public SokobanSolver(string path) { map = new SokobanSolverMap(path); arrayComparer = new ArrayComparer <ushort>(); moves = new Dictionary <ushort[], ushort[]>(arrayComparer); states = new Queue <ushort[]>(); explorer = new SokobanSolverExplorer(map); solutionBox = null; solutionPath = null; countMoves = 0; }
public SokobanStepper(SokobanSolverMap map) { this.map = new SokobanSolverMap(map); explorer = new SokobanSolverExplorer(this.map); newStatesCount = 0; newStates = new ushort[map.boxesCount * 4][]; accessXYs = new ushort[map.boxesCount * 4]; newStatesAvaliableCount = 0; distance = new int[map.boxesCount * 4]; order = new int[map.boxesCount * 4]; state = null; }
public SokobanSolverExplorer(SokobanSolverMap map) { this.map = map; state = null; cells = new byte[map.size]; Array.Copy(map.cells, cells, map.size); distance = new int[map.size]; backtrace = new ushort[map.size]; explore = new FixedQueue <ushort>(map.size); path = new FixedStack <ushort>(map.size); }
void RenderMenu() { Console.SetCursorPosition(0, 0); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Select map:"); int windowHeight = Math.Min(maps.Length + 1, Console.WindowHeight - 4); int menuOffset = Math.Min(0, maps.Length + 1 - selectedMapPos - windowHeight); for (int i = 0; i < windowHeight; ++i) { int mapPos = i + selectedMapPos + menuOffset; if (mapPos == selectedMapPos) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; } else { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; } string element; if (mapPos == 0) { Console.ForegroundColor = ConsoleColor.DarkGreen; element = newItem; } else { SokobanSolverMap map = maps[mapPos - 1]; if (map.lrud == null) { element = map.Name; } else { element = $"{map.Name} [{map.lrud.Length,4}]"; } } Console.SetCursorPosition(0, i + 1); Console.Write(element.PadLeft(element.Length + ((maxMapNameLength - element.Length) >> 1)).PadRight(maxMapNameLength)); } Console.ResetColor(); }
public SokobanSolverMap(SokobanSolverMap map) { path = map.path; size = map.size; width = map.width; height = map.height; boxesCount = map.boxesCount; cells = new byte[size]; targetXYs = new ushort[map.boxesCount]; boxXYs = new ushort[map.boxesCount]; Array.Copy(map.cells, cells, map.size); Array.Copy(map.targetXYs, targetXYs, map.boxesCount); Array.Copy(map.boxXYs, boxXYs, map.boxesCount); playerXY = map.playerXY; }