Anonymous user
Maze generation: Difference between revisions
→{{header|Java}}: randomize() was not a correct shuffle (http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Implementation_errors), plus shuffle is already in library
(→{{header|Java}}: lang tag; whitespace) |
(→{{header|Java}}: randomize() was not a correct shuffle (http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Implementation_errors), plus shuffle is already in library) |
||
Line 1,026:
import java.util.Random;
import java.util.Collections;
import java.util.Arrays;
/*
Line 1,067 ⟶ 1,069:
private void generateMaze(int cx, int cy) {
Collections.shuffle(Arrays.asList(dirs));
for (DIR dir : dirs) {
int nx = cx + dir.dx;
int ny = cy + dir.dy;
Line 1,079 ⟶ 1,083:
}
private static boolean between(int v, int upper) {
return (v >= 0) && (v < upper);
}
|