public List <Move> AllPosiblePiecePlays(Board board, BoardLogic boardLogic, PieceBase piece, List <Move> AllMoves, double actualValue)
        {
            board = boardLogic.GoTo(board.TurnNumber, board);
            int x = piece.Position.PositionX;
            int y = piece.Position.PositionY;

            foreach (Position position in piece.ValidMoves(board))
            {
                if (boardLogic.FinallyMove(x, y, position.x1, position.y1, board, boardLogic, false))
                {
                    // solo lo guardo si no empeora la situacion (cuanto ams negativo mejor para la pc
                    double Eval = EvaluateBoard(board);

                    if (Eval <= actualValue)
                    {
                        //actualValue = EvaluateBoard(board);
                        AllMoves.Add(new Move {
                            x1 = x, y1 = y, x2 = position.x1, y2 = position.y1
                        });
                    }
                    // back to previous board
                    board = boardLogic.GoTo(board.TurnNumber - 1, board);
                    boardLogic.futureMoves.Clear();
                }
                //}
            }
            return(AllMoves);
        }
示例#2
0
 /// <summary>
 /// true si la pieza en x,y tiene al menos un movimiento válido (es para saber si no es ahogado)
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public bool CanPieceMoveOrDraw(int x, int y, PieceBase piece, Board board)
 {
     foreach (Position position in piece.ValidMoves(board))
     {
         int       i            = position.x1;
         int       j            = position.y1;
         PieceBase pieceRemoved = board.GetPiece(i, j);
         if (LogicMove(x, y, i, j, board)) //va true (osea testea) porque solo quiere saber si se puede mover
         {
             UndoMove(x, y, i, j, pieceRemoved, board);
             return(true);
         }
     }
     return(false);
 }