public void _05_Processor_Calculates_Transitions_Correclty() { var map = new SlidingPuzzleMap( "1111;" + "10W1;" + "101;" + "101;" + "111"); var processor = new SlidingPuzzleProcessor(map); var initState = new SlidingPuzzleState(new Vector2Int(1, 3)); var result = processor.ProcessWithTransitions(initState, new Vector2Int(0, -1)); Assert.That(result.Transitions.Length, Is.EqualTo(1), $"Transitions Size Incorrect"); Assert.That(result.Transitions[0], Is.EqualTo(new Transition(initState.PlayerCoords, new Vector2Int(1, 1))), $"Transition list is incorrect"); }
public void _01_String_Parsing_Works() { var walls = new bool[4, 5] { { true, true, true, true, true }, { true, false, false, false, true }, { true, true, true, false, true }, { true, true, true, true, true } }; var map = new SlidingPuzzleMap( "1111;" + "1001;" + "1011;" + "1W1;" + "111"); Assert.That(new Vector2Int(map.Walls.GetLength(0), map.Walls.GetLength(1)), Is.EqualTo(new Vector2Int(4, 5)), "Size in incorrect"); Assert.That(map.Walls, Is.EqualTo(walls), $"Incorrect array\nExpected:\n{ArrayToText(walls)}and got:\n{ArrayToText(map.Walls)}"); Assert.That(map.WinCoords, Is.EqualTo(new Vector2Int(1, 1)), $"Win is in incorect place"); }
public void _04_Processor_Move_Correctly_Resolved(int[] start, int[] dir, int[] expected, bool expectedWin) { var map = new SlidingPuzzleMap( "1111;" + "1001;" + "1011;" + "1W1;" + "111"); var processor = new SlidingPuzzleProcessor(map); var initState = new SlidingPuzzleState(new Vector2Int(start[0], start[1])); var result = processor.Process(initState, new Vector2Int(dir[0], dir[1])); Assert.That(result.PlayerCoords, Is.EqualTo(new Vector2Int(expected[0], expected[1])), "Player is in incorrect position"); if (expectedWin) { Assert.That(result.Type, Is.EqualTo(SlidingPuzzleState.StateType.Win), "Move is not registered as winning"); } else { Assert.That(result.Type, Is.EqualTo(SlidingPuzzleState.StateType.Idle), "Move is registered as winning"); } }
public SlidingPuzzleProcessor Reconstruct(SlidingPuzzleMap map) { _map = map; return(this); }
public SlidingPuzzleProcessor(SlidingPuzzleMap map) { _map = map; }