Beispiel #1
0
    private void NewTurn(BoardState newState)
    {
        if (newState.currentMove == Team.Black)
        {
            Move move = board.currentGame.GetLastMove();
            if (move.capturedPiece.HasValue)
            {
                agent.AddReward(0.1f);
            }

            if (newState.checkmate != Team.Black)
            {
                Debug.Log("Failed");
                agent.AddReward(-1);
                Reset();
            }
            else
            {
                Debug.Log("Success");
                agent.AddReward(1);
            }
        }
        else if (newState.currentMove == Team.White)
        {
            agent.RequestDecision();
        }
    }
Beispiel #2
0
    private void FixedUpdate()
    {
        if (firstDecision)
        {
            firstDecision = false;
            NewTurn(board.GetCurrentBoardState());
            return;
        }

        nextDecision?.RequestDecision();
    }
Beispiel #3
0
 private void FixedUpdate()
 {
     if (turn == Team.White)
     {
         turn = Team.None;
         agent.RequestDecision();
     }
     else if (turn == Team.Black)
     {
         // Dumb random AI
         turn = Team.None;
         BoardState state = board.GetCurrentBoardState();
         List <(Piece piece, Index target, MoveType moveType)> moves = board.currentGame.GetAllValidMovesForTeam(Team.Black, state);
         (Piece piece, Index target, MoveType moveType)move = moves[UnityEngine.Random.Range(0, moves.Count)];
         IPiece piece = board.activePieces[(Team.Black, move.piece)];
Beispiel #4
0
 private void NewTurn(BoardState newState)
 {
     if (newState.currentMove == Team.Black)
     {
         if (newState.checkmate != Team.Black)
         {
             Debug.Log("Failed");
             agent.AddReward(-1);
             Reset();
         }
         else
         {
             Debug.Log("Success");
             agent.AddReward(1);
         }
     }
     else if (newState.currentMove == Team.White)
     {
         agent.RequestDecision();
     }
 }