export enum Direction { none = 0, top = 1 << 0, left = 1 << 1, bottom = 1 << 2, right = 1 << 3, } export class MazeTile { public paths:Direction[]; public id:string; public neighbors:Map<Direction, MazeTile>; constructor(id:string) { this.id = id; this.paths = []; this.neighbors = new Map<Direction, MazeTile>(); } public getRepresentation(): number { let output = Direction.none; for (const dir of this.paths) { output |= dir; } return output; } } export class MazeMap { public id:string; public allTiles:Map<string, MazeTile>; public cart:MazeTile[][]; constructor(id:string) { this.id = id; this.allTiles = new Map<string, MazeTile>(); this.cart = []; } public getRepresentation(): number[][] { const output:number[][] = []; for (const row of this.cart) { const newRow:number[] = []; for (const cell of row) { newRow.push(cell.getRepresentation()); } output.push(newRow); } return output; } }