Esempio n. 1
0
        private int evaluateTable(Table table)
        {
            int nValue = 0;

            for (int nRow = 0; nRow < table.TableSize; ++nRow)
            {
                for (int nCol = 0; nCol < table.TableSize; ++nCol)
                {
                    Piece piece = table.getTableSquare(nCol, nRow).Piece;
                    if (piece == null)
                        continue;

                    if (m_bBlack != piece.isBlack)
                    {
                        if (piece is Queen)
                        {
                            nValue += 50;
                        }
                        else if (piece is Bishop)
                        {
                            nValue += 25;
                        }
                        else if (piece is Rook)
                        {
                            nValue += 20;
                        }
                        else if (piece is Knight)
                        {
                            nValue += 10;
                        }
                        else if (piece is Pawn)
                        {
                            nValue += 5;
                        }
                    }
                    else
                    {
                        if (piece is Queen)
                        {
                            nValue += 30;
                        }
                        else if (piece is Bishop)
                        {
                            nValue += 15;
                        }
                        else if (piece is Rook)
                        {
                            nValue += 10;
                        }
                        else if (piece is Knight)
                        {
                            nValue += 5;
                        }
                        else if (piece is Pawn)
                        {
                            nValue += 2;
                        }
                    }
                }
            }

            return nValue;
        }
Esempio n. 2
0
        private List<Table> generateTables(Table table)
        {
            List<Table> lstTables = new List<Table>();

            for (int nRow = 0; nRow < table.TableSize; ++nRow)
            {
                for (int nCol = 0; nCol < table.TableSize; ++nCol)
                {
                    Table.TableSquare tableSquare = table.getTableSquare(nRow, nCol);

                    // Verify if the is a piece in this square.
                    if (tableSquare.Piece == null)
                        continue;

                    // Verify if the piece is mine.
                    if (tableSquare.Piece.isBlack != m_bTeamTemp)
                        continue;

                    List<Point> lstPositions = tableSquare.Piece.vetPossibleMovements;
                    foreach (Point position in lstPositions)
                    {
                        Play play = new Play();
                        play.oldPosition = new Point(nRow, nCol);
                        play.newPosition = position;
                        Table newTable = table + play;
                        lstTables.Add(newTable);
                    }
                }
            }

            return lstTables;
        }