Hunt The Wumpus/Java: Difference between revisions

→‎Code: don't try to place identical hazards in the same room
mNo edit summary
(→‎Code: don't try to place identical hazards in the same room)
Line 103:
hazards.put(i, EnumSet.noneOf(Hazard.class));
 
// hazards can share rooms (unless they are identical)
int[] ordinals = {0, 1, 1, 1, 2, 2};
Hazard[] values = Hazard.values();
Line 110:
do {
room = rand.nextInt(rooms.length);
} while (tooCloseForComforttooClose(room) || hazards.get(room).contains(values[ord]));
 
if (ord == 0)
Line 122:
 
// don't place hazards close to the starting room
boolean tooCloseForComforttooClose(int room) {
if (currRoom == room)
return true;
Anonymous user