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

Mr. Neutron nicktsocanos at
Fri Aug 23 19:48:40 CEST 2002

On Thu, 22 Aug 2002 20:35:51 -0400, Jay O'Connor wrote:

> Would it work to use some sort of Flywheel pattern?  Instead of having a
> two dimensional list of world coordinates with each space having (or
> not) a set of features, have a dictionary where the key is a feature and
> the value is a list of tuples representing the world coordinate
> worldmap = {
> 	"ore": [(1,2), (1,3)...],
> 	"food": [(10,11), (12,13)...]
> ...}
> then to know what features are in a give location you do a reverse
> lookup
> location = (x,y)
> featuresInLocation = []
> for each in worldmap.keys():
> 	if location in worldmap (each):
> 		featuresInLocation.append (each)
> When this is done, featuresInLocation will hold "ore", "food" etc...for
> (x,y)
> From here, it may be possible to use a RunArray of some sort to further
> reduce memory for contigious locations that contain a given feature
This is actually an interesting idea I never thought of! Actually this
would make it much easier to find things in the world too. I will
investigate this one.

I see an immediate need for this in my robot logic. I can build this into
it's logic for finding resources it located in it's expedition throughout
the world.


More information about the Python-list mailing list