예제 #1
0
        public void AddToHistory(List <Case> currentGameTable)
        {
            Generation newGenInHistory = new Generation()
            {
                Id = GenerationId, GameTable = currentGameTable
            };

            GenerationsHistory.Enqueue(newGenInHistory);

            if (GenerationsHistory.Count == MaxHistoryCount + 1)
            {
                GenerationsHistory.Dequeue();
            }
        }
예제 #2
0
        public bool CheckIfGenerationStucked(int maxHistoryCount)
        {
            int isSameCounter = 0;

            if (GenerationsHistory.Count == maxHistoryCount)
            {
                int         index             = 0;
                List <Case> previousGameTable = null;

                foreach (List <Case> currentGameTable in GenerationsHistory.Select(x => x.GameTable).ToList())
                {
                    if (previousGameTable != null && currentGameTable.SequenceEqual(previousGameTable, new CaseComparer()))
                    {
                        isSameCounter++;
                    }

                    index++;
                    previousGameTable = new List <Case>(currentGameTable);
                }
            }

            return(isSameCounter == maxHistoryCount - 1);
        }