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

Bengt Richter bokr at oz.net
Fri Aug 23 21:44:32 EDT 2002


On Fri, 23 Aug 2002 06:53:03 -0400, "Mr. Neutron" <nicktsocanos at charter.net> 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 http://www.python.org/topics/database/

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:

http://postgis.refractions.net/docs/c191.html

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

Regards,
Bengt Richter



More information about the Python-list mailing list