/// <summary> /// This is the function that is called to get your moves for each turn. /// </summary> /// <param name="igrid">This contains the board information - note that this contains GridSquare information only for squares I can see</param> /// <returns>A Command for this turn - Up, Down, Left or Right for my tank.</returns> public override ICommand GetTurnCommands(IPlayerWorldState igrid) { MyWorldState = (PlayerWorldState)igrid; // the board UpdateMyMap(); // update my map with the new squares seen fsm.Initialize(MyWorldState, MyMap); //WriteTrace("MyWorldState:"); //WriteTrace(MyWorldState); WriteTrace("\r\nMyMap:"); WriteTrace(MyMapToString()); fsm.DoState(); WriteTrace("\r\nMyPath:"); WriteTrace(fsm.aStar.SearchToString(fsm.aStar.MyPath)); if (fsm.GetCommand() != null) { WriteTrace(fsm.GetCommand().ToString()); } else { WriteTrace("null Command"); } return(fsm.GetCommand()); }
/// <summary> /// Return the commands for this turn /// </summary> public override ICommand GetTurnCommands(IPlayerWorldState igrid) { myWorldState = (PlayerWorldState)igrid; // initialise my own copy of Board TheBoard = new Board(myWorldState); // reset the counter of boards evaluated BoardsEvaluated = 0; // No BestMove known yet - BestMove == null corresponds to passing the turn BestMove = new Move(); // Search for the best move double alpha = GetGameResultDepthLimitedAlphaBeta(this.ID, 0, -1000.0, 1000.0); // Display the best move so far for debugging purposes if (BestMove.TheCommand == null) { WriteTrace("Best Move - PASS - after " + BoardsEvaluated + " boards"); } else { WriteTrace("Best Move - " + BestMove + " - after " + BoardsEvaluated + " boards"); } // return the move return(BestMove.TheCommand); }
public override ICommand GetTurnCommands(IPlayerWorldState igrid) { myWorldState = (PlayerWorldState)igrid; Debug.WriteLine(myWorldState); return(null); // Return the command “Do nothing at all!” }
public override ICommand GetTurnCommands(IPlayerWorldState igrid) { MyWorldState = (PlayerWorldState)igrid; UpdateMyMap(); // update my "map" of squares seen to date // Write all of the properties of this player which are inherited from BasePlayer to the Trace Window WriteTrace("this.AITimePerGame: " + this.AITimePerGame); WriteTrace("this.AITimePerTurn: " + this.AITimePerTurn); WriteTrace("this.CPUTimeUsedSeconds: " + this.CPUTimeUsedSeconds); WriteTrace("this.ID: " + this.ID); WriteTrace("this.MaxNumOverTimeAITurns: " + this.MaxNumOverTimeAITurns); WriteTrace("this.MaxNumTurns: " + this.MaxNumTurns); WriteTrace("this.Name: " + this.Name); WriteTrace("this: " + this); // Write all of the properties of this player's PlayerWorldState to the Trace Window WriteTrace("MyWorldState.CanSee(PlayerWorldState.Facing.Up,5,0,7,4,mygrid): " + MyWorldState.CanSee(PlayerWorldState.Facing.Up, 5, 0, 7, 4, MyMap)); WriteTrace("MyWorldState.EmptySquaresSeen: " + MyWorldState.EmptySquaresSeen); WriteTrace("MyWorldState.GridHeightInSquares: " + MyWorldState.GridHeightInSquares); WriteTrace("MyWorldState.GridWidthInSquares: " + MyWorldState.GridWidthInSquares); WriteTrace("MyWorldState.ID: " + MyWorldState.ID); WriteTrace("MyWorldState.Kills: " + MyWorldState.Kills); WriteTrace("MyWorldState.MaximumVisionDistance: " + MyWorldState.MaximumVisionDistance); WriteTrace("MyWorldState.MyFacing: " + MyWorldState.MyFacing); WriteTrace("MyWorldState.MyGridSquare: " + MyWorldState.MyGridSquare); WriteTrace("MyWorldState.MyVisibleSquares: "); foreach (GridSquare gs in MyWorldState.MyVisibleSquares) { WriteTrace(gs); } WriteTrace("MyWorldState.PlayerCount: " + MyWorldState.PlayerCount); WriteTrace("MyWorldState.RockSquaresSeen: " + MyWorldState.RockSquaresSeen); WriteTrace("MyWorldState.Score: " + MyWorldState.Score); WriteTrace("MyWorldState.ScorePerEmptySquareSeen: " + MyWorldState.ScorePerEmptySquareSeen); WriteTrace("MyWorldState.ScorePerOpposingTankDestroyed: " + MyWorldState.ScorePerOpposingTankDestroyed); WriteTrace("MyWorldState.ScorePerRockSquareSeen: " + MyWorldState.ScorePerRockSquareSeen); WriteTrace("MyWorldState.ShotsFired: " + MyWorldState.ShotsFired); WriteTrace("MyWorldState: " + MyWorldState); WriteTrace("MyWorldState.TurnNumber: " + MyWorldState.TurnNumber); WriteTrace("My Map:"); WriteTrace(MyMapToString()); // the command Command c = new Command(Command.Move.Up, true); // move up and shoot return(c); }
public override ICommand GetTurnCommands(IPlayerWorldState igrid) { //the Board WorldState = (PlayerWorldState)igrid; // Search for the best move Negamax NM = new Negamax(-1000.0, 1000.0, MaxDepth); // Make a working copy of the board, with me about to move GameBoard = new GameBoard(WorldState); // No BestMove known yet - BestMove == null corresponds to passing the turn BestMove = null; double alpha = NM.NegaMaxSearchFunction(GameBoard, 0, -1000.0, 1000.0, WorldState); BestMove = NM.NegaBest; return(BestMove.Com); }
public override ICommand GetTurnCommands(IPlayerWorldState igrid) { myWorldState = (PlayerWorldState)igrid; // bot can only move, but not shoot // 0 - Up, 1-Down, 2- Left, 3-Right, 4-RotateLeft, 5-RotateRight, 6-Stay Random rand = new Random(); int direction = rand.Next(7); for (int i = 0; i < myWorldState.MyVisibleSquares.Count; i++) { WriteTrace(myWorldState.MyVisibleSquares[i] + " "); } //WriteTrace("ScoreEmptySquare " + myWorldState.ScorePerEmptySquareSeen); //WriteTrace("ScoreTankDestroyed " + myWorldState.ScorePerOpposingTankDestroyed); //WriteTrace("ScoreRockSquare " + myWorldState.ScorePerRockSquareSeen); switch (direction) { case 0: return(new Command(Command.Move.Up, false)); case 1: return(new Command(Command.Move.Down, false)); case 2: return(new Command(Command.Move.Left, false)); case 3: return(new Command(Command.Move.Right, false)); case 4: return(new Command(Command.Move.RotateLeft, false)); case 5: return(new Command(Command.Move.RotateRight, false)); case 6: return(new Command(Command.Move.Stay, false)); } return(null); }