From f3b36cf626b12ac5dcaf298d272b69f183cd72ec Mon Sep 17 00:00:00 2001
From: ligerbot <139721374+ligerbot@users.noreply.github.com>
Date: Sun, 31 Dec 2023 23:35:19 -0500
Subject: [PATCH 1/5] Add submission files
---
art/mazeGenerator-Evan/index.js | 239 ++++++++++++++
.../snapshots/10x10_maze.svg | 18 ++
.../175x175_maze-unrealisticForBlot.svg | 18 ++
.../snapshots/20x10_maze.svg | 18 ++
.../snapshots/squished_10x10_maze.svg | 18 ++
art/mazeGenerator-Evan/source.ts | 303 ++++++++++++++++++
6 files changed, 614 insertions(+)
create mode 100644 art/mazeGenerator-Evan/index.js
create mode 100644 art/mazeGenerator-Evan/snapshots/10x10_maze.svg
create mode 100644 art/mazeGenerator-Evan/snapshots/175x175_maze-unrealisticForBlot.svg
create mode 100644 art/mazeGenerator-Evan/snapshots/20x10_maze.svg
create mode 100644 art/mazeGenerator-Evan/snapshots/squished_10x10_maze.svg
create mode 100644 art/mazeGenerator-Evan/source.ts
diff --git a/art/mazeGenerator-Evan/index.js b/art/mazeGenerator-Evan/index.js
new file mode 100644
index 000000000..909216234
--- /dev/null
+++ b/art/mazeGenerator-Evan/index.js
@@ -0,0 +1,239 @@
+//+------------------------------------+
+//| SEE BOTTOM FOR RUN CODE & SETTINGS |
+//+------------------------------------+
+/*
+ .
+ .
+ . ;.
+ .;
+ ;;.
+ ;.;;
+ ;;;;.
+ ;;;;;
+ ;;;;;
+ ;;;;;
+ ;;;;;
+ ;;;;;
+ ..;;;;;..
+ ':::::'
+ ':`
+*/
+
+//THIS IS A BUILT SOURCE! It's advised you look at the original code before it was transpiled
+//You can find the code at: https://github.com/ligerbot/blot/tree/main/art/mazeGenerator-Evan
+var MazeDrawer = /** @class */ (function () {
+ function MazeDrawer() {
+ }
+ MazeDrawer.draw = function (X, Y, width, hight, maze) {
+ //Cleares entrence and exit
+ maze.walls.rows[0][0].isWall = false;
+ maze.walls.rows[maze.walls.rows.length - 1][maze.walls.rows[0].length - 1].isWall = false;
+ //Turtle time!
+ var turtle = createTurtle();
+ turtle.jump([X, Y]);
+ turtle.down();
+ //basicly the width of a colum
+ var rowSegmentLength = width / maze.grid.columCount;
+ //basicly the hight of a row
+ var columSegmentLength = hight / maze.grid.rowCount;
+ //ensure most efficient path of plotter
+ var directionToggle = true;
+ var currentRowY = Y;
+ for (var _i = 0, _a = maze.walls.rows.reverse(); _i < _a.length; _i++) {
+ var row = _a[_i];
+ if (directionToggle) {
+ //left to right
+ var nextX = X;
+ turtle.jump([nextX, currentRowY]);
+ for (var _b = 0, row_1 = row; _b < row_1.length; _b++) {
+ var wall = row_1[_b];
+ nextX += rowSegmentLength;
+ if (wall.isWall) {
+ turtle.goTo([nextX, currentRowY]);
+ }
+ else {
+ turtle.jump([nextX, currentRowY]);
+ }
+ }
+ directionToggle = false;
+ }
+ else {
+ //right to left
+ var nextX = X + width;
+ turtle.jump([nextX, currentRowY]);
+ for (var _c = 0, _d = row.reverse(); _c < _d.length; _c++) {
+ var wall = _d[_c];
+ nextX -= rowSegmentLength;
+ if (wall.isWall) {
+ turtle.goTo([nextX, currentRowY]);
+ }
+ else {
+ turtle.jump([nextX, currentRowY]);
+ }
+ }
+ directionToggle = true;
+ }
+ currentRowY += columSegmentLength;
+ }
+ //Some how borken, WIP
+ var currentColumX = X;
+ directionToggle = false;
+ for (var colum = 0; colum < maze.walls.colums[0].length; colum++) {
+ if (directionToggle) {
+ //left to right
+ var nextY = Y;
+ turtle.jump([currentColumX, nextY]);
+ for (var row = 0; row < maze.walls.colums.length; row++) {
+ nextY += columSegmentLength;
+ if (maze.walls.colums[maze.walls.colums.length - 1 - row][colum].isWall) {
+ turtle.goTo([currentColumX, nextY]);
+ }
+ else {
+ turtle.jump([currentColumX, nextY]);
+ }
+ }
+ directionToggle = false;
+ }
+ else {
+ //right to left
+ var nextY = Y + hight;
+ turtle.jump([currentColumX, nextY]);
+ for (var row = maze.walls.colums.length - 1; row >= 0; row--) {
+ nextY -= columSegmentLength;
+ if (maze.walls.colums[maze.walls.colums.length - 1 - row][colum].isWall) {
+ turtle.goTo([currentColumX, nextY]);
+ }
+ else {
+ turtle.jump([currentColumX, nextY]);
+ }
+ }
+ directionToggle = true;
+ }
+ currentColumX += rowSegmentLength;
+ }
+ drawTurtles([turtle]);
+ };
+ return MazeDrawer;
+}());
+var MazeImplementation = /** @class */ (function () {
+ function MazeImplementation(rows, colums) {
+ this.walls = new WallsImplementation(rows, colums);
+ this.grid = new CellGridImplementation(rows, colums, this.walls);
+ }
+ MazeImplementation.prototype.generateMaze = function () {
+ this.generateMazeHelper(0, 0);
+ };
+ MazeImplementation.prototype.generateMazeHelper = function (row, colum) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
+ this.grid.grid[row][colum].generated = true;
+ while (((_b = (_a = this.grid.grid[row - 1]) === null || _a === void 0 ? void 0 : _a[colum]) === null || _b === void 0 ? void 0 : _b.generated) === false || ((_d = (_c = this.grid.grid[row + 1]) === null || _c === void 0 ? void 0 : _c[colum]) === null || _d === void 0 ? void 0 : _d.generated) === false || ((_f = (_e = this.grid.grid[row]) === null || _e === void 0 ? void 0 : _e[colum - 1]) === null || _f === void 0 ? void 0 : _f.generated) === false || ((_h = (_g = this.grid.grid[row]) === null || _g === void 0 ? void 0 : _g[colum + 1]) === null || _h === void 0 ? void 0 : _h.generated) === false) {
+ //Math.floor(Math.random() * (max - min + 1) + min)
+ var randomNumber = Math.floor(Math.random() * (4 - 1 + 1) + 1);
+ //up,down,left,right
+ if (randomNumber === 1 && ((_j = this.grid.grid[row - 1]) === null || _j === void 0 ? void 0 : _j[colum]) != undefined && this.grid.grid[row - 1][colum].generated === false) {
+ this.grid.grid[row][colum].boderingWall.up.isWall = false;
+ this.generateMazeHelper(row - 1, colum);
+ }
+ else if (randomNumber === 2 && ((_k = this.grid.grid[row + 1]) === null || _k === void 0 ? void 0 : _k[colum]) != undefined && this.grid.grid[row + 1][colum].generated === false) {
+ this.grid.grid[row][colum].boderingWall.down.isWall = false;
+ this.generateMazeHelper(row + 1, colum);
+ }
+ else if (randomNumber === 3 && ((_l = this.grid.grid[row]) === null || _l === void 0 ? void 0 : _l[colum - 1]) != undefined && this.grid.grid[row][colum - 1].generated === false) {
+ this.grid.grid[row][colum].boderingWall.left.isWall = false;
+ this.generateMazeHelper(row, colum - 1);
+ }
+ else if (randomNumber === 4 && ((_m = this.grid.grid[row]) === null || _m === void 0 ? void 0 : _m[colum + 1]) != undefined && this.grid.grid[row][colum + 1].generated === false) {
+ this.grid.grid[row][colum].boderingWall.right.isWall = false;
+ this.generateMazeHelper(row, colum + 1);
+ }
+ }
+ };
+ MazeImplementation.prototype.resetMaze = function () {
+ var rows = this.grid.rowCount;
+ var colums = this.grid.rowCount;
+ this.walls = new WallsImplementation(rows, colums);
+ this.grid = new CellGridImplementation(rows, colums, this.walls);
+ };
+ MazeImplementation.prototype.displayMaze = function () {
+ var displayMazed = "Maze:\n";
+ for (var row = 0; row < this.grid.rowCount; row++) {
+ for (var colum = 0; colum < this.grid.columCount; colum++) {
+ displayMazed += this.grid.grid[row][colum].boderingWall.up.isWall ? "+---" : "+ ";
+ }
+ displayMazed += "+\n";
+ for (var colum = 0; colum < this.grid.columCount; colum++) {
+ displayMazed += this.grid.grid[row][colum].boderingWall.left.isWall ? "| " : " ";
+ }
+ displayMazed += this.grid.grid[row][this.grid.columCount - 1].boderingWall.right.isWall ? "|\n" : " \n";
+ if (this.grid.rowCount - 1 === row) {
+ for (var colum = 0; colum < this.grid.columCount; colum++) {
+ displayMazed += this.grid.grid[row][colum].boderingWall.down.isWall ? "+---" : "+ ";
+ }
+ displayMazed += "+\n";
+ }
+ }
+ console.log(displayMazed);
+ };
+ return MazeImplementation;
+}());
+var CellGridImplementation = /** @class */ (function () {
+ function CellGridImplementation(rows, colums, walls) {
+ var tempGrid = Array.from({ length: rows }, function () { return Array(colums).fill(undefined); });
+ for (var row = 0; row < tempGrid.length; row++) {
+ for (var colum = 0; colum < tempGrid[row].length; colum++) {
+ tempGrid[row][colum] = new CellImplementation(row, colum, walls);
+ }
+ }
+ this.grid = tempGrid;
+ this.rowCount = rows;
+ this.columCount = colums;
+ }
+ return CellGridImplementation;
+}());
+var CellImplementation = /** @class */ (function () {
+ function CellImplementation(row, colum, walls) {
+ this.row = row;
+ this.colum = colum;
+ this.boderingWall = new BoderingWallsImplementation(row, colum, walls);
+ this.generated = false;
+ }
+ return CellImplementation;
+}());
+var BoderingWallsImplementation = /** @class */ (function () {
+ function BoderingWallsImplementation(cellRow, cellColum, walls) {
+ this.up = walls.rows[cellRow][cellColum];
+ this.down = walls.rows[cellRow + 1][cellColum];
+ this.left = walls.colums[cellRow][cellColum];
+ this.right = walls.colums[cellRow][cellColum + 1];
+ }
+ return BoderingWallsImplementation;
+}());
+var WallsImplementation = /** @class */ (function () {
+ //Assumes user input is in terms of cells, not walls
+ function WallsImplementation(cellRows, cellColums) {
+ this.colums = Array.from(Array(cellRows), function () { return Array.from(Array(cellColums + 1), function () { return ({ isWall: true }); }); });
+ this.rows = Array.from(Array(cellRows + 1), function () { return Array.from(Array(cellColums), function () { return ({ isWall: true }); }); });
+ this.rowCount = cellRows + 1;
+ this.columCount = cellColums + 1;
+ }
+ return WallsImplementation;
+}());
+/*
+ __ __ _______
+| \ / \ | \
+| ▓▓\ / ▓▓ ______ ________ ______ | ▓▓▓▓▓▓▓\__ __ _______ _______ ______ ______ __
+| ▓▓▓\ / ▓▓▓| \| \/ \ | ▓▓__| ▓▓ \ | \ \| \ / \ / \| \
+| ▓▓▓▓\ ▓▓▓▓ \▓▓▓▓▓▓\\▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓\ | ▓▓ ▓▓ ▓▓ | ▓▓ ▓▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\\▓▓
+| ▓▓\▓▓ ▓▓ ▓▓/ ▓▓ / ▓▓| ▓▓ ▓▓ | ▓▓▓▓▓▓▓\ ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓ ▓▓ \▓▓ _
+| ▓▓ \▓▓▓| ▓▓ ▓▓▓▓▓▓▓/ ▓▓▓▓_| ▓▓▓▓▓▓▓▓ | ▓▓ | ▓▓ ▓▓__/ ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓▓▓▓▓▓▓ ▓▓ | \
+| ▓▓ \▓ | ▓▓\▓▓ ▓▓ ▓▓ \\▓▓ \ | ▓▓ | ▓▓\▓▓ ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓\▓▓ \ ▓▓ \▓▓
+ \▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓\▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓
+*/
+//Please exuse the lack of documentation
+//To generate a maze you need to make a new instance of MazeImplementation and then run the generateMaze(rows,colums) method on it.
+//Then use MazeDrawer.draw(startX, startY, widthInMM, hightInMM, mazeInstance)
+
+//Below is an example I made that you can play around with
+var maze = new MazeImplementation(5, 5);
+maze.generateMaze();
+MazeDrawer.draw(5, 5, 100, 100, maze);
diff --git a/art/mazeGenerator-Evan/snapshots/10x10_maze.svg b/art/mazeGenerator-Evan/snapshots/10x10_maze.svg
new file mode 100644
index 000000000..90814b4ad
--- /dev/null
+++ b/art/mazeGenerator-Evan/snapshots/10x10_maze.svg
@@ -0,0 +1,18 @@
+
+
+
\ No newline at end of file
diff --git a/art/mazeGenerator-Evan/snapshots/175x175_maze-unrealisticForBlot.svg b/art/mazeGenerator-Evan/snapshots/175x175_maze-unrealisticForBlot.svg
new file mode 100644
index 000000000..690d4cc40
--- /dev/null
+++ b/art/mazeGenerator-Evan/snapshots/175x175_maze-unrealisticForBlot.svg
@@ -0,0 +1,18 @@
+
+
+
\ No newline at end of file
diff --git a/art/mazeGenerator-Evan/snapshots/20x10_maze.svg b/art/mazeGenerator-Evan/snapshots/20x10_maze.svg
new file mode 100644
index 000000000..833523748
--- /dev/null
+++ b/art/mazeGenerator-Evan/snapshots/20x10_maze.svg
@@ -0,0 +1,18 @@
+
+
+
\ No newline at end of file
diff --git a/art/mazeGenerator-Evan/snapshots/squished_10x10_maze.svg b/art/mazeGenerator-Evan/snapshots/squished_10x10_maze.svg
new file mode 100644
index 000000000..ec7f93c45
--- /dev/null
+++ b/art/mazeGenerator-Evan/snapshots/squished_10x10_maze.svg
@@ -0,0 +1,18 @@
+
+
+
\ No newline at end of file
diff --git a/art/mazeGenerator-Evan/source.ts b/art/mazeGenerator-Evan/source.ts
new file mode 100644
index 000000000..348d6f78e
--- /dev/null
+++ b/art/mazeGenerator-Evan/source.ts
@@ -0,0 +1,303 @@
+//The import and functions here are so you can have access to the turtle functions when porgraming, for the real thing delete them
+import { Turtle } from "blot/virtual-gallery/drawing-functions/Turtle.js"
+function createTurtle(): Turtle {
+ return new Turtle
+}
+
+function drawTurtles(turtle: Turtle[]) { }
+
+function randIntInRange(min: number, max: number): number {
+ return Math.floor(Math.random() * (max - min + 1) + min)
+}
+//turtle stuff above^
+
+
+interface Maze {
+ walls: Walls
+ grid: CellGrid
+ // constructor(rows: number, colums: number)
+
+ generateMaze()
+
+ resetMaze()
+}
+
+interface CellGrid {
+ grid: Cell[][]
+ rowCount: number
+ columCount: number
+ // constructor(rows:number,colums:number)
+}
+
+interface Cell {
+ row: number
+ colum: number
+ boderingWall: boderingWalls
+ generated: boolean
+ // constructor(row:number,colum:number)
+}
+
+interface boderingWalls {
+ up: WallState
+ down: WallState
+ left: WallState
+ right: WallState
+ // constructor(up:object,down:object,left:object,right:object)
+}
+
+interface Walls {
+ colums: WallState[][]
+ rows: WallState[][]
+
+ // constructor(cellRows: number, cellColums: number)
+}
+
+interface WallState {
+ isWall: boolean;
+}
+/*
+ ______ __ __ __ __
+| \ | \ | \ | \ | \
+ \▓▓▓▓▓▓______ ____ ______ | ▓▓ ______ ______ ____ ______ _______ _| ▓▓_ ______ _| ▓▓_ \▓▓ ______ _______ __
+ | ▓▓ | \ \ / \| ▓▓/ \| \ \ / \| \| ▓▓ \ | \| ▓▓ \ | \/ \| \| \
+ | ▓▓ | ▓▓▓▓▓▓\▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\\▓▓▓▓▓▓ \▓▓▓▓▓▓\\▓▓▓▓▓▓ | ▓▓ ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\\▓▓
+ | ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ __ / ▓▓ | ▓▓ __| ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ _
+ _| ▓▓_| ▓▓ | ▓▓ | ▓▓ ▓▓__/ ▓▓ ▓▓ ▓▓▓▓▓▓▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓▓▓▓▓▓▓ ▓▓ | ▓▓ | ▓▓| \ ▓▓▓▓▓▓▓ | ▓▓| \ ▓▓ ▓▓__/ ▓▓ ▓▓ | ▓▓ \
+| ▓▓ \ ▓▓ | ▓▓ | ▓▓ ▓▓ ▓▓ ▓▓\▓▓ \ ▓▓ | ▓▓ | ▓▓\▓▓ \ ▓▓ | ▓▓ \▓▓ ▓▓\▓▓ ▓▓ \▓▓ ▓▓ ▓▓\▓▓ ▓▓ ▓▓ | ▓▓\▓▓
+ \▓▓▓▓▓▓\▓▓ \▓▓ \▓▓ ▓▓▓▓▓▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓
+ | ▓▓
+ | ▓▓
+ \▓▓
+*/
+
+
+class MazeDrawer {
+ public static draw(X: number, Y: number, width: number, hight: number, maze: Maze) {
+ //Cleares entrence and exit
+ maze.walls.rows[0][0].isWall = false
+ maze.walls.rows[maze.walls.rows.length - 1][maze.walls.rows[0].length - 1].isWall = false
+ //Turtle time!
+ let turtle = createTurtle()
+ turtle.jump([X, Y])
+ turtle.down()
+ //basicly the width of a colum
+ const rowSegmentLength = width / maze.grid.columCount
+ //basicly the hight of a row
+ const columSegmentLength = hight / maze.grid.rowCount
+
+ //ensure most efficient path of plotter
+ let directionToggle = true
+ let currentRowY = Y
+ for (let row of maze.walls.rows.reverse()) {
+ if (directionToggle) {
+ //left to right
+ let nextX = X
+ turtle.jump([nextX,currentRowY])
+ for (let wall of row) {
+ nextX += rowSegmentLength
+ if (wall.isWall) {
+ turtle.goTo([nextX, currentRowY])
+ } else {
+ turtle.jump([nextX, currentRowY])
+ }
+ }
+ directionToggle = false
+ } else {
+ //right to left
+ let nextX = X + width
+ turtle.jump([nextX,currentRowY])
+ for (let wall of row.reverse()) {
+ nextX -= rowSegmentLength
+ if (wall.isWall) {
+ turtle.goTo([nextX, currentRowY])
+ } else {
+ turtle.jump([nextX, currentRowY])
+ }
+ }
+ directionToggle = true
+ }
+ currentRowY += columSegmentLength
+ }
+
+ //Some how borken, WIP
+ let currentColumX = X
+ directionToggle = false
+ for (let colum = 0; colum < maze.walls.colums[0].length; colum++) {
+ if (directionToggle) {
+ //left to right
+ let nextY = Y
+ turtle.jump([currentColumX, nextY])
+ for (let row = 0; row < maze.walls.colums.length; row++) {
+ nextY += columSegmentLength
+ if (maze.walls.colums[maze.walls.colums.length - 1 - row][colum].isWall) {
+ turtle.goTo([currentColumX,nextY])
+ } else {
+ turtle.jump([currentColumX,nextY])
+ }
+ }
+ directionToggle = false
+ } else {
+ //right to left
+ let nextY = Y + hight
+ turtle.jump([currentColumX,nextY])
+ for (let row = maze.walls.colums.length - 1; row >= 0; row--) {
+ nextY -= columSegmentLength
+ if (maze.walls.colums[maze.walls.colums.length - 1 - row][colum].isWall) {
+ turtle.goTo([currentColumX,nextY])
+ } else {
+ turtle.jump([currentColumX,nextY])
+ }
+ }
+ directionToggle = true
+ }
+ currentColumX += rowSegmentLength
+ }
+
+ drawTurtles([ turtle ])
+ }
+}
+
+class MazeImplementation implements Maze {
+ walls: Walls
+ grid: CellGrid
+ constructor(rows: number, colums: number) {
+ this.walls = new WallsImplementation(rows, colums)
+ this.grid = new CellGridImplementation(rows, colums, this.walls)
+ }
+
+ generateMaze() {
+ this.generateMazeHelper(0, 0)
+ }
+
+ private generateMazeHelper(row: number, colum: number) {
+ this.grid.grid[row][colum].generated = true
+ while (this.grid.grid[row - 1]?.[colum]?.generated === false || this.grid.grid[row + 1]?.[colum]?.generated === false || this.grid.grid[row]?.[colum - 1]?.generated === false || this.grid.grid[row]?.[colum + 1]?.generated === false) {
+ //Math.floor(Math.random() * (max - min + 1) + min)
+ const randomNumber = randIntInRange(1,4)
+ //up,down,left,right
+ if (randomNumber === 1 && this.grid.grid[row - 1]?.[colum] != undefined && this.grid.grid[row - 1][colum].generated === false) {
+ this.grid.grid[row][colum].boderingWall.up.isWall = false
+ this.generateMazeHelper(row - 1, colum)
+ } else if (randomNumber === 2 && this.grid.grid[row + 1]?.[colum] != undefined && this.grid.grid[row + 1][colum].generated === false) {
+ this.grid.grid[row][colum].boderingWall.down.isWall = false
+ this.generateMazeHelper(row + 1, colum)
+ } else if (randomNumber === 3 && this.grid.grid[row]?.[colum - 1] != undefined && this.grid.grid[row][colum - 1].generated === false) {
+ this.grid.grid[row][colum].boderingWall.left.isWall = false
+ this.generateMazeHelper(row, colum - 1)
+ } else if (randomNumber === 4 && this.grid.grid[row]?.[colum + 1] != undefined && this.grid.grid[row][colum + 1].generated === false) {
+ this.grid.grid[row][colum].boderingWall.right.isWall = false
+ this.generateMazeHelper(row, colum + 1)
+ }
+ }
+ }
+
+ resetMaze() {
+ const rows = this.grid.rowCount
+ const colums = this.grid.rowCount
+ this.walls = new WallsImplementation(rows, colums)
+ this.grid = new CellGridImplementation(rows, colums, this.walls)
+ }
+
+ displayMaze() {
+ let displayMazed = "Maze:\n";
+ for (let row = 0; row < this.grid.rowCount; row++) {
+ for (let colum = 0; colum < this.grid.columCount; colum++) {
+ displayMazed += this.grid.grid[row][colum].boderingWall.up.isWall ? "+---" : "+ ";
+ }
+ displayMazed += "+\n";
+
+ for (let colum = 0; colum < this.grid.columCount; colum++) {
+ displayMazed += this.grid.grid[row][colum].boderingWall.left.isWall ? "| " : " ";
+ }
+ displayMazed += this.grid.grid[row][this.grid.columCount - 1].boderingWall.right.isWall ? "|\n" : " \n"
+
+ if (this.grid.rowCount - 1 === row) {
+ for (let colum = 0; colum < this.grid.columCount; colum++) {
+ displayMazed += this.grid.grid[row][colum].boderingWall.down.isWall ? "+---" : "+ ";
+ }
+ displayMazed += "+\n";
+ }
+ }
+ console.log(displayMazed);
+ }
+
+}
+
+class CellGridImplementation implements CellGrid {
+ grid: Cell[][]
+ rowCount: number
+ columCount: number
+ constructor(rows: number, colums: number, walls: Walls) {
+ let tempGrid: any[][] = Array.from({ length: rows }, () => Array(colums).fill(undefined));
+ for (let row = 0; row < tempGrid.length; row++) {
+ for (let colum = 0; colum < tempGrid[row].length; colum++) {
+ tempGrid[row][colum] = new CellImplementation(row, colum, walls)
+ }
+ }
+ this.grid = tempGrid
+ this.rowCount = rows
+ this.columCount = colums
+ }
+}
+
+class CellImplementation implements Cell {
+ row: number
+ colum: number
+ boderingWall: boderingWalls
+ generated: boolean
+ constructor(row: number, colum: number, walls: Walls) {
+ this.row = row
+ this.colum = colum
+ this.boderingWall = new BoderingWallsImplementation(row, colum, walls)
+ this.generated = false
+ }
+}
+
+class BoderingWallsImplementation implements boderingWalls {
+ up: WallState
+ down: WallState
+ left: WallState
+ right: WallState
+ constructor(cellRow: number, cellColum: number, walls: Walls) {
+ this.up = walls.rows[cellRow][cellColum]
+ this.down = walls.rows[cellRow + 1][cellColum]
+ this.left = walls.colums[cellRow][cellColum]
+ this.right = walls.colums[cellRow][cellColum + 1]
+ }
+}
+
+class WallsImplementation implements Walls {
+ colums: WallState[][]
+ rows: WallState[][]
+ //number of rows and colums of walls
+ rowCount: number
+ columCount: number
+
+ //Assumes user input is in terms of cells, not walls
+ constructor(cellRows: number, cellColums: number) {
+ this.colums = Array.from(Array(cellRows), () => Array.from(Array(cellColums + 1), () => ({ isWall: true })));
+ this.rows = Array.from(Array(cellRows + 1), () => Array.from(Array(cellColums), () => ({ isWall: true })));
+ this.rowCount = cellRows + 1
+ this.columCount = cellColums + 1
+ }
+
+}
+/*
+ __ __ _______
+| \ / \ | \
+| ▓▓\ / ▓▓ ______ ________ ______ | ▓▓▓▓▓▓▓\__ __ _______ _______ ______ ______ __
+| ▓▓▓\ / ▓▓▓| \| \/ \ | ▓▓__| ▓▓ \ | \ \| \ / \ / \| \
+| ▓▓▓▓\ ▓▓▓▓ \▓▓▓▓▓▓\\▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓\ | ▓▓ ▓▓ ▓▓ | ▓▓ ▓▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\\▓▓
+| ▓▓\▓▓ ▓▓ ▓▓/ ▓▓ / ▓▓| ▓▓ ▓▓ | ▓▓▓▓▓▓▓\ ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓ ▓▓ \▓▓ _
+| ▓▓ \▓▓▓| ▓▓ ▓▓▓▓▓▓▓/ ▓▓▓▓_| ▓▓▓▓▓▓▓▓ | ▓▓ | ▓▓ ▓▓__/ ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓▓▓▓▓▓▓ ▓▓ | \
+| ▓▓ \▓ | ▓▓\▓▓ ▓▓ ▓▓ \\▓▓ \ | ▓▓ | ▓▓\▓▓ ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓\▓▓ \ ▓▓ \▓▓
+ \▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓\▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓
+*/
+//Please exuse the lack of documentation
+//To generate a maze you need to make a new instance of MazeImplementation and then run the generateMaze(rows,colums) method on it.
+//Then use MazeDrawer.draw(startX, startY, widthInMM, hightInMM, mazeInstance)
+
+//Below is an example I made that you can play around with
+let maze = new MazeImplementation(5, 5)
+maze.generateMaze()
+MazeDrawer.draw(5, 5, 100, 100, maze)
From 2c4fa68ab11b5be7e1edc6f9b1c982c4ba913e05 Mon Sep 17 00:00:00 2001
From: ligerbot <139721374+ligerbot@users.noreply.github.com>
Date: Mon, 1 Jan 2024 12:20:12 -0500
Subject: [PATCH 2/5] Update index.js
Forgot to use blots RNG, changed to it.
---
art/mazeGenerator-Evan/index.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/art/mazeGenerator-Evan/index.js b/art/mazeGenerator-Evan/index.js
index 909216234..74ebdd772 100644
--- a/art/mazeGenerator-Evan/index.js
+++ b/art/mazeGenerator-Evan/index.js
@@ -75,7 +75,7 @@ var MazeDrawer = /** @class */ (function () {
}
currentRowY += columSegmentLength;
}
- //Some how borken, WIP
+ //Colums
var currentColumX = X;
directionToggle = false;
for (var colum = 0; colum < maze.walls.colums[0].length; colum++) {
@@ -128,7 +128,7 @@ var MazeImplementation = /** @class */ (function () {
this.grid.grid[row][colum].generated = true;
while (((_b = (_a = this.grid.grid[row - 1]) === null || _a === void 0 ? void 0 : _a[colum]) === null || _b === void 0 ? void 0 : _b.generated) === false || ((_d = (_c = this.grid.grid[row + 1]) === null || _c === void 0 ? void 0 : _c[colum]) === null || _d === void 0 ? void 0 : _d.generated) === false || ((_f = (_e = this.grid.grid[row]) === null || _e === void 0 ? void 0 : _e[colum - 1]) === null || _f === void 0 ? void 0 : _f.generated) === false || ((_h = (_g = this.grid.grid[row]) === null || _g === void 0 ? void 0 : _g[colum + 1]) === null || _h === void 0 ? void 0 : _h.generated) === false) {
//Math.floor(Math.random() * (max - min + 1) + min)
- var randomNumber = Math.floor(Math.random() * (4 - 1 + 1) + 1);
+ var randomNumber = randInRange(1,4);
//up,down,left,right
if (randomNumber === 1 && ((_j = this.grid.grid[row - 1]) === null || _j === void 0 ? void 0 : _j[colum]) != undefined && this.grid.grid[row - 1][colum].generated === false) {
this.grid.grid[row][colum].boderingWall.up.isWall = false;
From 130d737840ba09ef189d59c664c2b625205a19aa Mon Sep 17 00:00:00 2001
From: ligerbot <139721374+ligerbot@users.noreply.github.com>
Date: Mon, 1 Jan 2024 12:23:12 -0500
Subject: [PATCH 3/5] Update source.ts
Removed inaccurate comment saying something was broken when it was not.
---
art/mazeGenerator-Evan/source.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/art/mazeGenerator-Evan/source.ts b/art/mazeGenerator-Evan/source.ts
index 348d6f78e..de373e3ee 100644
--- a/art/mazeGenerator-Evan/source.ts
+++ b/art/mazeGenerator-Evan/source.ts
@@ -119,7 +119,7 @@ class MazeDrawer {
currentRowY += columSegmentLength
}
- //Some how borken, WIP
+ //Colums
let currentColumX = X
directionToggle = false
for (let colum = 0; colum < maze.walls.colums[0].length; colum++) {
From 4c66ba9bdbefcb45899b9b9bd8d4e63549dfafb3 Mon Sep 17 00:00:00 2001
From: ligerbot <139721374+ligerbot@users.noreply.github.com>
Date: Mon, 1 Jan 2024 12:34:23 -0500
Subject: [PATCH 4/5] Use correct RNG function
Updated the RNG function to use the int one.
---
art/mazeGenerator-Evan/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/art/mazeGenerator-Evan/index.js b/art/mazeGenerator-Evan/index.js
index 74ebdd772..7a7dfb63a 100644
--- a/art/mazeGenerator-Evan/index.js
+++ b/art/mazeGenerator-Evan/index.js
@@ -128,7 +128,7 @@ var MazeImplementation = /** @class */ (function () {
this.grid.grid[row][colum].generated = true;
while (((_b = (_a = this.grid.grid[row - 1]) === null || _a === void 0 ? void 0 : _a[colum]) === null || _b === void 0 ? void 0 : _b.generated) === false || ((_d = (_c = this.grid.grid[row + 1]) === null || _c === void 0 ? void 0 : _c[colum]) === null || _d === void 0 ? void 0 : _d.generated) === false || ((_f = (_e = this.grid.grid[row]) === null || _e === void 0 ? void 0 : _e[colum - 1]) === null || _f === void 0 ? void 0 : _f.generated) === false || ((_h = (_g = this.grid.grid[row]) === null || _g === void 0 ? void 0 : _g[colum + 1]) === null || _h === void 0 ? void 0 : _h.generated) === false) {
//Math.floor(Math.random() * (max - min + 1) + min)
- var randomNumber = randInRange(1,4);
+ var randomNumber = randIntInRange(1,4);
//up,down,left,right
if (randomNumber === 1 && ((_j = this.grid.grid[row - 1]) === null || _j === void 0 ? void 0 : _j[colum]) != undefined && this.grid.grid[row - 1][colum].generated === false) {
this.grid.grid[row][colum].boderingWall.up.isWall = false;
From 138c337894937471c6a3b146248dd01cb82d967e Mon Sep 17 00:00:00 2001
From: leomcelroy
Date: Tue, 2 Jan 2024 11:36:51 -0500
Subject: [PATCH 5/5] Update !metadata.json
---
art/!metadata.json | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/art/!metadata.json b/art/!metadata.json
index bd526fed5..a7f793536 100644
--- a/art/!metadata.json
+++ b/art/!metadata.json
@@ -58,5 +58,10 @@
"directory": "self_portrait-kieran",
"snapshots": ["snapshot-1.png"],
"source": "index.js"
- }
+ },
+ {
+ "directory": "maxeGenerator-Evan",
+ "snapshots": ["20x10_maze.svg"],
+ "source": "index.js"
+ },
]