Esempio n. 1
0
        public void PickPair(ModelBoard i_DataBoard, Position io_FirstChoicePosition, Position io_SecondChoicePosition)
        {
            char signValue;

            // copmputer AI algoritem to pick pair of squares:
            if (ChoosePairFromMemory(io_FirstChoicePosition, io_SecondChoicePosition))
            {
                m_BoardMemory[io_FirstChoicePosition.Row, io_FirstChoicePosition.Col].IsTaken   = true;
                m_BoardMemory[io_SecondChoicePosition.Row, io_SecondChoicePosition.Col].IsTaken = true;
            }
            else
            {
                PickSquare(io_FirstChoicePosition);                                                     // select first square in a naive way.
                signValue = i_DataBoard.GetSignFromCompleteBoard(io_FirstChoicePosition);               // gets the sign value from the complete board
                m_BoardMemory[io_FirstChoicePosition.Row, io_FirstChoicePosition.Col].Sign = signValue; // updates first naive choise sign to memory board

                if (SearchMatchInMemory(signValue, io_FirstChoicePosition, io_SecondChoicePosition))
                {
                    UpdateMemory(i_DataBoard, io_FirstChoicePosition, io_SecondChoicePosition, true);
                }
                else
                {
                    PickSquare(io_SecondChoicePosition); // select secound square in a naive way.

                    if (i_DataBoard.IsIdenticalPair(io_FirstChoicePosition, io_SecondChoicePosition))
                    {
                        UpdateMemory(i_DataBoard, io_FirstChoicePosition, io_SecondChoicePosition, true);
                    }
                    else  // failed to find a match sqaures
                    {
                        UpdateMemory(i_DataBoard, io_FirstChoicePosition, io_SecondChoicePosition, false);
                    }
                }
            }
        }
Esempio n. 2
0
        private void startRound()
        {
            int boardHeight = 0, boardWidth = 0;

            MessageOrganizer.ClearScreen();
            MessageOrganizer.HandleBoardSize(ref boardHeight, ref boardWidth);
            m_DataBoard = new ModelBoard(boardHeight, boardWidth);
        }
Esempio n. 3
0
        public void UpdateMemory(ModelBoard i_DataBoard, Position i_FirstSignPosition, Position i_SecondSignPosition, bool i_IsTaken) // updates the computer memory board
        {
            m_BoardMemory[i_FirstSignPosition.Row, i_FirstSignPosition.Col].Sign    = i_DataBoard.GetSignFromCompleteBoard(i_FirstSignPosition);
            m_BoardMemory[i_FirstSignPosition.Row, i_FirstSignPosition.Col].IsTaken = i_IsTaken;

            m_BoardMemory[i_SecondSignPosition.Row, i_SecondSignPosition.Col].Sign    = i_DataBoard.GetSignFromCompleteBoard(i_SecondSignPosition);
            m_BoardMemory[i_SecondSignPosition.Row, i_SecondSignPosition.Col].IsTaken = i_IsTaken;
        }