I'm still working on my Cell class for my maze game I'm trying to make. After helping in another thread, it was suggested that I use EnumMap for my Walls / Neighbors, and this works fine so far.
Here is what I still have:
enum Dir { NORTH, SOUTH, EAST, WEST } class Cell { public Map<Dir, Cell> neighbors = Collections .synchronizedMap(new EnumMap<Dir, Cell>(Dir.class)); public Map<Dir, Boolean> walls = Collections .synchronizedMap(new EnumMap<Dir, Boolean>(Dir.class)); public boolean Visited; public Cell() { Visited = false; for (Dir direction : Dir.values()) { walls.put(direction, true); } }
If you look at this last comment, I will first tear down, say, a NORTH wall in my current cell. Then I take my northern neighbor, and now I have to tear down my southern wall, so the walls between the two cells have been removed.
What will be a simple way to expand my enumeration so that I can give him direction, and he returns me the opposite?
source share