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

Loic fejoz loic at fejoz.net
Fri Aug 23 08:25:32 EDT 2002


Keith S. <keith_s at ntlworld.nospam.com> wrote:
> Mr. Neutron wrote:
>
>> 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.
>
> Why not represent the 'world' as a graph. Each vertex of the graph
> is one 'location'. Edges of the graph connect locations (this is
> nice, since it means you can control how your robot can move from
> location to location - different edges can have different costs,
> representing distance between vertices).
>
> Not sure if there's any good books on graph implementation in Python,
> but you can get a good overview from 'Algorithms in C++ Part 5'
> by Robert Sedgewick, published by Addison Wesley.
>
> - Keith


Guido's essays on Graph with Python :
http://www.python.org/doc/essays/graphs.html

--
Loïc





More information about the Python-list mailing list