예제 #1
0
 public void SaveToMemory(BoardCoordinates i_BoardCoordinates)
 {
     if (!r_Memory.Contains(i_BoardCoordinates))
     {
         this.r_Memory.Insert(0, i_BoardCoordinates);
     }
 }
예제 #2
0
        public void EraseLastMoveFromBoard(BoardCoordinates i_GuessedCardCoordinates)
        {
            Card wronglyGuessedCard = this.GetCardByCoordinates(i_GuessedCardCoordinates);

            wronglyGuessedCard.Exposed = false;
            this.m_CardTemporaryExposedByPlayer.Exposed = false;
        }
예제 #3
0
        public bool GuessCard(BoardCoordinates i_BoardCoordinates)
        {
            bool guessWasCorrect = false;
            Card guessedCard     = this.GetCardByCoordinates(i_BoardCoordinates);

            guessedCard.Exposed = true;

            if (this.m_CardTemporaryExposedByPlayer.Letter == guessedCard.Letter)
            {
                this.m_NumberOfExposedPairs += 1;
                guessWasCorrect              = true;
            }

            return(guessWasCorrect);
        }
예제 #4
0
 public void ExposeCard(BoardCoordinates i_BoardCoordinates)
 {
     this.m_CardTemporaryExposedByPlayer         = this.r_GameBoard[i_BoardCoordinates.Row, i_BoardCoordinates.Column];
     this.m_CardTemporaryExposedByPlayer.Exposed = true;
 }
예제 #5
0
 public bool IsCardExposed(BoardCoordinates i_BoardCoordinates)
 {
     return(this.GetCardByCoordinates(i_BoardCoordinates).Exposed);
 }
예제 #6
0
 public Card GetCardByCoordinates(BoardCoordinates i_CardCoordinates)
 {
     return(this.r_GameBoard[i_CardCoordinates.Row, i_CardCoordinates.Column]);
 }
예제 #7
0
        public BoardCoordinates[] GetCardsForNextMove(GameBoard i_GameBoard)
        {
            List <BoardCoordinates> possibleBoardCoordinates = new List <BoardCoordinates>();
            int heightOfBoard = i_GameBoard.GetHeightOfBoard();
            int lengthOfBoard = i_GameBoard.GetLengthOfBoard();

            for (int i = 0; i < heightOfBoard; i++)
            {
                for (int j = 0; j < lengthOfBoard; j++)
                {
                    BoardCoordinates currentBoardCoordinates = new BoardCoordinates(i, j);

                    if (!possibleBoardCoordinates.Contains(currentBoardCoordinates) && !i_GameBoard.GetCardByCoordinates(currentBoardCoordinates).Exposed)
                    {
                        possibleBoardCoordinates.Add(currentBoardCoordinates);
                    }
                }
            }

            Random           rnd                      = new Random();
            int              firstCardIdx             = rnd.Next(0, possibleBoardCoordinates.Count);
            BoardCoordinates firstChoiceOfCoordinates = possibleBoardCoordinates.ElementAt(firstCardIdx);

            possibleBoardCoordinates.Remove(firstChoiceOfCoordinates);
            int secondCardIdx = rnd.Next(0, possibleBoardCoordinates.Count);
            BoardCoordinates secondChoiceOfCoordinates = possibleBoardCoordinates.ElementAt(secondCardIdx);

            ///this.r_Memory.Remove(firstChoiceBoardCoordinates);

            ////if (this.r_AiMode == eAiModes.Genius)
            ////{
            ////    bool found = false;
            ////    foreach (BoardCoordinates boardCoordinates1 in this.r_Memory)
            ////    {
            ////        if (found)
            ////        {
            ////            break;
            ////        }

            ////        foreach (BoardCoordinates boardCoordinates2 in this.r_Memory)
            ////        {
            ////            if (i_GameBoard.GetCardByCoordinates(boardCoordinates1).Letter == i_GameBoard.GetCardByCoordinates(boardCoordinates2).Letter &&
            ////                boardCoordinates1.Column != boardCoordinates2.Column && boardCoordinates1.Row != boardCoordinates2.Row)
            ////            {
            ////                secondChoiceBoardCoordinates = boardCoordinates2;
            ////                firstChoiceBoardCoordinates = boardCoordinates1;
            ////                found = true;
            ////                break;
            ////            }
            ////        }
            ////    }
            ////}
            ////else if (this.r_AiMode != eAiModes.Random && this.r_Memory.Any())
            ////{
            ////    int cardsCheckedForMatch = 0;
            ////    foreach (BoardCoordinates boardCoordinates in this.r_Memory)
            ////    {
            ////        if (cardsCheckedForMatch > this.r_MemoryDepth)
            ////        {
            ////            break;
            ////        }

            ////        if (i_GameBoard.GetCardByCoordinates(firstChoiceBoardCoordinates).Letter == i_GameBoard.GetCardByCoordinates(boardCoordinates).Letter)
            ////        {
            ////            secondChoiceBoardCoordinates = boardCoordinates;
            ////        }

            ////        cardsCheckedForMatch++;
            ////    }
            ////}

            ////this.r_Memory.Remove(secondChoiceBoardCoordinates);
            return(new[] { firstChoiceOfCoordinates, secondChoiceOfCoordinates });
        }