Created
December 8, 2019 15:27
-
-
Save Dev-Owl/ff6e33a85f0f9e43474aac1ce551fba4 to your computer and use it in GitHub Desktop.
Example to get a maze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:theseus/theseus.dart'; | |
import 'package:theseus/src/formatters/formatters.dart' as formatters; | |
main(List<String> arguments) { | |
var mazeOption = MazeOptions(width: 8, height: 8); | |
var orthogonalMaze = OrthogonalMaze(mazeOption); | |
print("generating the maze..."); | |
orthogonalMaze.generate(); | |
printMaze(orthogonalMaze); | |
for (var x = 0; x < 8; ++x) { | |
printCellDetails(orthogonalMaze.getCell(x, 0)); | |
} | |
} | |
void printCellDetails(int cell) { | |
print(cell.toRadixString(2)); | |
if (cell & Maze.N == Maze.N) { | |
print("North is open"); | |
} | |
else{ | |
print("North is closed"); | |
} | |
if (cell & Maze.S == Maze.S) { | |
print("South is open"); | |
} | |
else{ | |
print("South is closed"); | |
} | |
if (cell & Maze.W == Maze.W) { | |
print("West is open"); | |
} | |
else{ | |
print("West is closed"); | |
} | |
if (cell & Maze.E == Maze.E) { | |
print("East is open"); | |
} | |
else{ | |
print("East is closed"); | |
} | |
} | |
void printMaze(Maze maze) { | |
formatters.ASCIIMode.values.forEach((formatters.ASCIIMode mode) { | |
print("mode: $mode"); | |
var out = | |
maze.to<formatters.ASCII, formatters.ASCIIMode>(FormatType.ascii, mode); | |
print(out.toString()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment