Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 53.51 KB | None | 0 0
  1. /*
  2.  * Author: KV from ITSE 2421 course (Final Project)
  3.  * Description:
  4.  * This program is an implementation of the board game Chess. It supports a
  5.  * human vs. human mode and a human vs. computer mode.
  6.  */
  7.  
  8.  
  9. import java.util.*;
  10.  
  11. public class P4ChessBL
  12. {
  13.     //----------------------------------------------------------------------------------------
  14.     //  Copyright © 2006 - 2015 Tangible Software Solutions Inc.
  15.     //  This class can be used by anyone provided that the copyright notice remains intact.
  16.     //
  17.     //  This class provides the ability to initialize array elements with the default
  18.     //  constructions for the array type.
  19.     //----------------------------------------------------------------------------------------
  20.     public final class Arrays
  21.     {
  22.         public static ClassicMap[] initializeWithDefaultClassicMapInstances(int length)
  23.         {
  24.             ClassicMap[] array = new ClassicMap[length];
  25.             for (int i = 0; i < length; i++)
  26.             {
  27.                 array[i] = new ClassicMap();
  28.             }
  29.             return array;
  30.         }
  31.  
  32.         public static std_pair[] initializeWithDefaultpairInstances(int length)
  33.         {
  34.             std_pair[] array = new std_pair[length];
  35.             for (int i = 0; i < length; i++)
  36.             {
  37.                 array[i] = new std_pair();
  38.             }
  39.             return array;
  40.         }
  41.     }
  42.    
  43.    
  44.     //----------------------------------------------------------------------------------------
  45.     //  Copyright © 2006 - 2015 Tangible Software Solutions Inc.
  46.     //  This class can be used by anyone provided that the copyright notice remains intact.
  47.     //
  48.     //  This class provides the ability to simulate the behavior of the C/C++ functions for
  49.     //  generating random numbers.
  50.     //  'rand' converts to the parameterless overload of NextNumber
  51.     //  'random' converts to the single-parameter overload of NextNumber
  52.     //  'randomize' converts to the parameterless overload of Seed
  53.     //  'srand' converts to the single-parameter overload of Seed
  54.     //----------------------------------------------------------------------------------------
  55.     public final class RandomNumbers
  56.     {
  57.         private static Random r;
  58.  
  59.         public static int nextNumber()
  60.         {
  61.             if (r == null)
  62.                 Seed();
  63.  
  64.             return r.nextInt();
  65.         }
  66.  
  67.         public static int nextNumber(int ceiling)
  68.         {
  69.             if (r == null)
  70.                 Seed();
  71.  
  72.             return r.nextInt(ceiling);
  73.         }
  74.  
  75.         public static void seed()
  76.         {
  77.             r = new Random();
  78.         }
  79.  
  80.         public static void seed(int seed)
  81.         {
  82.             r = new Random(seed);
  83.         }
  84.     }
  85.  
  86. /* These const values are used for identifying whether the "piece" occupying
  87.  * a chess board space is black, white, or in the case of a blank spot,
  88.  * "clear."
  89.  */
  90.  
  91.     public static final int BLACK = 0;
  92.     public static final int WHITE = 1;
  93.     public static final int CLEAR = 2;
  94.     public static final int CHECK_MOVE = 1; // this is a piece move "mode" designating an AI board evaluation
  95.     public static final int REAL_MOVE = 2; // this is a piece move "mode" designating an actual AI move
  96.  
  97.  
  98.  
  99.     public class Coord
  100.     {
  101.       public int m_X;
  102.       public int m_Y;
  103.     }
  104.  
  105.  /* This is the class to handle the layout of the chess board.
  106.  */
  107.  
  108.     public class ChessBoard
  109.     {
  110.  
  111.       /* The ctor fills the chess board grid with a proper starting setup.
  112.        */
  113.  
  114.       public ChessBoard()
  115.       {
  116.           this.m_capturelessMoves = 0;
  117.         m_lastMoves[P4ChessBL.BLACK].first = 8; // beginning "last move" of the black piece as "nothing"
  118.         m_lastMoves[P4ChessBL.BLACK].second = 8; // ^-- in this case, not a valid move at all
  119.         m_lastMoves[P4ChessBL.WHITE].first = 8; // similarly, we set the white pieces' last move.
  120.         m_lastMoves[P4ChessBL.WHITE].second = 8;
  121.         m_lastMoveRepeats[P4ChessBL.BLACK] = 0; // here we note that there has been no repetition of moves yet
  122.         m_lastMoveRepeats[P4ChessBL.WHITE] = 0; // ^-- for either black or white pieces.
  123.         m_locations = new ChessPiece[8][];
  124.         for (int i = 0; i < 8; ++i) // this loop creates a chess board grid for holding piece objects
  125.         {
  126.           m_locations[i] = new ChessPiece[8];
  127.         }
  128.         ChessPiece piece;
  129.         piece = new ChessPiece(CPiece.Type.ROOK, P4ChessBL.BLACK); // following lines set up some pieces on the board for black
  130.         m_locations[0][0] = piece;
  131.         piece = new ChessPiece(CPiece.Type.ROOK, P4ChessBL.BLACK);
  132.         m_locations[7][0] = piece;
  133.         piece = new ChessPiece(CPiece.Type.KNIGHT, P4ChessBL.BLACK);
  134.         m_locations[1][0] = piece;
  135.         piece = new ChessPiece(CPiece.Type.KNIGHT, P4ChessBL.BLACK);
  136.         m_locations[6][0] = piece;
  137.         piece = new ChessPiece(CPiece.Type.BISHOP, P4ChessBL.BLACK);
  138.         m_locations[2][0] = piece;
  139.         piece = new ChessPiece(CPiece.Type.BISHOP, P4ChessBL.BLACK);
  140.         m_locations[5][0] = piece;
  141.         piece = new ChessPiece(CPiece.Type.QUEEN, P4ChessBL.BLACK);
  142.         m_locations[3][0] = piece;
  143.         piece = new ChessPiece(CPiece.Type.KING, P4ChessBL.BLACK);
  144.         m_locations[4][0] = piece;
  145.         for (int i = 0; i < 8; ++i) // this loop creates black pawn pieces to setup the board
  146.         {
  147.           piece = new ChessPiece(CPiece.Type.PAWN, P4ChessBL.BLACK);
  148.           m_locations[i][1] = piece;
  149.         }
  150.         piece = new ChessPiece(CPiece.Type.ROOK, P4ChessBL.WHITE); // setting up the white king's row here
  151.         m_locations[0][7] = piece;
  152.         piece = new ChessPiece(CPiece.Type.ROOK, P4ChessBL.WHITE);
  153.         m_locations[7][7] = piece;
  154.         piece = new ChessPiece(CPiece.Type.KNIGHT, P4ChessBL.WHITE);
  155.         m_locations[1][7] = piece;
  156.         piece = new ChessPiece(CPiece.Type.KNIGHT, P4ChessBL.WHITE);
  157.         m_locations[6][7] = piece;
  158.         piece = new ChessPiece(CPiece.Type.BISHOP, P4ChessBL.WHITE);
  159.         m_locations[2][7] = piece;
  160.         piece = new ChessPiece(CPiece.Type.BISHOP, P4ChessBL.WHITE);
  161.         m_locations[5][7] = piece;
  162.         piece = new ChessPiece(CPiece.Type.QUEEN, P4ChessBL.WHITE);
  163.         m_locations[3][7] = piece;
  164.         piece = new ChessPiece(CPiece.Type.KING, P4ChessBL.WHITE);
  165.         m_locations[4][7] = piece;
  166.         for (int i = 0; i < 8; ++i) // and now we place white pawns
  167.         {
  168.           piece = new ChessPiece(CPiece.Type.PAWN, P4ChessBL.WHITE);
  169.           m_locations[i][6] = piece;
  170.         }
  171.         for (int i = 0; i < 8; ++i) // the rest of the board is represented by "blank" pieces of "clear" color
  172.         {
  173.           for (int j = 2; j < 6; ++j)
  174.           {
  175.             piece = new ChessPiece(CPiece.Type.BLANK, P4ChessBL.CLEAR);
  176.             m_locations[i][j] = piece;
  177.           }
  178.         }
  179.         for (int i = 0; i < 2; ++i) // we set up our piece map that records which pieces a player has left
  180.         {
  181.           m_pieceMaps[i].put(CPiece.Type.PAWN.getValue(), 8);
  182.           m_pieceMaps[i].put(CPiece.Type.ROOK.getValue(), 2);
  183.           m_pieceMaps[i].put(CPiece.Type.KNIGHT.getValue(), 2);
  184.           m_pieceMaps[i].put(CPiece.Type.BISHOP.getValue(), 2);
  185.           m_pieceMaps[i].put(CPiece.Type.QUEEN.getValue(), 1);
  186.           m_pieceMaps[i].put(CPiece.Type.KING.getValue(), 1);
  187.         }
  188.       }
  189.  
  190.       /* Copy ctor for the ChessBoard class.
  191.        */
  192.  
  193.       public ChessBoard(ChessBoard src)
  194.       {
  195.         m_locations = new ChessPiece[8][];
  196.         for (int i = 0; i < 8; ++i)
  197.         {
  198.           m_locations[i] = new ChessPiece[8];
  199.         }
  200.         copy(src);
  201.       }
  202.  
  203.       /* The ChessBoard class dtor frees memory allocated for the board grid.
  204.        */
  205.  
  206.       public void dispose()
  207.       {
  208.         for (int i = 0; i < 8; ++i)
  209.         {
  210.           for (int j = 0; j < 8; ++j)
  211.           {
  212.             if (m_locations[i][j] != null)
  213.                 m_locations[i][j].dispose();
  214.           }
  215.           m_locations[i] = null;
  216.         }
  217.         m_locations = null;
  218.       }
  219.  
  220.       /* Overloaded operator= for the ChessBoard class.
  221.        */
  222.  
  223.       public final ChessBoard copyFrom(ChessBoard rhs)
  224.       {
  225.         if (this == rhs)
  226.         {
  227.           return this;
  228.         }
  229.         copy(rhs);
  230.         return this;
  231.       }
  232.  
  233.       /* This member function is used to display the board to the screen with the
  234.        * current chess piece locations. Extended ASCII is used to draw the lines of
  235.        * the board grid itself.
  236.        */
  237.  
  238.       public final void display()
  239.       {
  240.         byte c;
  241.         byte cc;
  242.         boolean rightWhite;
  243.         System.out.print('\n');
  244.         System.out.print(32);
  245.         for (int i = 0; i < 8; ++i)
  246.         {
  247.           System.out.print(32);
  248.           System.out.print(32);
  249.           System.out.print(97 + i);
  250.           System.out.print(32);
  251.         }
  252.         System.out.print('\n');
  253.         System.out.print(32);
  254.         System.out.print(218);
  255.         for (int i = 0; i < 8; ++i)
  256.         {
  257.           System.out.print(196);
  258.           System.out.print(196);
  259.           System.out.print(196);
  260.           if (i < 7)
  261.           {
  262.             System.out.print(194);
  263.           }
  264.           else
  265.           {
  266.             System.out.print(191);
  267.           }
  268.         }
  269.         System.out.print('\n');
  270.         cc = (byte)'8';
  271.         rightWhite = false;
  272.         for (int i = 0; i < 8; ++i)
  273.         {
  274.           System.out.print(cc--);
  275.           System.out.print(179);
  276.           for (int j = 0; j < 8; ++j)
  277.           {
  278.             if (!rightWhite && (((j + i % 2) % 2) != 0))
  279.             {
  280.               System.out.print(32);
  281.             }
  282.             else
  283.             {
  284.             if (!rightWhite && (((j + i % 2) % 2) != 0))
  285.             {
  286.               System.out.print(32);
  287.             }
  288.             else
  289.             {
  290.             if (m_locations[j][i].getType() != CPiece.Type.BLANK)
  291.             {
  292.               System.out.print(221);
  293.             }
  294.             else
  295.             {
  296.               System.out.print(219);
  297.             }
  298.             }
  299.             }
  300.             switch (m_locations[j][i].getType().toString)
  301.             {
  302.               case "PAWN":
  303.                 c = (byte)'p';
  304.                 break;
  305.               case "ROOK":
  306.                 c = (byte)'r';
  307.                 break;
  308.               case "KNIGHT":
  309.                 c = (byte)'n';
  310.                 break;
  311.               case "BISHOP":
  312.                 c = (byte)'b';
  313.                 break;
  314.               case "QUEEN":
  315.                 c = (byte)'q';
  316.                 break;
  317.               case "KING":
  318.                 c = (byte)'k';
  319.                 break;
  320.               default:
  321.                 if ((rightWhite) && (((j + i % 2) % 2) != 0 ))
  322.                 {
  323.                   c = (byte)32;
  324.                 }
  325.                 else
  326.                 {
  327.                 if (!(rightWhite) && (((j + i % 2) % 2) != 0 ))
  328.                 {
  329.                   c = (byte)32;
  330.                 }
  331.                 else
  332.                 {
  333.                   c = (byte)219;
  334.                 }
  335.                 }
  336.             }
  337.             if (c != (byte)32 && c != (byte)219) // we're drawing the pieces, and this if statement will generate
  338.             {
  339.               c = c - (32 * m_locations[j][i].getColor()); // capital letters for the white ones
  340.             }
  341.             System.out.print(c);
  342.             if (rightWhite && (((j + i % 2) % 2) != 0))
  343.             {
  344.               System.out.print(32);
  345.             }
  346.             else
  347.             {
  348.             if (!rightWhite && (((j + i % 2) % 2) != 0))
  349.             {
  350.               System.out.print(32);
  351.             }
  352.             else
  353.             {
  354.             if (m_locations[j][i].getType() != CPiece.Type.BLANK)
  355.             {
  356.               System.out.print(222);
  357.             }
  358.             else
  359.             {
  360.               System.out.print(219);
  361.             }
  362.             }
  363.             }
  364.             System.out.print(179);
  365.             rightWhite = !rightWhite;
  366.           }
  367.           System.out.print('\n');
  368.           System.out.print(32);
  369.           if (i < 7)
  370.           {
  371.             System.out.print(195);
  372.             for (int j = 0; j < 8; ++j)
  373.             {
  374.               System.out.print(196);
  375.               System.out.print(196);
  376.               System.out.print(196);
  377.               if (j < 7)
  378.               {
  379.                 System.out.print(197);
  380.               }
  381.               else
  382.               {
  383.                 System.out.print(180);
  384.               }
  385.             }
  386.           }
  387.           else
  388.           {
  389.             System.out.print(192);
  390.             for (int j = 0; j < 8; ++j)
  391.             {
  392.               System.out.print(196);
  393.               System.out.print(196);
  394.               System.out.print(196);
  395.               if (j < 7)
  396.               {
  397.                 System.out.print(193);
  398.               }
  399.               else
  400.               {
  401.                 System.out.print(217);
  402.               }
  403.             }
  404.           }
  405.           System.out.print('\n');
  406.         }
  407.       }
  408.  
  409.       /* This function is used to reposition the pieces in a configuration reflecting
  410.        * a board that has been "flipped" or turned around for a perspective from
  411.        * the opposite side of the board. It is mainly used before displaying the
  412.        * board prior to a piece move.
  413.        */
  414.  
  415.       public final void flip()
  416.       {
  417.         ChessPiece piece;
  418.         for (int i = 0; i < 4; ++i)
  419.         {
  420.           for (int j = 0; j < 8; ++j)
  421.           {
  422.             piece = m_locations[j][i];
  423.             m_locations[j][i] = m_locations[7 - j][7 - i];
  424.             m_locations[7 - j][7 - i] = piece;
  425.           }
  426.         }
  427.       }
  428.  
  429.       /* This function returns a pointer to the piece located at the given chess
  430.        * board coordinates.
  431.        */
  432.  
  433.       public final ChessPiece at(int x, int y)
  434.       {
  435.         return m_locations[x][y];
  436.       }
  437.  
  438.       /* This function is used to relocate a piece on the chess board.
  439.        */
  440.  
  441.       public final void move(int bX, int bY, int eX, int eY)
  442.       {
  443.           move(bX, bY, eX, eY, 0);
  444.       }
  445.       public final void move(int bX, int bY, int eX, int eY, int mode)
  446.       { // purposes such as AI, or if this is an actual piece move for play
  447.         if (bX == eX && bY == eY)
  448.           return;
  449.         java.lang.Class tempType = new java.lang.Class();
  450.         if (mode == 0 || mode == P4ChessBL.REAL_MOVE) // if !mode or REAL_MOVE, we're moving pieces, we will determine if a player
  451.         { // has just lost a piece from their arsenal
  452.           tempType = m_locations[eX][eY].getType();
  453.           if (tempType != CPiece.Type.BLANK)
  454.           {
  455.             m_capturelessMoves = 0; // here we're accounting for a capture made, so the count for 50 capturless
  456.             --m_pieceMaps[m_locations[eX][eY].getColor()].get(tempType); // moves starts over (we're far from be able to call a DRAW here)
  457.             if (m_pieceMaps[m_locations[eX][eY].getColor()].get(tempType) == 0)
  458.             {
  459.               m_pieceMaps[m_locations[eX][eY].getColor()].remove(tempType);
  460.             }
  461.           }
  462.           if (at(bX, bY).getType() != CPiece.Type.PAWN) // if that piece just moved wasn't a pawn, we increment the move count since
  463.           {
  464.             ++m_capturelessMoves; // no capture was made on this move
  465.           }
  466.           else
  467.           {
  468.             m_capturelessMoves = 0; // yet, here is WAS a pawn... pawns reset the counter
  469.           }
  470.         }
  471.         ChessPiece piece;
  472.         piece = new ChessPiece(CPiece.Type.BLANK, P4ChessBL.CLEAR); // we create a blank space to leave behind when we move this piece
  473.         if (m_locations[eX][eY] != null)
  474.             m_locations[eX][eY].dispose(); // erase the piece object at the target move location
  475.         m_locations[eX][eY] = m_locations[bX][bY]; // replace the target piece location with the piece what was moved
  476.         m_locations[bX][bY] = piece; // the old position is replaced with out blank/clear piece object
  477.         m_locations[eX][eY].incrementMoves(); // we increment the number of times this piece has been moved now
  478.         if (at(eX, eY).getType() == CPiece.Type.PAWN && eX != bX && (mode == 0 || mode == P4ChessBL.REAL_MOVE)) // here we check if this move is an en Passant capture. if it is, we need
  479.         {
  480.           if (7 - m_lastMoveX == eX && 7 - m_lastMoveY == eY + 1) // ^-- to handle how the pieces are arranged on the board in a special manner
  481.           {
  482.             piece = new ChessPiece(CPiece.Type.BLANK, P4ChessBL.CLEAR);
  483.             if (m_locations[7 - m_lastMoveX][7 - m_lastMoveY] != null)
  484.                 m_locations[7 - m_lastMoveX][7 - m_lastMoveY].dispose();
  485.             m_locations[7 - m_lastMoveX][7 - m_lastMoveY] = piece;
  486.             System.out.print("\nEn passant capture.");
  487.             System.out.print("\n");
  488.           }
  489.         }
  490.         if (eY == 0 && at(eX, eY).getType() == CPiece.Type.PAWN && mode == 0) // did a pawn make it all the way to the enemie's king's row?
  491.         { // ^-- if so, this is a PAWN PROMOTION
  492.           String choice;
  493.           byte c;
  494.           c = (byte)0;
  495.           do
  496.           {
  497.             System.out.print("\nPawn promotion!\nChoose Q)ueen, R)ook, B)ishop, or N) " + "Knight: ");
  498.             choice = new Scanner(System.in).nextLine();
  499.             if (choice.length() != 0)
  500.             {
  501.               c = Character.toUpperCase(choice.charAt(0));
  502.             }
  503.           } while (c != 'Q' && c != 'R' && c != 'B' && c != 'N');
  504.           switch (c) // this switch will create a promotion piece to replace the pawn with
  505.           {
  506.             case 'N':
  507.               piece = new ChessPiece(CPiece.Type.KNIGHT, at(eX, eY).getColor());
  508.               break;
  509.             case 'B':
  510.               piece = new ChessPiece(CPiece.Type.BISHOP, at(eX, eY).getColor());
  511.               break;
  512.             case 'R':
  513.               piece = new ChessPiece(CPiece.Type.ROOK, at(eX, eY).getColor());
  514.               break;
  515.             default:
  516.               piece = new ChessPiece(CPiece.Type.QUEEN, at(eX, eY).getColor());
  517.           }
  518.           if (m_locations[eX][eY] != null)
  519.               m_locations[eX][eY].dispose(); // we need to get rid of that promoted pawn
  520.           m_locations[eX][eY] = piece; // we need to replace it with the promotion piece
  521.           if (mode == 0) // if this is a real move, then we need to update the player's pieces arsenal
  522.           {
  523.             --m_pieceMaps[piece.getColor()].get(CPiece.Type.PAWN.getValue());
  524.             if (m_pieceMaps[piece.getColor()].get(CPiece.Type.PAWN.getValue()) == 0)
  525.             {
  526.               m_pieceMaps[piece.getColor()].remove(CPiece.Type.PAWN);
  527.             }
  528.             java.util.Iterator<java.lang.Class, int> it;
  529.             it.copyFrom(m_pieceMaps[piece.getColor()].find(piece.getType()));
  530.             if (it != m_pieceMaps[piece.getColor()].end())
  531.             {
  532.               ++it.second;
  533.             }
  534.             else
  535.             {
  536.               m_pieceMaps[piece.getColor()].put(piece.getType(), 1);
  537.             }
  538.           }
  539.         }
  540.         else
  541.         {
  542.         if (eY == 0 && at(eX, eY).getType() == CPiece.Type.PAWN && mode == P4ChessBL.REAL_MOVE) // this is a special mode, handling pawn promotion for the computer
  543.         { // the computer always chooses a QUEEN for its new piece
  544.           System.out.print("\nPawn promotion!\nComputer chooses a Queen.");
  545.           System.out.print("\n");
  546.           piece = new ChessPiece(CPiece.Type.QUEEN, at(eX, eY).getColor());
  547.           if (m_locations[eX][eY] != null)
  548.               m_locations[eX][eY].dispose();
  549.           m_locations[eX][eY] = piece;
  550.           if (mode == 0)
  551.           {
  552.             --m_pieceMaps[piece.getColor()].get(CPiece.Type.PAWN.getValue());
  553.               if (m_pieceMaps[piece.getColor()].get(CPiece.Type.PAWN.getValue()) == 0)
  554.               {
  555.                 m_pieceMaps[piece.getColor()].remove(CPiece.Type.PAWN);
  556.               }
  557.             java.util.Iterator<java.lang.Class, int> it;
  558.             it.copyFrom(m_pieceMaps[piece.getColor()].find(CPiece.Type.QUEEN));
  559.             if (it != m_pieceMaps[piece.getColor()].end())
  560.             {
  561.               ++it.second;
  562.             }
  563.             else
  564.             {
  565.               m_pieceMaps[piece.getColor()].put(CPiece.Type.QUEEN.getValue(), 1);
  566.             }
  567.           }
  568.         }
  569.         }
  570.         if (mode == 0 || mode == P4ChessBL.REAL_MOVE) // here we are tracking the last moves made to see if there is a
  571.         { // ^-- three-fold repetition in moves.
  572.           m_lastMoveX = eX;
  573.           m_lastMoveY = eY;
  574.           if (m_lastMoves[at(eX, eY).getColor()].first == bX && m_lastMoves[at(eX, eY).getColor()].second == bY)
  575.           {
  576.             ++m_lastMoveRepeats[at(eX, eY).getColor()]; // back-and-forth piece movements will inrement the repeated moves counter
  577.             m_lastMoves[at(eX, eY).getColor()].first = eX;
  578.             m_lastMoves[at(eX, eY).getColor()].second = eY;
  579.           }
  580.           else
  581.           {
  582.             m_lastMoves[at(eX, eY).getColor()].first = eX;
  583.             m_lastMoves[at(eX, eY).getColor()].second = eY;
  584.             m_lastMoveRepeats[at(eX, eY).getColor()] = 1;
  585.           }
  586.         }
  587.       }
  588.  
  589.       /* This function checks to see if the last move made was to X,Y passed in,
  590.        * from the perspective of a flipped board, it is used for AI processing.
  591.        */
  592.  
  593.       public final boolean lastMoveWas(int X, int Y)
  594.       {
  595.         return (7 - m_lastMoveX == X && 7 - m_lastMoveY == Y);
  596.       }
  597.  
  598.       /* This function replaces a piece object on the board with a new one supplied
  599.        */
  600.  
  601.       public final void replace(ChessPiece piece, int X, int Y)
  602.       {
  603.         if (m_locations[X][Y] != null)
  604.             m_locations[X][Y].dispose();
  605.         m_locations[X][Y] = piece;
  606.       }
  607.  
  608.       /* This boolean function returns true if there is an option to call DRAW
  609.        */
  610.  
  611.       public final boolean isPotentialDraw(int turn)
  612.       {
  613.         return m_capturelessMoves >= 50 || (m_lastMoveRepeats[turn] > 2 && m_lastMoveRepeats[(turn + 1) % 2] > 3);
  614.       }
  615.     //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found:
  616.     //  boolean callDraw(ushort NamelessParameter);
  617.  
  618.       /* If en Passant is a valid move, this is going to reset the 3-fold move c
  619.        * counter because the board presents slightly different options than when
  620.        * pieces are otherwise simply moved back and forth repeatedly
  621.        */
  622.  
  623.       public final boolean enPassantOption(int color)
  624.       {
  625.         m_lastMoveRepeats[(color + 1) % 2] = 1;
  626.         return true;
  627.       }
  628.  
  629.       /* This function returns true if there are not enough pieces left on the board
  630.        * to accomplish a check mate.  It is used to determine if the game is a draw
  631.        */
  632.  
  633.       public final boolean isInsufficientPieces(ChessBoard board)
  634.       {
  635.         if ((board.m_pieceMaps[P4ChessBL.BLACK].size() == 2 && board.m_pieceMaps[P4ChessBL.WHITE].size() == 2) && board.m_pieceMaps[P4ChessBL.BLACK].containsKey(CPiece.Type.BISHOP) && board.m_pieceMaps[P4ChessBL.WHITE].containsKey(CPiece.Type.BISHOP) && P4ChessBL.sameSquareColorBishops(board))
  636.         {
  637.           return true;
  638.         }
  639.         if (board.m_pieceMaps[P4ChessBL.BLACK].size() + board.m_pieceMaps[P4ChessBL.WHITE].size() > 3)
  640.         {
  641.           return false;
  642.         }
  643.         boolean[] insufficient = new boolean[2];
  644.         insufficient[P4ChessBL.BLACK] = false;
  645.         insufficient[P4ChessBL.WHITE] = false;
  646.         for (int i = 0; i < 2; ++i)
  647.         {
  648.           if (board.m_pieceMaps[i].size() == 1)
  649.           {
  650.             insufficient[i] = true;
  651.             continue;
  652.           }
  653.           if (board.m_pieceMaps[i].containsKey(CPiece.Type.KNIGHT).getValue() != 0)
  654.           {
  655.             insufficient[i] = true;
  656.             continue;
  657.           }
  658.           if (board.m_pieceMaps[i].containsKey(CPiece.Type.BISHOP).getValue() != 0)
  659.           {
  660.             insufficient[i] = true;
  661.             continue;
  662.           }
  663.         }
  664.         return insufficient[P4ChessBL.BLACK] && insufficient[P4ChessBL.WHITE];
  665.       }
  666.      
  667.     public boolean callDraw(int turn)
  668.     {
  669.       if (isPotentialDraw(turn))
  670.       {
  671.         System.out.print((turn == BLACK != false ? "Black " : "White "));
  672.         if (m_capturelessMoves >= 50)
  673.         {
  674.           System.out.print("calls draw based on 50 move rule: No captures made or " + "pawns moved.");
  675.           System.out.print("\n");
  676.           return true;
  677.         }
  678.         System.out.print("calls draw based on threefold repetition of moves.");
  679.         System.out.print("\n");
  680.         return true;
  681.       }
  682.       return false;
  683.     }
  684.  
  685.       /* This copy function is used by both the ChessBoard copy ctor and operator=
  686.        * for creating a board copy.
  687.        */
  688.  
  689.       private void copy(ChessBoard src)
  690.       {
  691.         for (int i = 0; i < 8; ++i)
  692.         {
  693.           for (int j = 0; j < 8; ++j)
  694.           {
  695.             m_locations[i][j] = new ChessPiece(src.m_locations[i][j]);
  696.           }
  697.         }
  698.       }
  699.       private ChessPiece[][] m_locations; // this will be an array to represent a chess board grid
  700.       private java.util.TreeMap<java.lang.Class, int>[] m_pieceMaps = P4ChessBL.Arrays.initializeWithDefaultClassicMapInstances(2); // this map tracks number of pieces left in a player's arsenal
  701.       private Arrays.std_pair<int, int>[] m_lastMoves = P4ChessBL.Arrays.initializeWithDefaultpairInstances(2); // this pair is used in determining if there is a repetition of moves
  702.       private int[] m_lastMoveRepeats = new int[2]; // this counts the number of times the same moves have been repeated
  703.       private int m_lastMoveX; // this is the last move made, used for checking if en Passant is valid
  704.       private int m_lastMoveY; // this is the 'Y' coordinate of the last move (see above)
  705.       private int m_capturelessMoves; // this variable counts moves where no pawns are moved or captures made
  706.     } // ^-- it will be used to determine if the game can be called a draw
  707.     /* If a player calls draw, here we handle the output for the specific game
  708.      * draw conditions that were met.
  709.      */
  710.  
  711. /* This is the chess piece class to represent the occupation of a space on the
  712.  * chess board.
  713.  */
  714.      
  715.     public class ChessBoard
  716.     {
  717.  
  718.     }
  719.  
  720.     public class ChessPiece
  721.     {
  722.  
  723.  
  724.         /* The ctor for ChessPiece takes a piece type and color.
  725.         */
  726.  
  727.       public ChessPiece(java.lang.Class type, int color)
  728.       {
  729.           this.m_type = type;
  730.           this.m_color = color;
  731.           this.m_moves = 0;
  732.       }
  733.       public void dispose()
  734.       {
  735.       }
  736.  
  737.         /* This member function returns the chess piece type.
  738.         */
  739.  
  740.       public final java.lang.Class getType()
  741.       {
  742.         return m_type;
  743.       }
  744.    
  745.       /* This member function returns the chess piece color.
  746.        */
  747.  
  748.       public final int getColor()
  749.       {
  750.         return m_color;
  751.       }
  752.  
  753.       /* This function is used to record a new movement of a piece. Movement tracking
  754.        * is necessary for evaluating validity of special piece moves like en passant
  755.        * capture and castling.
  756.        */
  757.  
  758.       public final void incrementMoves()
  759.       {
  760.         ++m_moves;
  761.       }
  762.  
  763.       /* Reduces the number of times a piece has been moved. Used for adjustment when
  764.        * a function incidentally increments the movement of a piece in a case where
  765.        * a board evaluation is taking place, and is not intended as an actual move.
  766.        */
  767.  
  768.       public final void decrementMoves()
  769.       {
  770.         --m_moves;
  771.       }
  772.  
  773.       /* Returns the number of times a piece has been moved.
  774.        */
  775.  
  776.       public final int getMoves()
  777.       {
  778.         return m_moves;
  779.       }
  780.       private java.lang.Class m_type = new java.lang.Class(); // this variable holds the type of piece this object represents
  781.       private int m_color; // this variable holds the color of the piece, white or black
  782.       private int m_moves; // this variable holds the number of moves the piece has made
  783.     }
  784.    
  785.  
  786. /* This enum represents values for each of the possible "pieces" that can
  787.  * occupy a space on the chess board, including "blank" for a vacant space.
  788.  */
  789.     public class CPiece
  790.     {
  791.     public static enum Type
  792.     {
  793.       BLANK,
  794.       PAWN,
  795.       BISHOP,
  796.       KNIGHT,
  797.       ROOK,
  798.       QUEEN,
  799.       KING;
  800.  
  801.         public int getValue()
  802.         {
  803.             return this.ordinal();
  804.         }
  805.  
  806.         public static Type forValue(int value)
  807.         {
  808.             return values()[value];
  809.         }
  810.     }
  811.     }
  812.  
  813. /* This is the game play loop, it governs the the player's turns or delegates
  814.  * a move to the computer to play.
  815.  */
  816.     public static void play()
  817.     {
  818.       boolean gameOver = false; // game-play sentinel boolean variable
  819.       boolean computerPlay; // will the computer be playing? this bool hold the answer.
  820.       boolean skipTurn = false; // do we need to skip a color's turn? it depends on who moves first
  821.       String move; // this string is used for input of move coordinates as well as game options
  822.       int turn; // this holds the "color" of whose turn it is
  823.       ChessBoard board = new ChessBoard(); // we create the ChessBoard object
  824.       turn = WHITE;
  825.       System.out.print("\nWelcome to the game of Chess!\n");
  826.       System.out.print("\n");
  827.       do
  828.       { // We need to get some info about how the game will be played, first.
  829.         System.out.print("Enter 1 for computer play, 2 for human vs. human: ");
  830.         move = new Scanner(System.in).nextLine();
  831.       } while (!(move.length() != 0) || (move.charAt(0) != '1' && move.charAt(0) != '2'));
  832.       if (move.charAt(0) == '1')
  833.       {
  834.         computerPlay = true;
  835.         do
  836.         {
  837.           System.out.print("Enter W to play white pieces, or B to play black: ");
  838.           move = new Scanner(System.in).nextLine();
  839.         } while (!(move.length() != 0) || (!(Character.toUpperCase(move.charAt(0)) == 'W') && !(Character.toUpperCase(move.charAt(0)) == 'B')));
  840.         if (Character.toUpperCase(move.charAt(0)) == 'B')
  841.         {
  842.           skipTurn = true;
  843.           turn = BLACK;
  844.           board.flip();
  845.         }
  846.         else
  847.         {
  848.           skipTurn = false;
  849.         }
  850.       }
  851.       else
  852.       {
  853.         computerPlay = false;
  854.       }
  855.       System.out.print((computerPlay ? "\nComputer competitor mode." : "\nHuman vs. " + "human mode."));
  856.       System.out.print("\n");
  857.       if (computerPlay)
  858.       {
  859.         System.out.print((skipTurn ? "Playing black pieces." : "Playing white pieces."));
  860.         System.out.print("\n");
  861.       }
  862.       System.out.print("Enter ? for help.");
  863.       System.out.print("\n");
  864.       do
  865.       { // here we enter the game-play loop
  866.         if (!skipTurn)
  867.           do
  868.           {
  869.             board.display(); // show the board
  870.             if (P4ChessBL.putInCheck(board, turn)) // the loop checks the board configuration for certain scenarios
  871.             {
  872.               if (P4ChessBL.isCheckMate(board, turn))
  873.               {
  874.                 System.out.print("Check Mate!");
  875.                 System.out.print("\n");
  876.                 gameOver = true;
  877.                 break;
  878.               }
  879.               System.out.print("You are in check.");
  880.               System.out.print("\n");
  881.             }
  882.             else
  883.             {
  884.             if (P4ChessBL.isStalemate(board, turn))
  885.             {
  886.               System.out.print("Stalemate!");
  887.               System.out.print("\n");
  888.               gameOver = true;
  889.               break;
  890.             }
  891.             else
  892.             {
  893.             if (P4ChessBL.isDraw(board))
  894.             {
  895.               System.out.print("Draw!");
  896.               System.out.print("\n");
  897.               gameOver = true;
  898.               break;
  899.             }
  900.             }
  901.             }
  902.             if (board.isPotentialDraw(turn))
  903.             {
  904.               System.out.print("CPiece.Type \"DRAW\" to declare Draw. ");
  905.             }
  906.             System.out.print(':');
  907.             move = new Scanner(System.in).nextLine();
  908.             if ((move.length() != 0) && Character.toUpperCase(move.charAt(0)) == 'Q')
  909.             {
  910.               gameOver = true;
  911.               break;
  912.             }
  913.             if (board.isPotentialDraw(turn) && P4ChessBL.allCaps(move).equals("DRAW"))
  914.             {
  915.               gameOver = board.callDraw(turn);
  916.               if (gameOver)
  917.               {
  918.                 System.out.print("Draw!");
  919.                 System.out.print("\n");
  920.               }
  921.               break;
  922.             }
  923.             if (move.equals("?"))
  924.             {
  925.               P4ChessBL.displayHelp();
  926.             }
  927.           } while (!P4ChessBL.goodMove(board, move, turn));
  928.         else
  929.         {
  930.           skipTurn = false;
  931.         }
  932.         board.flip();
  933.         if (turn == WHITE)
  934.         {
  935.           turn = BLACK;
  936.         }
  937.         else
  938.         {
  939.           turn = WHITE;
  940.         }
  941.         if (computerPlay && !gameOver) // if the computer is playing, it will make its move here
  942.         {
  943.           if (P4ChessBL.isCheckMate(board, turn))
  944.           {
  945.             System.out.print("Check Mate!");
  946.             System.out.print("\n");
  947.             gameOver = true;
  948.             break;
  949.           }
  950.           else
  951.           {
  952.           if (P4ChessBL.isStalemate(board, turn))
  953.           {
  954.             System.out.print("Stalemate!");
  955.             System.out.print("\n");
  956.             gameOver = true;
  957.             break;
  958.           }
  959.           else
  960.           {
  961.           if (P4ChessBL.isDraw(board))
  962.           {
  963.             System.out.print("Draw!");
  964.             System.out.print("\n");
  965.             gameOver = true;
  966.             break;
  967.           }
  968.           else
  969.           {
  970.           if (board.isPotentialDraw(turn))
  971.           {
  972.             gameOver = board.callDraw(turn);
  973.             if (gameOver)
  974.             {
  975.               System.out.print("Draw!");
  976.               System.out.print("\n");
  977.             }
  978.             break;
  979.           }
  980.           }
  981.           }
  982.           }
  983.           P4ChessBL.computerMove(board, turn);
  984.           if (turn == WHITE)
  985.           {
  986.             turn = BLACK;
  987.           }
  988.           else
  989.           {
  990.             turn = WHITE;
  991.           }
  992.           board.flip();
  993.         }
  994.       } while (!gameOver);
  995.     }
  996.  
  997. /* This function evaluates whether or not the move coordinates entered are
  998.  * valid, and if they are it will go ahead and make function calls to make that
  999.  * move
  1000.  */
  1001.  
  1002.     public static boolean goodMove(ChessBoard board, String move, int turn)
  1003.     {
  1004.       if (move.equals("?"))
  1005.       {
  1006.         return false;
  1007.       }
  1008.       if (move.length() != 5)
  1009.       {
  1010.         System.out.print("\nErroneous input.");
  1011.         System.out.print("\n");
  1012.         return false;
  1013.       }
  1014.       byte beginCoordX;
  1015.       byte beginCoordY;
  1016.       byte endCoordX;
  1017.       byte endCoordY;
  1018.       beginCoordX = (byte)(move.charAt(0)); // we're converting the text input into numerical coordinates
  1019.       beginCoordY = (byte)(move.charAt(1));
  1020.       endCoordX = (byte)(move.charAt(3));
  1021.       endCoordY = (byte)(move.charAt(4));
  1022.       beginCoordX = (byte)(Character.toUpperCase(beginCoordX));
  1023.       endCoordX = (byte)(Character.toUpperCase(endCoordX));
  1024.       beginCoordX -= 65;
  1025.       endCoordX -= 65;
  1026.       beginCoordY -= 49;
  1027.       endCoordY -= 49;
  1028.       beginCoordY = (byte)(7 - beginCoordY);
  1029.       endCoordY = (byte)(7 - endCoordY);
  1030.       if (!((beginCoordX >= 0 && beginCoordX < 8) && (beginCoordY >= 0 && beginCoordY < 8) && (endCoordX >= 0 && endCoordX < 8) && (endCoordY >= 0 && endCoordY < 8))) // we respond to some potential errors in input for this turn
  1031.       {
  1032.         System.out.print("\nErroneous input.");
  1033.         System.out.print("\n");
  1034.         return false;
  1035.       }
  1036.       ChessPiece piece;
  1037.       piece = new ChessPiece(board.at(beginCoordX, beginCoordY));
  1038.       if (piece.getColor() != turn || piece.getType() == CPiece.Type.BLANK)
  1039.       {
  1040.         System.out.print("\nYou need to move one of your pieces.\nInvalid move.");
  1041.         System.out.print("\n");
  1042.         if (piece != null)
  1043.         piece.dispose();
  1044.         return false;
  1045.       }
  1046.       if (beginCoordX == endCoordX && beginCoordY == endCoordY)
  1047.       {
  1048.         System.out.print("\nInvalid move.");
  1049.         System.out.print("\n");
  1050.         if (piece != null)
  1051.         piece.dispose();
  1052.         return false;
  1053.       }
  1054.       if (P4ChessBL.inRange(board, piece, beginCoordX, beginCoordY, endCoordX, endCoordY) && P4ChessBL.pathClear(board, piece, beginCoordX, beginCoordY, endCoordX, endCoordY)) // we're checking to see if a move is possible given the coordinates
  1055.       {
  1056.         if (piece.getType().equals(CPiece.Type.KING) && P4ChessBL.putInCheck(board, piece.getColor()) && beginCoordY == endCoordY && (beginCoordX - 2 == endCoordX || beginCoordX + 2 == endCoordX)) // handling an attempt to castle out of check here
  1057.         {
  1058.           System.out.print("\nYou may not castle out of check.");
  1059.         }
  1060.         else
  1061.         {
  1062.         if (piece.getType().equals(CPiece.Type.KING) && beginCoordY == endCoordY && (beginCoordX - 2 == endCoordX || beginCoordX + 2 == endCoordX) && ((beginCoordX - 2 == endCoordX && P4ChessBL.putInCheck(board, piece.getColor(), beginCoordX, beginCoordY, beginCoordX - 1, endCoordY)) || (beginCoordX + 2 == endCoordX && P4ChessBL.putInCheck(board, piece.getColor(), beginCoordX, beginCoordY, beginCoordX + 1, endCoordY)))) // handling an attempt to castle THROUGH check, here
  1063.         {
  1064.           System.out.print("\nYou may not castle through check.");
  1065.         }
  1066.         else
  1067.         {
  1068.         if (!P4ChessBL.putInCheck(board, piece.getColor(), beginCoordX, beginCoordY, endCoordX, endCoordY)) // handling a successful move
  1069.         {
  1070.           board.move(beginCoordX, beginCoordY, endCoordX, endCoordY);
  1071.           if (piece.getType().equals(CPiece.Type.KING) && beginCoordY == endCoordY && (beginCoordX - 2 == endCoordX || beginCoordX + 2 == endCoordX)) // ...and handling a castle move, if that's the case
  1072.           {
  1073.             System.out.print("\nCastle move.");
  1074.             System.out.print("\n");
  1075.             if (beginCoordX > endCoordX)
  1076.             {
  1077.               board.move(0, 7, 2 + piece.getColor(), 7);
  1078.             }
  1079.             else
  1080.             {
  1081.               board.move(7, 7, 4 + piece.getColor(), 7);
  1082.             }
  1083.           }
  1084.           if (piece != null)
  1085.           piece.dispose();
  1086.           return true;
  1087.         }
  1088.         else
  1089.         {
  1090.           System.out.print("\nThat move would leave you in check.");
  1091.         }
  1092.         }
  1093.         }
  1094.       }
  1095.       System.out.print("\nInvalid move.");
  1096.       System.out.print("\n");
  1097.       if (piece != null)
  1098.       piece.dispose();
  1099.       return false;
  1100.     }
  1101.  
  1102. /* This function is used for checking whether or not a piece is capable of
  1103.  * making a move to the coordinate supplied.
  1104.  */
  1105.  
  1106.     public static boolean inRange(ChessBoard board, ChessPiece piece, int bX, int bY, int eX, int eY)
  1107.     {
  1108.       ChessPiece target;
  1109.       target = board.at(eX, eY);
  1110.       switch (piece.getType().toString)
  1111.       {
  1112.         case "PAWN":
  1113.           if ((bY - eY == 1 && bX == eX) || (piece.getMoves() == 0 && bY - eY == 2 && bX == eX))
  1114.           {
  1115.             return true;
  1116.           }
  1117.           if (bY - eY == 1 && ((eX - 1 == bX || eX + 1 == bX) && target.getType().equals(CPiece.Type.BLANK) && target.getColor() != piece.getColor()))
  1118.           {
  1119.             return true;
  1120.           }
  1121.           if (bY - eY == 1 && eX != bX && board.at(eX, eY + 1).getType().equals(CPiece.Type.PAWN) && board.at(eX, eY + 1).getMoves() == 1 && eY == 2 && board.lastMoveWas(eX, eY + 1))
  1122.           {
  1123.             return board.enPassantOption(piece.getColor());
  1124.           }
  1125.           return false;
  1126.         case "ROOK":
  1127.           if ((bX == eX && bY != eY) || (bX != eX && bY == eY))
  1128.           {
  1129.             return true;
  1130.           }
  1131.           return false;
  1132.         case "KNIGHT":
  1133.           if ((bX == eX - 2 || bX == eX + 2) && (bY == eY - 1 || bY == eY + 1))
  1134.           {
  1135.             return true;
  1136.           }
  1137.           if ((bY == eY - 2 || bY == eY + 2) && (bX == eX - 1 || bX == eX + 1))
  1138.           {
  1139.             return true;
  1140.           }
  1141.           return false;
  1142.         case "BISHOP":
  1143.           if (bX > eX && (bY - eY == bX - eX || eY - bY == bX - eX))
  1144.           {
  1145.             return true;
  1146.           }
  1147.           if (bX < eX && (bY - eY == eX - bX || eY - bY == eX - bX))
  1148.           {
  1149.             return true;
  1150.           }
  1151.           return false;
  1152.         case "QUEEN":
  1153.           if ((bX == eX && bY != eY) || (bX != eX && bY == eY))
  1154.           {
  1155.             return true;
  1156.           }
  1157.           if (bX > eX && (bY - eY == bX - eX || eY - bY == bX - eX))
  1158.           {
  1159.             return true;
  1160.           }
  1161.           if (bX < eX && (bY - eY == eX - bX || eY - bY == eX - bX))
  1162.           {
  1163.             return true;
  1164.           }
  1165.           return false;
  1166.         case "KING":
  1167.           if (bX <= eX + 1 && bX >= eX - 1 && bY <= eY + 1 && bY >= eY - 1)
  1168.           {
  1169.             return true;
  1170.           }
  1171.           if (bY == eY && ((bX - 2 == eX && board.at(0, eY).getMoves() == 0) || (bX + 2 == eX && board.at(7, eY).getMoves() == 0)) && piece.getMoves() == 0 && eY == 7)
  1172.           {
  1173.             return true;
  1174.           }
  1175.           return false;
  1176.       }
  1177.       return false;
  1178.     }
  1179.  
  1180. /* This function checks whether or not a piece is blocked by other pieces
  1181.  * while it tries to move to a location that is otherwise "in range"
  1182.  */
  1183.  
  1184.     public static boolean pathClear(ChessBoard board, ChessPiece piece, int bX, int bY, int eX, int eY)
  1185.     {
  1186.       switch (piece.getType().toString)
  1187.       {
  1188.         case "PAWN":
  1189.           if (bX == eX && board.at(eX, eY).getType() != CPiece.Type.BLANK)
  1190.           {
  1191.             return false;
  1192.           }
  1193.           if (bX == eX && bY - 2 == eY && board.at(eX, eY + 1).getType() != CPiece.Type.BLANK)
  1194.           {
  1195.             return false;
  1196.           }
  1197.           return true;
  1198.         case "ROOK":
  1199.           if (bX == eX)
  1200.           {
  1201.             if (bY < eY)
  1202.             {
  1203.               for (int i = bY + 1; i <= eY; ++i)
  1204.               {
  1205.                 if ((board.at(eX, i).getType() != CPiece.Type.BLANK && i != eY) || board.at(eX, i).getColor() == piece.getColor())
  1206.                 {
  1207.                   return false;
  1208.                 }
  1209.               }
  1210.             }
  1211.             else
  1212.             {
  1213.               for (int i = bY - 1; i >= eY; --i)
  1214.               {
  1215.                 if ((board.at(eX, i).getType() != CPiece.Type.BLANK && i != eY) || board.at(eX, i).getColor() == piece.getColor())
  1216.                 {
  1217.                   return false;
  1218.                 }
  1219.               }
  1220.             }
  1221.           }
  1222.           else
  1223.           {
  1224.             if (bX < eX)
  1225.             {
  1226.               for (int i = bX + 1; i <= eX; ++i)
  1227.               {
  1228.                 if ((board.at(i, eY).getType() != CPiece.Type.BLANK && i != eX) || board.at(i, eY).getColor() == piece.getColor())
  1229.                 {
  1230.                   return false;
  1231.                 }
  1232.               }
  1233.             }
  1234.             else
  1235.             {
  1236.               for (int i = bX - 1; i >= eX; --i)
  1237.               {
  1238.                 if ((board.at(i, eY).getType() != CPiece.Type.BLANK && i != eX) || board.at(i, eY).getColor() == piece.getColor())
  1239.                 {
  1240.                   return false;
  1241.                 }
  1242.               }
  1243.             }
  1244.           }
  1245.           return true;
  1246.         case "KNIGHT":
  1247.           if (board.at(eX, eY).getColor() == piece.getColor())
  1248.           {
  1249.             return false;
  1250.           }
  1251.           return true;
  1252.         case "BISHOP":
  1253.           if (bX < eX)
  1254.           {
  1255.             if (bY < eY)
  1256.             {
  1257.               for (int i = bX + 1, j = bY + 1; i <= eX && j <= eY; ++i, ++j)
  1258.               {
  1259.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1260.                 {
  1261.                   return false;
  1262.                 }
  1263.               }
  1264.             }
  1265.             else
  1266.             {
  1267.               for (int i = bX + 1, j = bY - 1; i <= eX && j >= eY; ++i, --j)
  1268.               {
  1269.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1270.                 {
  1271.                   return false;
  1272.                 }
  1273.               }
  1274.             }
  1275.           }
  1276.           else
  1277.           {
  1278.             if (bY < eY)
  1279.             {
  1280.               for (int i = bX - 1, j = bY + 1; i >= eX && j <= eY; --i, ++j)
  1281.               {
  1282.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1283.                 {
  1284.                   return false;
  1285.                 }
  1286.               }
  1287.             }
  1288.             else
  1289.             {
  1290.               for (int i = bX - 1, j = bY - 1; i >= eX && j >= eY; --i, --j)
  1291.               {
  1292.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1293.                 {
  1294.                   return false;
  1295.                 }
  1296.               }
  1297.             }
  1298.           }
  1299.           return true;
  1300.         case "QUEEN":
  1301.           if (bX == eX)
  1302.           {
  1303.             if (bY < eY)
  1304.             {
  1305.               for (int i = bY + 1; i <= eY; ++i)
  1306.               {
  1307.                 if ((board.at(eX, i).getType() != CPiece.Type.BLANK && i != eY) || board.at(eX, i).getColor() == piece.getColor())
  1308.                 {
  1309.                   return false;
  1310.                 }
  1311.               }
  1312.             }
  1313.             else
  1314.             {
  1315.               for (int i = bY - 1; i >= eY; --i)
  1316.               {
  1317.                 if ((board.at(eX, i).getType() != CPiece.Type.BLANK && i != eY) || board.at(eX, i).getColor() == piece.getColor())
  1318.                 {
  1319.                   return false;
  1320.                 }
  1321.               }
  1322.             }
  1323.           }
  1324.           else
  1325.           {
  1326.           if (bY == eY)
  1327.           {
  1328.             if (bX < eX)
  1329.             {
  1330.               for (int i = bX + 1; i <= eX; ++i)
  1331.               {
  1332.                 if ((board.at(i, eY).getType() != CPiece.Type.BLANK && i != eX) || board.at(i, eY).getColor() == piece.getColor())
  1333.                 {
  1334.                   return false;
  1335.                 }
  1336.               }
  1337.             }
  1338.             else
  1339.             {
  1340.               for (int i = bX - 1; i >= eX; --i)
  1341.               {
  1342.                 if ((board.at(i, eY).getType() != CPiece.Type.BLANK && i != eX) || board.at(i, eY).getColor() == piece.getColor())
  1343.                 {
  1344.                   return false;
  1345.                 }
  1346.               }
  1347.             }
  1348.           }
  1349.           }
  1350.           if (bX < eX)
  1351.           {
  1352.             if (bY < eY)
  1353.             {
  1354.               for (int i = bX + 1, j = bY + 1; i <= eX && j <= eY; ++i, ++j)
  1355.               {
  1356.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1357.                 {
  1358.                   return false;
  1359.                 }
  1360.               }
  1361.             }
  1362.             else
  1363.             {
  1364.               for (int i = bX + 1, j = bY - 1; i <= eX && j >= eY; ++i, --j)
  1365.               {
  1366.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1367.                 {
  1368.                   return false;
  1369.                 }
  1370.               }
  1371.             }
  1372.           }
  1373.           else
  1374.           {
  1375.             if (bY < eY)
  1376.             {
  1377.               for (int i = bX - 1, j = bY + 1; i >= eX && j <= eY; --i, ++j)
  1378.               {
  1379.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1380.                 {
  1381.                   return false;
  1382.                 }
  1383.               }
  1384.             }
  1385.             else
  1386.             {
  1387.               for (int i = bX - 1, j = bY - 1; i >= eX && j >= eY; --i, --j)
  1388.               {
  1389.                 if ((board.at(i, j).getType() != CPiece.Type.BLANK && i != eX && j != eY) || board.at(i, j).getColor() == piece.getColor())
  1390.                 {
  1391.                   return false;
  1392.                 }
  1393.               }
  1394.             }
  1395.           }
  1396.           return true;
  1397.         case "KING":
  1398.           if (board.at(eX, eY).getColor() == piece.getColor())
  1399.           {
  1400.             return false;
  1401.           }
  1402.           if (bX + 1 < eX || bX - 1 > eX)
  1403.           {
  1404.             if (bX > eX)
  1405.             {
  1406.               for (int i = bX - 1; i > 0; --i)
  1407.               {
  1408.                 if (board.at(i, 7).getColor() != CLEAR)
  1409.                 {
  1410.                   return false;
  1411.                 }
  1412.               }
  1413.             }
  1414.             if (bX < eX)
  1415.             {
  1416.               for (int i = bX + 1; i < 7; ++i)
  1417.               {
  1418.                 if (board.at(i, 7).getColor() != CLEAR)
  1419.                 {
  1420.                   return false;
  1421.                 }
  1422.               }
  1423.             }
  1424.           }
  1425.           return true;
  1426.       }
  1427.       return false;
  1428.     }
  1429.  
  1430. /* This function checks whether or not a player will be in check if he makes
  1431.  * a certain move.
  1432.  */
  1433.  
  1434.     public static boolean putInCheck(ChessBoard board, int color, int bX, int bY, int eX, int eY)
  1435.     {
  1436.       int[] kingLoc = new int[2];
  1437.       int enemy;
  1438.       if (color == BLACK)
  1439.       {
  1440.         enemy = WHITE;
  1441.       }
  1442.       else
  1443.       {
  1444.         enemy = BLACK;
  1445.       }
  1446.       ChessPiece target;
  1447.       target = new ChessPiece(board.at(eX, eY));
  1448.       board.move(bX, bY, eX, eY, CHECK_MOVE);
  1449.       if (bX != eX || bY != eY)
  1450.       {
  1451.         board.at(eX, eY).decrementMoves();
  1452.       }
  1453.       board.flip();
  1454.       P4ChessBL.getKingLocation(board, color, kingLoc);
  1455.       for (int i = 0; i < 8; ++i)
  1456.       {
  1457.         for (int j = 0; j < 8; ++j)
  1458.         {
  1459.           if (board.at(i, j).getColor() == enemy && P4ChessBL.inRange(board, board.at(i, j), i, j, kingLoc[0], kingLoc[1]) && P4ChessBL.pathClear(board, board.at(i, j), i, j, kingLoc[0], kingLoc[1]))
  1460.           {
  1461.             board.flip();
  1462.             board.move(eX, eY, bX, bY, CHECK_MOVE);
  1463.             if (bX != eX || bY != eY)
  1464.             {
  1465.               board.at(bX, bY).decrementMoves();
  1466.             }
  1467.             board.replace(target, eX, eY);
  1468.             return true;
  1469.           }
  1470.         }
  1471.       }
  1472.       board.flip();
  1473.       board.move(eX, eY, bX, bY, CHECK_MOVE);
  1474.       if (bX != eX || bY != eY)
  1475.       {
  1476.         board.at(bX, bY).decrementMoves();
  1477.       }
  1478.       board.replace(target, eX, eY);
  1479.       return false;
  1480.     }
  1481.  
  1482. /* This function overloads the previous, and calls the previous with the same
  1483.  * beginning and ending coordinates of the king.  This determines if a player
  1484.  * is currently IN check.
  1485.  */
  1486.  
  1487.     public static boolean putInCheck(ChessBoard board, int color)
  1488.     {
  1489.       int[] kingLoc = new int[2];
  1490.       P4ChessBL.getKingLocation(board, color, kingLoc);
  1491.       return P4ChessBL.putInCheck(board, color, kingLoc[0], kingLoc[1], kingLoc[0], kingLoc[1]);
  1492.     }
  1493.  
  1494. /* This function is used by the AI implementation to decide if a certain piece
  1495.  * at a location is at risk of being lost to the opponent.
  1496.  */
  1497.  
  1498.     public static boolean inJeopardy(ChessBoard board, int color, int bX, int bY, int eX, int eY)
  1499.     {
  1500.       int enemy;
  1501.       if (color == BLACK)
  1502.       {
  1503.         enemy = WHITE;
  1504.       }
  1505.       else
  1506.       {
  1507.         enemy = BLACK;
  1508.       }
  1509.       ChessPiece target;
  1510.       target = new ChessPiece(board.at(eX, eY));
  1511.       board.move(bX, bY, eX, eY, CHECK_MOVE);
  1512.       if (bX != eX || bY != eY)
  1513.       {
  1514.         board.at(eX, eY).decrementMoves();
  1515.       }
  1516.       board.flip();
  1517.       for (int i = 0; i < 8; ++i)
  1518.       {
  1519.         for (int j = 0; j < 8; ++j)
  1520.         {
  1521.           if (board.at(i, j).getColor() == enemy && P4ChessBL.inRange(board, board.at(i, j), i, j, 7 - eX, 7 - eY) && P4ChessBL.pathClear(board, board.at(i, j), i, j, 7 - eX, 7 - eY))
  1522.           {
  1523.             board.flip();
  1524.             board.move(eX, eY, bX, bY, CHECK_MOVE);
  1525.             if (bX != eX || bY != eY)
  1526.             {
  1527.               board.at(bX, bY).decrementMoves();
  1528.             }
  1529.             board.replace(target, eX, eY);
  1530.             return true;
  1531.           }
  1532.         }
  1533.       }
  1534.       board.flip();
  1535.       board.move(eX, eY, bX, bY, CHECK_MOVE);
  1536.       if (bX != eX || bY != eY)
  1537.       {
  1538.         board.at(bX, bY).decrementMoves();
  1539.       }
  1540.       board.replace(target, eX, eY);
  1541.       return false;
  1542.     }
  1543.  
  1544. /* This function returns true if a player cannot move any pieces without
  1545.  * putting himself in check.
  1546.  */
  1547.  
  1548.     public static boolean isStalemate(ChessBoard board, int color)
  1549.     {
  1550.       for (int i = 0; i < 8; ++i)
  1551.       {
  1552.         for (int j = 0; j < 8; ++j)
  1553.         {
  1554.           if (board.at(i, j).getColor() == color)
  1555.           {
  1556.             for (int k = 0; k < 8; ++k)
  1557.             {
  1558.               for (int m = 0; m < 8; ++m)
  1559.               {
  1560.                 if (P4ChessBL.inRange(board, board.at(i, j), i, j, k, m) && P4ChessBL.pathClear(board, board.at(i, j), i, j, k, m) && !P4ChessBL.putInCheck(board, color, i, j, k, m))
  1561.                 {
  1562.                   return false;
  1563.                 }
  1564.               }
  1565.             }
  1566.           }
  1567.         }
  1568.       }
  1569.       return true;
  1570.     }
  1571.  
  1572. /* This function checks if the player is IN check, and uses the stalemate
  1573.  * function to determine whether or not there is a way out of it.  If there
  1574.  * is no way out, it is a check mate.
  1575.  */
  1576.  
  1577.     public static boolean isCheckMate(ChessBoard board, int color)
  1578.     {
  1579.       return P4ChessBL.putInCheck(board, color) && P4ChessBL.isStalemate(board, color);
  1580.     }
  1581.  
  1582. /* This function finds a player's king piece and fills the array "loc" with
  1583.  * its location
  1584.  */
  1585.  
  1586.     public static void getKingLocation(ChessBoard board, int color, int[] loc)
  1587.     {
  1588.       for (int i = 0; i < 8; ++i)
  1589.       {
  1590.         for (int j = 0; j < 8; ++j)
  1591.         {
  1592.           if (board.at(i, j).getType() == CPiece.Type.KING && board.at(i, j).getColor() == color)
  1593.           {
  1594.             loc[0] = i;
  1595.             loc[1] = j;
  1596.           }
  1597.         }
  1598.       }
  1599.     }
  1600.  
  1601. /* Returns true if the game is a draw by way of insufficient pieces.
  1602.  */
  1603.  
  1604.     public static boolean isDraw(ChessBoard board)
  1605.     {
  1606.       if (isInsufficientPieces(board))
  1607.       {
  1608.         System.out.print("Insufficient pieces to win game.");
  1609.         System.out.print("\n");
  1610.         return true;
  1611.       }
  1612.       return false;
  1613.     }
  1614.  
  1615. /* This function is used to determine if the players both have bishops on the
  1616.  * same colored square.  It is used to determine if there are sufficient
  1617.  * pieces to accomplish a check mate.  2 kings and 2 bishops of the same color
  1618.  * square do not allow check mate.
  1619.  */
  1620.  
  1621.     public static boolean sameSquareColorBishops(ChessBoard board)
  1622.     {
  1623.       int xpos = -1;
  1624.       int ypos;
  1625.       for (int i = 0; i < 8; ++i)
  1626.       {
  1627.         for (int j = 0; j < 8; ++j)
  1628.         {
  1629.           if (board.at(i, j).getType() == CPiece.Type.BISHOP)
  1630.           {
  1631.             if (xpos == -1)
  1632.             {
  1633.               xpos = i;
  1634.               ypos = j;
  1635.             }
  1636.             else
  1637.             {
  1638.               if ((i % 2 == j % 2 && xpos % 2 == ypos % 2) || (i % 2 != j % 2 && xpos % 2 != ypos % 2))
  1639.               {
  1640.                 return true;
  1641.               }
  1642.             }
  1643.           }
  1644.         }
  1645.       }
  1646.       return false;
  1647.     }
  1648.  
  1649. /* Here is the artificial intelligence function for the computer to make moves
  1650.  */
  1651.  
  1652.     public void computerMove(ChessBoard boardIn, int color)
  1653.     {
  1654.       java.util.ArrayList<Arrays.std_pair<Coord, Coord>> choices = new java.util.ArrayList<Arrays.std_pair<Coord, Coord>>(); // this vector stores possible moves
  1655.       java.util.ArrayList<Arrays.std_pair<Coord, Coord>> appealing = new java.util.ArrayList<Arrays.std_pair<Coord, Coord>>(); // this vector stores the most appealing moves to make
  1656.       Arrays.std_pair<Coord, Coord> movement = new Arrays.std_pair<Coord, Coord>();
  1657.       Coord coord = new Coord();
  1658.       ChessPiece piece;
  1659.       ChessBoard board = new ChessBoard(boardIn); // we make a copy of the passed-in board to manipulate for evaluation
  1660.       int appeal; // this variable is used to record the appeal of a possible move
  1661.       int maxAppeal = -10; // the max appeal variable will represent the most appealing move strength
  1662.       int checks = 0;
  1663.       int lastbX;
  1664.       int lastbY;
  1665.       int lasteX;
  1666.       int lasteY;
  1667.       boolean firstPass = true; // the computer will make an invisible "hypthetical" move on the
  1668.       do // ^-- first pass, then see if it can come up with an appealing move to
  1669.       { // follow with, it is only looking 1 move ahead.
  1670.           for (int i = 0; i < 8; ++i) // on each pass, the computer looks at all possible moves it could make on
  1671.           {
  1672.           for (int j = 0; j < 8; ++j) // the board, and then tries to judge the best choices to randomly use
  1673.           {
  1674.             if (board.at(i, j).getColor() == color) // we're scanning the whole board, this checks if we can even move from here
  1675.             {
  1676.               coord.m_X = i;
  1677.               coord.m_Y = j;
  1678.               piece = new ChessPiece(board.at(i, j)); // we're making a copy of the piece at the location for properties
  1679.               movement.first = coord;
  1680.               for (int k = 0; k < 8; ++k) // these are the loops to handle potential target coordinates for the
  1681.               {
  1682.                 for (int m = 0; m < 8; ++m) // next move to make
  1683.                 {
  1684.                   if (k == i && m == j) // if we're looking at moving to the same spot we're at, we just go
  1685.                     continue; // on to the next evalutation
  1686.                   appeal = 0;
  1687.                   if (P4ChessBL.inRange(board, piece, i, j, k, m) && P4ChessBL.pathClear(board, piece, i, j, k, m)) // here we check if a certain move is valid...
  1688.                   {
  1689.                     if (piece.getType().equals(CPiece.Type.KING) && P4ChessBL.putInCheck(board, piece.getColor()) && j == m && (i - 2 == k || i + 2 == k))
  1690.                     {
  1691.                         ; // we check if a castle is possible based on if we're in check, if in check
  1692.                     }
  1693.                     else // ^-- we do nothing with a castle move
  1694.                     {
  1695.                     if (piece.getType().equals(CPiece.Type.KING) && j == m && (i - 2 == k || i + 2 == k) && ((i - 2 == k && P4ChessBL.putInCheck(board, piece.getColor(), i, j, i - 1, m)) || (i + 2 == k && P4ChessBL.putInCheck(board, piece.getColor(), i, j, i + 1, m))))
  1696.                     {
  1697.                         ; // ^-- we do nothing with a castle move if trying to move through check -  we check if a castle is possible based on if we'll move THROUGH check
  1698.                     }
  1699.                     else
  1700.                     {
  1701.                     if (!P4ChessBL.putInCheck(board, piece.getColor(), i, j, k, m)) // we've determined that was could make this move, now we see if we should
  1702.                     {
  1703.                       if (firstPass && P4ChessBL.inJeopardy(board, piece.getColor(), i, j, i, j) && !P4ChessBL.inJeopardy(board, piece.getColor(), i, j, k, m)) // we're checking if moves will put the computer in jeopardy afterwards
  1704.                       {
  1705.                         appeal += 10 * piece.getType(); // we're grading moves based on what we will accomplish by moving there
  1706.                       }
  1707.                       appeal += 10 * board.at(k, m).getType();
  1708.                       if (board.at(i, j).getType().equals(CPiece.Type.PAWN) && m == 0)
  1709.                       {
  1710.                         appeal += 10 * CPiece.Type.QUEEN.getValue(); // appeal scores are greater for higher ranking pieces in the piece enum
  1711.                       }
  1712.                       if ((!firstPass && P4ChessBL.inJeopardy(board, piece.getColor(), i, j, i, j)) || P4ChessBL.inJeopardy(board, piece.getColor(), i, j, k, m))
  1713.                       {
  1714.                         appeal -= 10 * piece.getType();
  1715.                         if (piece.getType().equals(CPiece.Type.QUEEN))
  1716.                         {
  1717.                           appeal -= 20;
  1718.                         }
  1719.                       }
  1720.                       else
  1721.                       {
  1722.                       if (firstPass)
  1723.                       {
  1724.                         appeal += 10;
  1725.                       }
  1726.                       }
  1727.                       coord.m_X = k;
  1728.                       coord.m_Y = m;
  1729.                       movement.second = coord;
  1730.                       if (firstPass)
  1731.                       {
  1732.                         choices.add(movement); // this potential movement is now considered a "choice" for appeal checks
  1733.                       }
  1734.                       if (appeal > maxAppeal) // if we've found a move that is most appealing over previous judgements,
  1735.                       { // ^-- we clear the appealing vector and add new "more appealing" choices
  1736.                         maxAppeal = appeal;
  1737.                         appealing.clear();
  1738.                       }
  1739.                       if (appeal == maxAppeal) // if the appeal of the current potential move matches the highest appeal
  1740.                       { // found, we're going to add it to the appeal vector
  1741.                         if (firstPass)
  1742.                         {
  1743.                           movement.second.m_X = k;
  1744.                           movement.second.m_Y = m;
  1745.                         }
  1746.                         else
  1747.                         {
  1748.                           movement.first.m_X = lastbX;
  1749.                           movement.first.m_Y = lastbY;
  1750.                           movement.second.m_X = lasteX;
  1751.                           movement.second.m_Y = lasteY;
  1752.                         }
  1753.                         appealing.add(movement); // we only push appealing moves onto the appropriate vector on 2nd pass
  1754.                       }
  1755.                     }
  1756.                     }
  1757.                     }
  1758.                   }
  1759.                 }
  1760.               }
  1761.               if (piece != null)
  1762.               piece.dispose();
  1763.             }
  1764.           }
  1765.           }
  1766.         firstPass = false; // we've looped over the board once, now we can perform 2nd pass operations
  1767.         if (checks < choices.size())
  1768.         {
  1769.           board.copyFrom(boardIn);
  1770.           lastbX = choices.get(checks).first.m_X;
  1771.           lastbY = choices.get(checks).first.m_Y;
  1772.           lasteX = choices.get(checks).second.m_X;
  1773.           lasteY = choices.get(checks).second.m_Y;
  1774.           board.move(lastbX, lastbY, lasteX, lasteY, CHECK_MOVE); // here's a call the the ChessBoard move function for a "test move"
  1775.         } // this sets up a hypothetical new board situation to further evaluate
  1776.         ++checks;
  1777.       } while (checks < choices.size());
  1778.       if (appealing.size() == 0)
  1779.       {
  1780.         appealing = new java.util.ArrayList<Arrays.std_pair<Coord, Coord>>(choices);
  1781.       }
  1782.       if (appealing.size() != 0) // once we have looked over the board, it's time to make a move
  1783.       {
  1784.         int z;
  1785.         z = RandomNumbers.nextNumber() % (appealing.size());
  1786.         boardIn.move(appealing.get(z).first.m_X, appealing.get(z).first.m_Y, appealing.get(z).second.m_X, appealing.get(z).second.m_Y, REAL_MOVE); // calling ChessBoard move function with a real move, not hypothetical
  1787.         System.out.print("\nComputer Move: ");
  1788.         System.out.print((byte)(104 - appealing.get(z).first.m_X));
  1789.         System.out.print((byte)(49 + appealing.get(z).first.m_Y));
  1790.         System.out.print(" to ");
  1791.         System.out.print((byte)(104 - appealing.get(z).second.m_X));
  1792.         System.out.print((byte)(49 + appealing.get(z).second.m_Y));
  1793.         System.out.print("\n");
  1794.         piece = new ChessPiece(board.at(appealing.get(z).first.m_X, appealing.get(z).first.m_Y));
  1795.         if (piece.getType().equals(CPiece.Type.KING) && appealing.get(z).first.m_Y == appealing.get(z).second.m_Y && (appealing.get(z).first.m_X - 2 == appealing.get(z).second.m_X || appealing.get(z).first.m_X + 2 == appealing.get(z).second.m_X))
  1796.         {
  1797.             if (appealing.get(z).first.m_X > appealing.get(z).second.m_X)
  1798.             {
  1799.               board.move(0, 7, 2 + piece.getColor(), 7);
  1800.             }
  1801.             else
  1802.             {
  1803.               board.move(7, 7, 4 + piece.getColor(), 7);
  1804.             }
  1805.         }
  1806.         if (piece != null)
  1807.         piece.dispose();
  1808.       }
  1809.     }
  1810.  
  1811.    
  1812. /* This function just returns an all-caps representation of an input string
  1813.  */
  1814.  
  1815.     public static String allCaps(String str)
  1816.     {
  1817.       return str.toUpperCase();
  1818.     }
  1819.  
  1820. /* This function gives a quick introduction to the game instructions.
  1821.  */
  1822.  
  1823.     public static void displayHelp()
  1824.     {
  1825.       System.out.print("\nThis is a simple game of Chess. You make moves by entering " + "piece coordinates\nin the format: \"a2 a4\", where a2 represents the " + "beginning coordinate of a piece\nand a4 represents the desired placement. " + "Normal chess rules apply.\nEnter 'Q' by itself to quit the game.");
  1826.       System.out.print("\n");
  1827.     }
  1828.  
  1829.     /* Program entry point. We just seed the random number generator and call the
  1830.      * game play function which will loop over our game.
  1831.      */
  1832.  
  1833.     public static void Main()
  1834.     {
  1835.       RandomNumbers.seed((time(0)));
  1836.       P4ChessBL.play();
  1837.       return;
  1838.     }
  1839. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement