External data files in a scripting language

I’m new to Python, and have encountered a point on which I’m a little uncertain.

In C++, I would probably want my game to be “data-driven”, and employ external data files which are interpreted by the program.

For example, I’m looking at the moment at creating a weapon class. If I were doing this in C++, I would probably make a fairly general weapon class (or a small set of classes), then produce specific weapons (with varying damage values, appearances, reload/cooldown times, etc.) by loading values from an external file.

Similarly, if I were to allow special “on-event” behaviour for enemies, I might include it in an external file, which is then read in and interpreted by the program.

However, Python is already a scripting language.

So, am I correct then in thinking that I should just directly create my weapon templates or event scripts in a Python file, as Python objects from the start, without some sort of file loading and interpretation? That seems logical, although it raises my C+±born “hard-coding” red flag. ^^;;

yes that is logical. I code all my configurations in python. Also i try to separate python configuration files and python engine files.

Aah, good, thank you. I think that I will handle things that way, then. :slight_smile:

It’s usually convenient to handle storage and behavior rules in the same module, when you are making a game. I suggest you use a free rule-based system like PyCLIPS and store your data with in pyclips data files.

Don’t get scared with it’s strange syntax. PyCLIPS is really the best solution for game data and handling game behaviors. You can have millions of rules and it will test all those rules for you almost at fixed time. The algorithm used to optimize this is a variant of the RETE algorithm.
It’s not an easy to grasp think but the important thing is that it works.

Hmm… It’s an expert system toolkit, am I correct?

It looks as though it could be very useful for non-basic AI, indeed. That said, I don’t think that I’m planning on building AIs that call for anything as specific as an expert system - for now, at least, the sort of “on-event behaviour” that I was talking about is probably going to be something as simple as:

     change_state: angry
     switch_weapon: big nasty gun


     if impacted is poppy
          change_state: asleep

Where being “angry” just has the creature charge blindly (if quickly) at the player firing rapidly.

Very, very simple AI, in other words. :wink:

I’m not sure how it would apply to the storage of such things as weapon characteristics, however… (Unless I’ve missed something, of course.) I don’t see why I would keep item templates in the same way as such an expert system - I would think that separate files would work better (with the characteristic file perhaps referring to the behaviour file).

Hmm… I wonder, however, whether an expert system might have some use in the design for an adventure game puzzle system… I can see the possibility for puzzles that make use of expert systems, I think, but I wonder whether the design of the overall puzzle system (which keeps track of actions to be taken, whether or not the puzzle has been solved, etc.) might benefit from it…

Probably not, I don’t think. It may well bear some further thought, but I suspect that a state machine is better for that…

All of that said, thank you very much for mentioning it - I’ve bookmarked the SourceForge page that I presume to be its homepage. It could well come in handy in the future, whether for AI, as a puzzle tool, or some other use. :slight_smile: