コード例 #1
0
        // PRIVATE METHODS
        private PlayerStep checkIfSuitablePlayerStepSavedInList(PlayerStep i_PlayerStep)
        {
            int        suitablePlayerStepIndex = 0;
            bool       isPlayerStepFound       = false;
            PlayerStep stepPlayerToReturn;

            for (int i = 0; i < this.r_ArtificialPlayerStepMemoryList.Count; i++)
            {
                if (!i_PlayerStep.Equals(this.r_ArtificialPlayerStepMemoryList[i]))
                {
                    if (CheckCardMatch(i_PlayerStep, this.r_ArtificialPlayerStepMemoryList[i]))
                    {
                        suitablePlayerStepIndex = i;
                        isPlayerStepFound       = true;
                        break;
                    }
                }
            }

            if (isPlayerStepFound)
            {
                stepPlayerToReturn = this.r_ArtificialPlayerStepMemoryList[suitablePlayerStepIndex];
                this.r_ArtificialPlayerStepMemoryList.RemoveAt(suitablePlayerStepIndex);
            }
            else
            {
                stepPlayerToReturn = GetRandomMachineStep();
            }

            return(stepPlayerToReturn);
        }
コード例 #2
0
 public void SaveMachineStepInList(PlayerStep i_PlayerStep)
 {
     if (checkIfCurrentPlayerStepIsNotInList(i_PlayerStep))
     {
         this.r_ArtificialPlayerStepMemoryList.Add(i_PlayerStep);
     }
 }
コード例 #3
0
        public bool CheckCardMatch(PlayerStep i_FirstStep, PlayerStep i_SecondStep)
        {
            char firstCardSymbol, secondCardSymbol;

            firstCardSymbol  = GetSymbol(i_FirstStep.RowIndex, i_FirstStep.ColumnIndex);
            secondCardSymbol = GetSymbol(i_SecondStep.RowIndex, i_SecondStep.ColumnIndex);

            return(firstCardSymbol == secondCardSymbol);
        }
コード例 #4
0
        private bool checkIfCurrentPlayerStepIsNotInList(PlayerStep i_PlayerStepToCheck)
        {
            bool resultToReturn = true;

            for (int i = 0; i < this.r_ArtificialPlayerStepMemoryList.Count; i++)
            {
                if (i_PlayerStepToCheck.Equals(this.r_ArtificialPlayerStepMemoryList[i]))
                {
                    resultToReturn = false;
                }
            }

            return(resultToReturn);
        }
コード例 #5
0
        public PlayerStep GetRandomMachineStep()
        {
            int rowIndex, columnIndex, randomNum;

            this.r_RandomPlacementList.Clear();
            for (int i = 0; i < m_Height; i++)
            {
                for (int n = 0; n < m_Width; n++)
                {
                    if (!this.m_MemoryBoard[i, n].IsShown)
                    {
                        this.r_RandomPlacementList.Add((i * this.m_Width) + n);
                    }
                }
            }

            randomNum = this.m_randomNumGenerator.Next(0, this.r_RandomPlacementList.Count);
            convertRandomNumToMatrixIndexes(this.r_RandomPlacementList[randomNum], out rowIndex, out columnIndex);
            PlayerStep machinePlayerStep = new PlayerStep(rowIndex, columnIndex);

            return(machinePlayerStep);
        }
コード例 #6
0
        public PlayerStep GetMachineSecondStep(PlayerStep i_MachineFirstStep)
        {
            PlayerStep currentMachineStep = checkIfSuitablePlayerStepSavedInList(i_MachineFirstStep);

            return(currentMachineStep);
        }
コード例 #7
0
        public void SwitchCardStatus(PlayerStep i_PlayerStep)
        {
            bool currentCardStatus = this.m_MemoryBoard[i_PlayerStep.RowIndex, i_PlayerStep.ColumnIndex].IsShown;

            this.m_MemoryBoard[i_PlayerStep.RowIndex, i_PlayerStep.ColumnIndex].IsShown = !currentCardStatus;
        }