Exemplo n.º 1
0
 private static void SuccessfulPlayerMove(int square)
 {
     nextPlayer(isXsTurn);                                      //changes turn
     gameBoard[square].IsFilled = true;                         //square is filled
     boardAge++;                                                //advances age
     gameBoard[square].Age = boardAge;                          //sets age of square to current board age
     Console.WriteLine(boardAge + " " + gameBoard[square].Age); //delete
     fieldCount++;                                              //one more square is filled
     lastSquare = gameBoard[square];                            //now this is the last square that was filled
 }
Exemplo n.º 2
0
        private static void removeLowestAge()
        {
            int        lowestAge       = boardAge;   // guaranteed oldest
            GameSquare lowestAgeSquare = lastSquare; // guaranteed to be a filled square
            int        squareInt       = 0;

            for (int i = 0; i < 9; i++)                     // iterate through
            {
                if (gameBoard[i].IsFilled)                  // only check the filled squares/ignore empty squares
                {
                    if (gameBoard[i].Age < lowestAge)       // find lowest age
                    {
                        lowestAge       = gameBoard[i].Age; // update age
                        lowestAgeSquare = gameBoard[i];     // find the oldest square to remove
                        squareInt       = i;
                    }
                }
            }
            lowestAgeSquare.clearSquare();
            Console.WriteLine(squareInt);
            placeToken(squareInt, false);
        }