public void InitBoard(GameMasterSettingsGameDefinitionConfiguration settings) { Monitor.Enter(lockObject); actualBoard = new GameObjects.GameBoard((int)settings.BoardWidth, (int)settings.TaskAreaLength, (int)settings.GoalAreaLength, GoalFieldType.nongoal); PlaceInitialPieces((int)settings.InitialNumberOfPieces); PlaceInitialGoals(settings.Goals.Select(q => q).ToArray()); Monitor.Exit(lockObject); }
public void ManhattanDistance() { GameMasterSettingsGameDefinitionConfiguration settings = new GameMasterSettingsGameDefinitionConfiguration(GameMasterSettingsGameDefinition.GetDefaultGameDefinition()); settings.InitialNumberOfPieces = 0; GameMaster defaultGameMaster = new GameMaster(new GameMasterSettingsConfiguration(GameMasterSettings.GetGameMasterSettings(settings.ToBase()))); //first piece defaultGameMaster.SetPieceInLocation(2, 5, TeamColour.blue, PieceType.sham, 97); defaultGameMaster.UpdateDistancesFromAllPieces(); Assert.IsNotNull((defaultGameMaster.GetBoard.GetField(2, 5) as GameArea.GameObjects.TaskField).Piece); Assert.AreEqual(0, (defaultGameMaster.GetBoard.GetField(2, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(1, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(3, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(2, 4) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(2, 6) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(3, (defaultGameMaster.GetBoard.GetField(4, 6) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(4, (defaultGameMaster.GetBoard.GetField(4, 3) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(2, (defaultGameMaster.GetBoard.GetField(0, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); //second piece defaultGameMaster.SetPieceInLocation(4, 5, TeamColour.blue, PieceType.sham, 98); defaultGameMaster.UpdateDistancesFromAllPieces(); Assert.IsNotNull((defaultGameMaster.GetBoard.GetField(2, 5) as GameArea.GameObjects.TaskField).Piece); Assert.IsNotNull((defaultGameMaster.GetBoard.GetField(4, 5) as GameArea.GameObjects.TaskField).Piece); Assert.AreEqual(0, (defaultGameMaster.GetBoard.GetField(2, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(0, (defaultGameMaster.GetBoard.GetField(4, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(3, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(4, 6) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(2, (defaultGameMaster.GetBoard.GetField(4, 3) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(2, (defaultGameMaster.GetBoard.GetField(0, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); //third piece defaultGameMaster.SetPieceInLocation(1, 8, TeamColour.blue, PieceType.sham, 99); Assert.IsNotNull((defaultGameMaster.GetBoard.GetField(2, 5) as GameArea.GameObjects.TaskField).Piece); Assert.IsNotNull((defaultGameMaster.GetBoard.GetField(4, 5) as GameArea.GameObjects.TaskField).Piece); Assert.IsNotNull((defaultGameMaster.GetBoard.GetField(1, 8) as GameArea.GameObjects.TaskField).Piece); Assert.AreEqual(0, (defaultGameMaster.GetBoard.GetField(4, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(3, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(4, 6) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(2, (defaultGameMaster.GetBoard.GetField(4, 3) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(2, (defaultGameMaster.GetBoard.GetField(0, 5) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(1, (defaultGameMaster.GetBoard.GetField(1, 7) as GameArea.GameObjects.TaskField).DistanceToPiece); Assert.AreEqual(2, (defaultGameMaster.GetBoard.GetField(3, 8) as GameArea.GameObjects.TaskField).DistanceToPiece); }