[Tutor] ** Newbie ** LARGE lists versus databases - what's faster?

Chris McCormick cmccormick@thestate.com
Fri, 01 Feb 2002 10:34:01 -0500


Hello all, and thanks for listening to a newbie.

I've been working with pyGame for about a week, and am getting into some small proof-of-concept programs for CRPG game ideas that I have.

One idea is that of NPC "gossip".  It would consist of a system by which NPC's could have access to knowledge about the world, and share it with each other and the player character as well.  This would make for 
a much more realistic gaming experience if done right.

Problem is, I'm very new to algorithm/data structure design, and pretty new to Python as well.  So, I'm not sure what's the best way to go about this.  I imagine that (to start off with) I'll have a list of "subject tokens," 
which would contain the names of all the NPC's, the player, towns, inns, monsters, etc.  This would go in position 1:

The --------- 

Then, I'd have a list of modifiers, like "hungry," "dangerous," "at war," etc., which could be applied to the subjects, according to some set of rules.  So, you could have a subject token of "The town of 
Windermere," with a modifier token of "is starving,", and then put them together for the sentence "The town of Windermere is starving."  The resulting sentence would be stored in a third data structure.  Then, 
NPC's would have access to it.  The NPC's in Windermere would automatically have access to the data, and they might give access to other NPC's they meet.  So, the "gossip" would spread, and eventually the 
player might hear about it, and set off to Windermere to help.

With me so far?  So, in a very basic implementation of this, I have something like:

1.  A list of subjects
2.  A list of modifications/verbs
3.  A list for the resulting "gossip" strings.

And of course rules and code for generating/transferring/pruning the gossip items.

My question (thanks for reading so much, by the way) is this:

What kind of data structures should I put these things in?  I'm new enough to python that I haven't learned about things like pickles(?) and shelves(?), so I don't know if there are advanced data structures out there 
that might be well suited to large, lookup-able, constantly changing sets of information.  I also don't know if this would be best stored (i.e., with the most speed) in a list, a text file, a database (say, MySQL), or what.

Any ideas where I should start?  Good redaing material?  Similar projects?

Thanks in advance,
Chris McCormick