Exemple #1
0
 // IS CENTRE OF THREE IN A ROW
 public static Tuple <int, int> IsCentreOfThree(GameBoard_SYSTST <counters> board, counters us)
 {
     for (int x = 1; x <= 7; x++)
     {
         for (int y = 1; y <= 7; y++)
         {
             // check whether position piece at [x,y] has the same piece as neighbour
             for (int xx = 0; xx <= 1; xx++)
             {
                 for (int yy = 0; yy <= 1; yy++)
                 {
                     if (yy == 0 && xx == 0)
                     {
                         continue;
                     }
                     if (board[x, y] == us &&
                         board[x, y] == board[x + xx, y + yy] &&
                         board[x, y] == board[x - xx, y - yy])
                     {
                         return(new Tuple <int, int>(x, y));
                     }
                 }
             }
         }
     }
     return(new Tuple <int, int>(0, 0));
 }
Exemple #2
0
 public AIPlayer_SYSTST(counters _counter) : base(_counter)
 {
 }
Exemple #3
0
 // IS RIGHT OF THE TWO IN ROW
 public static Tuple <int, int> IsRightofTwo(GameBoard_SYSTST <counters> board, counters us)
 {
     for (int x = 1; x <= 7; x++)
     {
         for (int y = 1; y <= 7; y++)
         {
             // check whether position piece at [x,y] has the same piece as neighbour
             for (int xx = -1; xx <= 7; xx++)
             {
                 for (int yy = -1; yy <= 7; yy++)
                 {
                     if (yy == 0 && xx == 0)
                     {
                         continue;
                     }
                     if (board[x, y] == us && board[x, y] == board[x + xx, y + yy])
                     {
                         // two in a row in centre should give higher score
                         return(new Tuple <int, int>(x + xx, y + yy));
                     }
                 }
             }
         }
     }
     return(new Tuple <int, int>(0, 0));
 }
 /*
  * ----------------------------------------------------------------------------------------------------------------
  * Win -
  * --------------------------------------------------------------------------------------------------------------------------
  * The boolean method returns true or false wherever there is a three in a row (winning position) existing on the entire board.
  * --------------------------------------------------------------------------------------------------------------------------
  */
 // DETERMINE IF Player_TPL HAS WON
 public bool Win(GameBoard_TPL <counters> board, counters counter)
 {
     if (
         //HORIZONTAL
         (board[1, 1] == counter && board[2, 1] == counter && board[3, 1] == counter && board[4, 1] == counter && board[5, 1] == counter) ||
         (board[2, 1] == counter && board[3, 1] == counter && board[4, 1] == counter && board[5, 1] == counter && board[6, 1] == counter) ||
         (board[3, 1] == counter && board[4, 1] == counter && board[5, 1] == counter && board[6, 1] == counter && board[7, 1] == counter) ||
         (board[1, 2] == counter && board[2, 2] == counter && board[3, 2] == counter && board[4, 2] == counter && board[5, 2] == counter) ||
         (board[2, 2] == counter && board[3, 2] == counter && board[4, 2] == counter && board[5, 2] == counter && board[6, 2] == counter) ||
         (board[3, 2] == counter && board[4, 2] == counter && board[5, 2] == counter && board[6, 2] == counter && board[7, 2] == counter) ||
         (board[1, 3] == counter && board[2, 3] == counter && board[3, 3] == counter && board[4, 3] == counter && board[5, 3] == counter) ||
         (board[2, 3] == counter && board[3, 3] == counter && board[4, 3] == counter && board[5, 3] == counter && board[6, 3] == counter) ||
         (board[3, 3] == counter && board[4, 3] == counter && board[5, 3] == counter && board[6, 3] == counter && board[7, 3] == counter) ||
         (board[1, 4] == counter && board[2, 4] == counter && board[3, 4] == counter && board[4, 4] == counter && board[5, 4] == counter) ||
         (board[2, 4] == counter && board[3, 4] == counter && board[4, 4] == counter && board[5, 4] == counter && board[6, 4] == counter) ||
         (board[3, 4] == counter && board[4, 4] == counter && board[5, 4] == counter && board[6, 4] == counter && board[7, 4] == counter) ||
         (board[1, 5] == counter && board[2, 5] == counter && board[3, 5] == counter && board[4, 5] == counter && board[5, 5] == counter) ||
         (board[2, 5] == counter && board[3, 5] == counter && board[4, 5] == counter && board[5, 5] == counter && board[6, 5] == counter) ||
         (board[3, 5] == counter && board[4, 5] == counter && board[5, 5] == counter && board[6, 5] == counter && board[7, 5] == counter) ||
         (board[1, 6] == counter && board[2, 6] == counter && board[3, 6] == counter && board[4, 6] == counter && board[5, 6] == counter) ||
         (board[2, 6] == counter && board[3, 6] == counter && board[4, 6] == counter && board[5, 6] == counter && board[6, 6] == counter) ||
         (board[3, 6] == counter && board[4, 6] == counter && board[5, 6] == counter && board[6, 6] == counter && board[7, 6] == counter) ||
         (board[1, 7] == counter && board[2, 7] == counter && board[3, 7] == counter && board[4, 7] == counter && board[5, 7] == counter) ||
         (board[2, 7] == counter && board[3, 7] == counter && board[4, 7] == counter && board[5, 7] == counter && board[6, 7] == counter) ||
         (board[3, 7] == counter && board[4, 7] == counter && board[5, 7] == counter && board[6, 7] == counter && board[7, 7] == counter) ||
         //VERTICAL
         (board[1, 1] == counter && board[1, 2] == counter && board[1, 3] == counter && board[1, 4] == counter && board[1, 5] == counter) ||
         (board[1, 2] == counter && board[1, 3] == counter && board[1, 4] == counter && board[1, 5] == counter && board[1, 6] == counter) ||
         (board[1, 3] == counter && board[1, 4] == counter && board[1, 5] == counter && board[1, 6] == counter && board[1, 7] == counter) ||
         (board[2, 1] == counter && board[2, 2] == counter && board[2, 3] == counter && board[2, 4] == counter && board[2, 5] == counter) ||
         (board[2, 2] == counter && board[2, 3] == counter && board[2, 4] == counter && board[2, 5] == counter && board[2, 6] == counter) ||
         (board[2, 3] == counter && board[2, 4] == counter && board[2, 5] == counter && board[2, 6] == counter && board[2, 7] == counter) ||
         (board[3, 1] == counter && board[3, 2] == counter && board[3, 3] == counter && board[3, 4] == counter && board[3, 5] == counter) ||
         (board[3, 2] == counter && board[3, 3] == counter && board[3, 4] == counter && board[3, 5] == counter && board[3, 6] == counter) ||
         (board[3, 3] == counter && board[3, 4] == counter && board[3, 5] == counter && board[3, 6] == counter && board[3, 7] == counter) ||
         (board[4, 1] == counter && board[4, 2] == counter && board[4, 3] == counter && board[4, 4] == counter && board[4, 5] == counter) ||
         (board[4, 2] == counter && board[4, 3] == counter && board[4, 4] == counter && board[4, 5] == counter && board[4, 6] == counter) ||
         (board[4, 3] == counter && board[4, 4] == counter && board[4, 5] == counter && board[4, 6] == counter && board[4, 7] == counter) ||
         (board[5, 1] == counter && board[5, 2] == counter && board[5, 3] == counter && board[5, 4] == counter && board[5, 5] == counter) ||
         (board[5, 2] == counter && board[5, 3] == counter && board[5, 4] == counter && board[5, 5] == counter && board[5, 6] == counter) ||
         (board[5, 3] == counter && board[5, 4] == counter && board[5, 5] == counter && board[5, 6] == counter && board[5, 7] == counter) ||
         (board[6, 1] == counter && board[6, 2] == counter && board[6, 3] == counter && board[6, 4] == counter && board[6, 5] == counter) ||
         (board[6, 2] == counter && board[6, 3] == counter && board[6, 4] == counter && board[6, 5] == counter && board[6, 6] == counter) ||
         (board[6, 3] == counter && board[6, 4] == counter && board[6, 5] == counter && board[6, 6] == counter && board[6, 7] == counter) ||
         (board[7, 1] == counter && board[7, 2] == counter && board[7, 3] == counter && board[7, 4] == counter && board[7, 5] == counter) ||
         (board[7, 2] == counter && board[7, 3] == counter && board[7, 4] == counter && board[7, 5] == counter && board[7, 6] == counter) ||
         (board[7, 3] == counter && board[7, 4] == counter && board[7, 5] == counter && board[7, 6] == counter && board[7, 7] == counter) ||
         //DIAGONAL
         (board[1, 1] == counter && board[2, 2] == counter && board[3, 3] == counter && board[4, 4] == counter && board[5, 5] == counter) ||
         (board[2, 2] == counter && board[3, 3] == counter && board[4, 4] == counter && board[5, 5] == counter && board[6, 6] == counter) ||
         (board[3, 3] == counter && board[4, 4] == counter && board[5, 5] == counter && board[6, 6] == counter && board[7, 7] == counter))
     {
         return(true);
     }
     // Win at position (x,y), position (x,y), position(x,y)
     else
     {
         Two(board, counter);
     }
     return(false);
 }
Exemple #5
0
        // SPECIFY DIRECTION
        public int GetNumForDir(int startSq, int dir, GameBoard_SYSTST <counters> board, counters us)
        {
            int found = 0;

            while (board[startSq, startSq] != counters.BORDER)
            { // while start sq not border sq
                if (board[startSq, startSq] != us)
                {
                    break;
                }
                found++;
                startSq += dir;
            }
            return(found);
        }
 // DETERMINE IF PLAYER HAS ONE
 public bool One(GameBoard_SYSTST <counters> board, counters counter)
 {
     if (
         //HORIZONTAL
         (board[1, 1] == counter) ||
         (board[1, 2] == counter) ||
         (board[1, 3] == counter) ||
         (board[1, 4] == counter) ||
         (board[1, 5] == counter) ||
         (board[1, 6] == counter) ||
         (board[1, 7] == counter) ||
         (board[2, 1] == counter) ||
         (board[2, 2] == counter) ||
         (board[2, 3] == counter) ||
         (board[2, 4] == counter) ||
         (board[2, 5] == counter) ||
         (board[2, 6] == counter) ||
         (board[2, 7] == counter) ||
         (board[3, 1] == counter) ||
         (board[3, 2] == counter) ||
         (board[3, 3] == counter) ||
         (board[3, 4] == counter) ||
         (board[3, 5] == counter) ||
         (board[3, 6] == counter) ||
         (board[3, 7] == counter) ||
         (board[4, 1] == counter) ||
         (board[4, 2] == counter) ||
         (board[4, 3] == counter) ||
         (board[4, 4] == counter) ||
         (board[4, 5] == counter) ||
         (board[4, 6] == counter) ||
         (board[4, 7] == counter) ||
         (board[5, 1] == counter) ||
         (board[5, 2] == counter) ||
         (board[5, 3] == counter) ||
         (board[5, 4] == counter) ||
         (board[5, 5] == counter) ||
         (board[5, 6] == counter) ||
         (board[5, 7] == counter) ||
         (board[6, 1] == counter) ||
         (board[6, 2] == counter) ||
         (board[6, 3] == counter) ||
         (board[6, 4] == counter) ||
         (board[6, 5] == counter) ||
         (board[6, 6] == counter) ||
         (board[6, 7] == counter) ||
         (board[7, 1] == counter) ||
         (board[7, 2] == counter) ||
         (board[7, 3] == counter) ||
         (board[7, 4] == counter) ||
         (board[7, 5] == counter) ||
         (board[7, 6] == counter) ||
         (board[7, 7] == counter))
     {
         return(true);
     }
     // One at position (x,y), position (x,y), position(x,y)
     else
     {
         return(false);
     }
 }
 /*
  * ----------------------------------------------------------------------------------------------------------------
  * GetMove -
  * --------------------------------------------------------------------------------------------------------------------------
  * Takes user for x,y coords from Minimax for next move and then return a tuple containing the x,y coordinate position and then
  * places current counter in that coordinate position.
  * --------------------------------------------------------------------------------------------------------------------------
  */
 public abstract Tuple <int, int> GetMove(GameBoard_TPL <counters> board, counters counter, GameBoard_TPL <int> scoreBoard);
Exemple #8
0
 public HumanPlayer_SYSTST(string _name, counters _counter) : base(_counter)
 {
     name = _name;
 }
        // MINIMAX FUNCTION
        public Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> > Minimax(GameBoard <counters> board, counters counter, int ply, Tuple <int, int> positions, bool mmax, GameBoard <int> scoreBoard, ref int cont, int alpha, int beta)
        {
            // decs
            counters us       = Flip(counter);
            int      ourindex = 1;
            List <Tuple <int, int> > availableMoves = getAvailableMoves(board, positions);
            // create new list of Tuple<int,int>
            List <Tuple <int, Tuple <int, int> > > result_list = new List <Tuple <int, Tuple <int, int> > >();
            int bestScore         = mmax ? -1001 : 1001;
            int score             = Consts.MIN_SCORE; // current score of move
            Tuple <int, int> Move = new Tuple <int, int>(0, 0);

            Tuple <int, int> bestMove = new Tuple <int, int>(1, 1); // best move with score// THRESHOLD <=============
                                                                    // add assertion here
                                                                    // decs for random move
            Random           rnd       = new Random();
            int              randMoveX = rnd.Next(1, 7);            // creates a number between 1 and 7
            int              randMoveY = rnd.Next(1, 7);            // creates a number between 1 and 7
            Tuple <int, int> randMove  = new Tuple <int, int>(randMoveX, randMoveY);

            // check win
            if (availableMoves.Count == 0)
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(10, positions, board, scoreBoard));
            }
            else if (Win(board, counter))
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(1000, positions, board, scoreBoard));
            }
            else if (Win(board, this.otherCounter))
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(-1000, positions, board, scoreBoard));
            }

            if (FindTwoInARow(board, counter) && Two(board, counter) && board[Move.Item1, Move.Item2] == counters.EMPTY)
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(100, positions, board, scoreBoard));
            }
            else if (FindTwoInARow(board, this.otherCounter) && Two(board, this.otherCounter) && board[Move.Item1, Move.Item2] == counters.EMPTY)
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(-100, positions, board, scoreBoard));
            }
            else if (FindOneInARow(board, ourindex, this.otherCounter) && One(board, counter) && board[Move.Item1, Move.Item2] == counters.EMPTY)
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(100, positions, board, scoreBoard));
            }
            else if (FindOneInARow(board, ourindex, this.otherCounter) && One(board, this.otherCounter) && board[Move.Item1, Move.Item2] == counters.EMPTY)
            {
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(-100, positions, board, scoreBoard));
            }

            // CHECK DEPTH
            else if (ply > maxPly)
            {
                score = EvalCurrentBoard(board, scoreBoard, ourindex, us); // call stat evaluation func - takes board and player and gives score to that player
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(score, positions, board, scoreBoard));
            }
            // Console.WriteLine("HWL: Is this line reached?");
            // Console.ReadLine(); // HWL: even with a ReadLine here, the program runs to the end
            // place random move
            if (board.IsEmpty()) // if board is empty then play random move
            {
                // decide scoring for random move
                score = EvalForWin(board, ourindex, us);    // 1 for win, 0 for unknown
                // assign two score
                if (FindTwoInARow(board, us))               // player win?
                {
                    score = 100;                            // twoinrow confirmed
                }
                if (FindTwoInARow(board, us + 1))           // twoinrow opponent?
                {
                    score = -100;                           // twoinrow confirmed
                }
                if (FindOneInARow(board, ourindex, us))     // oneinrow?
                {
                    score = 10;                             // oneinrow confirmed
                }
                if (FindOneInARow(board, ourindex, us + 1)) // oneinarow opponent?
                {
                    score = -10;                            // oneinrow confirmed
                }
                // MakeRandomMove(board, counter, ply, positions, !mmax, scoreBoard, ref cont);

                //  Console.ReadLine();
                return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(score, positions, board, scoreBoard));
            }
            GameBoard <counters> copy;

            // make copy original board
            copy = board.Clone();     // make copy board
                                      // copy.DisplayBoard(); // display copy board
                                      // cell priority - favour centre and corners
            for (int i = 0; i < availableMoves.Count; i++)
            {
                Move = availableMoves[i];               // current move
                                                        // cell priority - favour centre and corners
                                                        // HWL: where do you actual place the piece for the position in Move? you don't do this here, just pass Move to the call of Minimax below; in the recursive call you then overwrite the input argument with a random move (see comment at start of Minimax; so you are actually not considering Move at all!
                                                        // HWL: try placing the piece here, and below just use the score
                copy[Move.Item1, Move.Item2] = counter; // place counter
                                                        // GameBoard board0 = MakeMove(board, move); // copies board - parallel ready

                // ************************************************************************************************
                // ************************************************************************************************
                // ************************************** MAIN MINIMAX WORK ***************************************
                // ************************************************************************************************
                // ************************************************************************************************

                // list defined in Minimax declarations
                Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> > result = Minimax(copy, Flip(counter), ply + 1, Move, !mmax, scoreBoard, ref cont, alpha, beta); /* swap player */ // RECURSIVE call

                // trying to prevent preventing cell overwrite
                copy[Move.Item1, Move.Item2] = counters.EMPTY; /*  counter; */ // HWL: remove counter that was tried in this iteration
                                                                               // GameBoard board0 = MakeMove(board, move); // copies board - parallel ready

                score     = -result.Item1;                                     // assign score
                positions = result.Item2;                                      // present position (x,y)

                // list of all result - list of possible result Tuple<int, int>
                result_list.Add(new Tuple <int, Tuple <int, int> >(score, positions));

                // assign score to correct cell in score
                scoreBoard[result.Item2.Item1, result.Item2.Item2] = score;
                // HWL: summarise the result of having tried Move, print the assoc scoreboard and check that the matching move is the one for the highest score on the board

                /*    Console.WriteLine(mmax.ToString() +
                 * " **HWL (ply={0}) Trying Move ({4},{5}) gives score {1} and position ({2},{3})  [[so far bestScore={6}, bestMove=({7},{8})",
                 *    ply, score, result.Item2.Item1, result.Item2.Item2, Move.Item1, Move.Item2,
                 *    bestScore, bestMove.Item1, bestMove.Item2);
                 */
                //   scoreBoard.DisplayBoard();
                if (score == Consts.MIN_SCORE || score == Consts.MAX_SCORE)
                {
                    /*   Console.WriteLine("**HWL CLAIM: putting piece {0} at position ({1},{2}) gives 3-in-a-row:",
                     *       counter, Move.Item1, Move.Item2);
                     */
                }

                // ************************************************************************************************
                // ************************************************************************************************
                // ******************************** END OF MAIN MINIMAX WORK **************************************
                // ************************************************************************************************
                // ************************************************************************************************

                // ************************************************************************************************
                // ************************* WHEN TO MAXIMISE, WHEN TO MINIMISE ***********************************
                // ******************************* WITH ALPHA-BETA PRUNING ****************************************
                // ************************************************************************************************
                // ************************************************************************************************

                // if maximising
                if (/* true HWL || */ mmax)
                {
                    alpha = score;
                    if (score > bestScore)
                    {
                        bestMove  = Move;
                        bestScore = score;
                    }
                    if (alpha > bestScore)
                    {
                        bestMove  = Move;
                        bestScore = alpha;
                    }
                }
                // if minimising
                else
                {
                    if (bestScore > score)
                    {
                        bestMove  = Move;
                        bestScore = score;
                    }
                    if (beta <= alpha)
                    {
                        bestScore = alpha;
                    }

                    return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(bestScore, positions, board, scoreBoard));
                }

                // ************************************************************************************************
                // ************************************************************************************************
                // ********************* END OF WHEN TO MAXIMISE, WHEN TO MINIMISE ********************************
                // ******************************* WITH ALPHA-BETA PRUNING ****************************************
                // ************************************************************************************************



                cont++;                                                                                                                // increment positions visited
            }
            return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(bestScore, bestMove, board, scoreBoard)); // return
        }
        public Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> > MakeRandomMove(GameBoard <counters> board, counters counter, int ply, Tuple <int, int> positions, bool mmax, GameBoard <int> scoreBoard, ref int cont)
        {
            List <Tuple <int, int> > availableMoves = getAvailableMoves(board, positions);
            Tuple <int, int>         Move           = new Tuple <int, int>(0, 0);
            Random           rnd       = new Random();
            int              randMoveX = rnd.Next(1, 7);   // creates a number between 1 and 7
            int              randMoveY = rnd.Next(1, 7);   // creates a number between 1 and 7
            Tuple <int, int> randMove  = new Tuple <int, int>(randMoveX, randMoveY);
            int              score     = Consts.MIN_SCORE; // current score of move
            counters         us        = Flip(counter);
            int              ourindex  = 1;
            // Create new stopwatch.
            Stopwatch stopwatch = new Stopwatch();

            // Begin timing.
            stopwatch.Start();
            Move      = randMove;
            positions = randMove; // HWL: NB: this overwrites the arg positions; which means you are actually not considering the move in positions, but a different, random move; this probably explains why you get such strange moves in your gameplay
            board.DisplayBoard();
            //cont = 1;
            if (ply > 0)
            {
                score = EvalCurrentBoard(board, scoreBoard, ourindex, us);  // is current pos a win?
            }
            // Stop timing.
            stopwatch.Stop();
            Console.WriteLine("========================================================================================================================" +
                              "RANDOMLY SELECTED MOVE:" + Environment.NewLine + "------------------------------------------------------------------------------------------------------------------------" +
                              "position: " + positions + "; " +
                              "for player: " + counter + "; " +
                              "score: " + score + "; " +
                              "positions visited " + cont + "; " +
                              "depth level: " + ply + Environment.NewLine +
                              "elapsed time for move: " + stopwatch.Elapsed + "; " +
                              "no. of remaining moves left: " + availableMoves.Count + Environment.NewLine +
                              "two in a row detected at: " + "Cell 1: " + IsLeftofTwo(board, counter) + ", " + "Cell 2: " + IsRightofTwo(board, counter)
                              + Environment.NewLine +
                              "build on two-in-row? " + "left: " + board.IsTwoLeftNeighbourEmpty(board, counter) + " at position " + board.PrintTwoLeftNeighbour(board, counter) +
                              ", right: " + board.IsTwoRightNeighbourEmpty(board, counter) + " at position " + board.PrintTwoRightNeighbour(board, counter) + Environment.NewLine +
                              "top: " + board.IsTwoTopNeighbourEmpty(board, counter) + " at position " + board.PrintTwoTopNeighbour(board, counter) +
                              ", bottom: " + board.IsTwoBottomNeighbourEmpty(board, counter) + " at position " + board.PrintTwoBottomNeighbour(board, counter) + Environment.NewLine
                              + "build on one-in-row? " + "left: " + board.IsOneLeftNeighbourEmpty(board, counter) + " at position " + board.PrintOneLeftNeighbour(board, counter) +
                              ", right: " + board.IsOneRightNeighbourEmpty(board, counter) + " at position " + board.PrintOneRightNeighbour(board, counter) + Environment.NewLine +
                              "top: " + board.IsOneTopNeighbourEmpty(board, counter) + " at position " + board.PrintOneTopNeighbour(board, counter) +
                              ", bottom: " + board.IsOneBottomNeighbourEmpty(board, counter) + " at position " + board.PrintOneBottomNeighbour(board, counter) + Environment.NewLine +
                              "build on two-in-row?:" + " with horzi gap? " + board.IsTwoWithHorziGapEmpty(board, counter) + " at position " + board.PrintTwoWithHorziGap(board, counter) +
                              ", with vertical gap?: " + board.IsTwoWithVerticalGapEmpty(board, counter) + " at position " + board.PrintTwoWithVerticalGap(board, counter));
            Console.WriteLine("========================================================================================================================");
            // Console.ReadLine();
            // assign score to correct cell in score
            scoreBoard[randMoveX, randMoveY] = score;
            // RandScoringSummary(board, scoreBoard);
            //  scoreBoard.DisplayBoard();
            // Console.ReadLine();
            return(new Tuple <int, Tuple <int, int>, GameBoard <counters>, GameBoard <int> >(score, positions, board, scoreBoard));
        }
        // STATIC EVALUATION FUNCTION
        public int EvalCurrentBoard(GameBoard <counters> board, GameBoard <int> scoreBoard, int ourindex, counters us)
        {
            // score decs
            int score     = 10;
            int two_score = 10;
            int one_score = 10;

            // assign
            score = EvalForWin(board, ourindex, us); // 1 for win, 0 for unknown
            // assign two score
            if (FindTwoInARow(board, us))            // player win?
            {
                score = 100;                         // twoinrow confirmed
            }
            two_score = 100;
            if (FindTwoInARow(board, us + 1)) // twoinrow opponent?
            {
                score = -100;                 // twoinrow confirmed
            }
            two_score = -100;
            // one score
            if (FindOneInARow(board, ourindex, us)) // oneinrow?
            {
                score = 10;                         // oneinrow confirmed
            }
            one_score = 10;
            if (FindOneInARow(board, ourindex, us + 1)) // oneinarow opponent?
            {
                score = -10;                            // oneinrow confirmed
            }
            one_score = -10;

            // ************************************************************************************************
            // ************************************************************************************************
            // ******** ASSIGN MORE WEIGHT TO INDIVIDUAL CELLS WITH MORE PROMINENT POSITIONING TO BUILD ON ****
            // ************************************************************************************************
            // ************************************************************************************************

            // assign more weight to score with individual cell moves with prominent positioning
            if (board.IsMiddleEmpty() == true & FindTwoInARow(board, us))
            {
                score = 100;
                // player win?
                board[4, 4] = counter;
                if (board[4, 4] == counter)
                {
                    return(score = 125); // player win confirmed
                }
                return(score = 10);
            }
            // assign more weight to score with individual cell moves with prominent positioning
            if (board.IsMiddleEmpty() == true & FindTwoInARow(board, us))
            {
                score = 100;
                // player win?
                board[4, 4] = counter;
                if (board[4, 4] == counter)
                {
                    // assign score to correct cell in score
                    scoreBoard[4, 4] = score;
                    return(score = 125); // player win confirmed
                }
                return(score = 10);
            }
            else if (board.IsMiddleEmpty() == true & FindTwoInARow(board, us + 1))
            {
                score = -100;
                // player win?
                board[4, 4] = counter;
                if (board[4, 4] == counter)
                {
                    // assign score to correct cell in score
                    scoreBoard[4, 4] = score;
                    return(score = -125); // opponent win confirmed
                }
                return(score = 10);
            }
            if (board.IsTopLeftEmpty() == true & FindTwoInARow(board, us))
            {
                score = 100;
                // player win?
                board[1, 1] = counter;
                if (board[1, 1] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[1, 1] = score;
                    return(score = 115); // player win confirmed
                }
                return(score = 10);
            }
            else if (board.IsTopLeftEmpty() == true & FindTwoInARow(board, us + 1))
            {
                score = -100;
                // player win?
                board[1, 1] = counter;
                if (board[1, 1] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[1, 1] = score;
                    return(score = -115); // opponent win confirmed
                }
                return(score = 10);
            }
            if (board.IsTopRightEmpty() == true & FindTwoInARow(board, us))
            {
                score = 100;
                // player win?
                board[7, 1] = counter;
                if (board[7, 1] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[7, 1] = score;
                    return(score = 115); // player win confirmed
                }
                return(score = 10);
            }
            else if (board.IsTopRightEmpty() == true & FindTwoInARow(board, us + 1))
            {
                score = -100;
                // player win?
                board[7, 1] = counter;
                if (board[7, 1] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[7, 1] = score;
                    return(score = -115); // opponent win confirmed
                }
                return(score = 10);
            }
            if (board.IsBottomLeftEmpty() == true & FindTwoInARow(board, us))
            {
                score = 100;
                // player win?
                board[1, 7] = counter;
                if (board[1, 7] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[1, 7] = score;
                    return(score = 115); // player win confirmed
                }
                return(score = 10);
            }
            else if (board.IsBottomLeftEmpty() == true & FindTwoInARow(board, us + 1))
            {
                score = -100;
                // player win?
                board[1, 7] = counter;
                if (board[1, 7] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[1, 7] = score;
                    return(score = -115); // opponent win confirmed
                }
                return(score = 10);
            }
            if (board.IsBottomRightEmpty() == true & FindTwoInARow(board, us))
            {
                score = 100;
                // player win?
                board[7, 7] = counter;
                if (board[7, 7] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[7, 7] = score;
                    return(score = 115);
                }
                return(score = 10);
            }
            else if (board.IsBottomRightEmpty() == true & FindTwoInARow(board, us + 1))
            {
                two_score = -100;
                // player win?
                board[7, 7] = counter;
                if (board[7, 7] == counters.EMPTY)
                {
                    // assign score to correct cell in score
                    scoreBoard[7, 7] = score;
                    return(score = -115); // opponent win confirmed
                }
            }
            // ************************************************************************************************
            // ************************************************************************************************
            // ** END OF ASSIGN MORE WEIGHT TO INDIVIDUAL CELLS WITH MORE PROMINENT POSITIONING TO BUILD ON **
            // ************************************************************************************************
            // ************************************************************************************************

            // ************************************************************************************************
            // ************************************************************************************************
            // ************************* ASSIGNING LESSER VALUE TO EDGES ***********************************
            // ************************************************************************************************
            // ************************************************************************************************

            // ************************************************************************************************
            // ************************************************************************************************
            // ************************* END OF ASSIGNING LESSER VALUE TO EDGES *******************************
            // ************************************************************************************************
            // ************************************************************************************************

            /*  // if one in a row, if two in a row found, three in a row found etc....
             * if (score == -1000 || score == 1000)
             * {
             *    board.DisplayBoard();
             *    //         Console.Write("three: " + score);
             *    //  Console.ReadLine();
             *
             *    return score * Consts.MAX_SCORE;
             * }
             */
            if (two_score != 0)
            {
                // board.DisplayBoard();
                //       Console.Write("two: " + two_score);
                //Console.ReadLine();
                return(two_score);
            }
            if (one_score != 0)
            {
                //board.DisplayBoard();
                //       Console.Write("one: " + one_score);
                return(one_score);
            }
            else
            {
                return(score = 10);
            }
        }
 public static int cont            = 0; // counter for number of nodes visited
 public AIPlayer(counters _counter) : base(_counter)
 {
 }