Computer Science question (python list is slow with my cruddy algorithm )

Bengt Richter bokr at
Sat Aug 24 03:44:32 CEST 2002

On Fri, 23 Aug 2002 06:53:03 -0400, "Mr. Neutron" <nicktsocanos at> wrote:
>Now I have made a very simple robot that can move around a world that is
>64x64 miles in area. It finds ore and collects it, finds fuel and gathers
>it. It understands that it needs to explore it's world to find resources.
>It moves about looking for things to collect. I am working on the store
>so that it can go to the store and buy items and upgrade. 
>Now that that is out of the way, are there any better ways to represent
>the world than a list of lists? I just need to be able to say
>World[Y][X] = ( values ). Or be able to say what is at World[Position].
>Ideally I could say World[ (X,Y) ] = (Values) but I have not tried this.
>If World[ (X,Y) ] is empty, than it does not need to store anything in
>memory at all. I need to go to Idle now and experiment with this.
Have you considered storing your world attributes in a relational database?
Check into what you can do with an SQL select statement (quite a bit ;-).
See python db stuff at

E.g., you could write a single SQL query to get all world-items within
a +/- dx,dy of a particular position that had more than some amount of whatever
and also had or didn't have other features. The result would be a set of records
you had previously stored in the database that met the criteria.

I'd also bet that the kind of data base that is behind e.g., MapQuest and such
might be applicable. (Are there free Python GIS dbms'?)

I googled a little and found this FAQ for PostGIS, a GIS extension of postgreSQL:

Looks like a pretty big project to get going though, and unix-oriented, but
it might give you ideas.

Bengt Richter

More information about the Python-list mailing list