示例#1
0
        public Choice GetSecondChoice()
        {
            Choice result = null;

            if (m_SecondChoice != null)
            {
                result = new Choice(m_SecondChoice);
            }
            else
            {
                if (m_FirstChoice != null)
                {
                    if (r_ActiveCellsMemory.ContainsKey(m_FirstChoice.Letter))
                    {
                        result = new Choice(r_ActiveCellsMemory[m_FirstChoice.Letter][0]);
                    }
                }
                else
                {
                    result = getEducatedGuess();
                }
            }

            m_FirstChoice = null;
            m_SecondChoice = null;

            return result;
        }
示例#2
0
        public Choice GetFirstChoice()
        {
            m_FirstChoice = m_SecondChoice = null;
            Choice result;

            if (knowsAboutPairPosition())
            {
                result = new Choice(m_FirstChoice);
            }
            else
            {
                result = getEducatedGuess();
                m_SecondChoice = null;
            }

            return result;
        }
示例#3
0
        private Choice getEducatedGuess()
        {
            Choice retChoice = null;
            var possibleChoices = new List<Choice>();

            for (int i = 0; i < r_BoardLines; ++i)
            {
                for (int j = 0; j < r_BoardCols; ++j)
                {
                    if (!isCellAlreadyVisibleOnBoard(i, j) && !isInActiveMemory(i, j))
                    {
                        possibleChoices.Add(new Choice(i, j));
                    }
                }
            }

            var random = new Random();
            if (possibleChoices.Count >= 1)
            {
                retChoice = possibleChoices[random.Next(0, possibleChoices.Count - 1)];
            }
            else if (possibleChoices.Count == 0)
            {
                bool breakOuterLoop = false;

                for (int i = 0; i < r_BoardLines && !breakOuterLoop; ++i)
                {
                    for (int j = 0; j < r_BoardCols; ++j)
                    {
                        if (!isCellAlreadyVisibleOnBoard(i, j))
                        {
                            retChoice = new Choice(i, j);
                            breakOuterLoop = true;
                            break;
                        }
                    }
                }
            }

            return retChoice;
        }