Skip to content

Instantly share code, notes, and snippets.

@Dev-Owl
Created December 8, 2019 15:27
Show Gist options
  • Save Dev-Owl/ff6e33a85f0f9e43474aac1ce551fba4 to your computer and use it in GitHub Desktop.
Save Dev-Owl/ff6e33a85f0f9e43474aac1ce551fba4 to your computer and use it in GitHub Desktop.
Example to get a maze
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