cleverhandle
Diamond Member
I'm trying to create a Collection that will let me keep track of objects based on their location in an xy coordinate plane. I had originally thought to do this using a HashMap keyed with an int[2] array, but that doesn't work - I'm searching the Map based on the location of a different object moving through the plane, and I can't see any way to search based on the values of the array rather than an object reference. Basically, I want to be able to ask the Collection: "Have I seen an object at this location before?" At this point, the only thing I can think of is to make the location array a member variable of the class, use an ArrayList, and iterate through the whole ArrayList checking every value against the current location. But that's obviously a very ugly solution.
Context: I'm working on a program to get a (simulated) robot to escape from a maze. At this point I have a program that works, but only for mazes without loops. I'm trying to make the program loop-tolerant by keeping track of intersections based on their location relative to my starting point.
Context: I'm working on a program to get a (simulated) robot to escape from a maze. At this point I have a program that works, but only for mazes without loops. I'm trying to make the program loop-tolerant by keeping track of intersections based on their location relative to my starting point.