private GameMasterClient newGameMaster(GameMaster.Net.Game game) { var settings = new GameMasterSettings(); settings.ActionCosts = new GameMasterSettingsActionCosts() { DiscoverDelay = 0, KnowledgeExchangeDelay = 0, MoveDelay = 0, PickUpDelay = 0, PlacingDelay = 0, TestDelay = 0 }; settings.GameDefinition = new GameMasterSettingsGameDefinition() { BoardWidth = "3", PlacingNewPiecesFrequency = uint.MaxValue, GoalAreaLength = "2", TaskAreaLength = "5", NumberOfPlayersPerTeam = "2" }; settings.GameDefinition.Goals = new Common.Config.GoalField[] { new Common.Config.GoalField() { x = 0, y = 0 } }; return(new GameMasterClient(new ConnectionMock(), settings, new MockLogger(), game, new Ranking())); }
public static GameMasterSettingsConfiguration LoadSettingsFromFile(string path) { GameMasterSettings settings = null; //try { using (StreamReader reader = new StreamReader(path)) { var xmlReader = XmlReader.Create(reader); var serializer = new XmlSerializer(typeof(GameMasterSettings)); if (serializer.CanDeserialize(xmlReader)) { settings = (GameMasterSettings)serializer.Deserialize(xmlReader); var errors = Validator.ValidateSettings(new GameMasterSettingsConfiguration(settings)); if (!string.IsNullOrEmpty(errors)) { ConsoleWriter.Error(Constants.ERRORS_WHILE_PARSING_XML); ConsoleWriter.Show(errors); return(null); } } } } //catch(Exception e) //{ // ConsoleWriter.Error(Constants.UNEXPECTED_ERROR + e.Message); // ConsoleWriter.Show(e.StackTrace); //} return(new GameMasterSettingsConfiguration(settings)); }
public void InitGameMaster() { defaultSettings = new GameMasterSettingsConfiguration(GameMasterSettings.GetDefaultGameMasterSettings()); defaultGameMaster = new GameArea.GameMaster(defaultSettings); defaultGameMaster.InitBoard(defaultGameMaster.Settings.GameDefinition); }
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); }
public void InitGameMaster() { settings = new GameMasterSettingsConfiguration(GameMasterSettings.GetDefaultGameMasterSettings()); gameMaster = new GameArea.GameMaster(settings); }
public GameMasterSettingsGM(GameMasterSettings gameMasterSettings = null) : base(gameMasterSettings) { }