Пример #1
0
        public int Find(string fName)
        {
            inputFile           = new BasicFile.ImplementationBuffer(fName);
            fileManager         = new HashFileManager();
            HashDataFileIndexes = new IndexData(inputFile.Length);

            swCreateHashDataFile.Restart();
            CreateHashDataFile();
            swCreateHashDataFile.Stop();


            int counter = 0;

            foreach (var node in fileManager.GetAll())
            {
                if (node.Count == 1)
                {
                    counter++;
                }
            }


            PrintDebugStatistics();

            return(counter);
        }
Пример #2
0
        /// <summary>
        /// 获取时间并重置继续
        /// </summary>
        public void LogTimeRestart(string title = null)
        {
            Sw.Stop();
            var ms = Sw.ElapsedMilliseconds;

            Log?.Invoke($"{title}{(title != null ? ": " : "")}{ms}ms", null);
            Sw.Restart();
        }
Пример #3
0
        /// <summary>
        /// 获取时间并重置继续
        /// </summary>
        public void ConsoleTimeRestart(string title = null)
        {
            Sw.Stop();
            var ms = Sw.ElapsedMilliseconds;

            Console.WriteLine($"{title}{(title != null ? ": " : "")}{ms}ms");
            Sw.Restart();
        }
Пример #4
0
        /// <summary>
        /// 获取时间并重置继续
        /// </summary>
        public long GetTimeRestart()
        {
            Sw.Stop();
            var ms = Sw.ElapsedMilliseconds;

            Sw.Restart();

            return(ms);
        }
Пример #5
0
        private void CreateHashDataFile()
        {
            int index = 0;

            while (true)
            {
                if (index == -1 || inputFile.IsEOF(index))
                {
                    break;
                }
                swReadNextString.Restart();
                var(h, i) = ReadNextString(index);
                index     = i;
                swReadNextString.Stop();

                swSaveNextHash.Restart();
                SaveNextHash(h);
                swSaveNextHash.Stop();
            }
            fileManager.Close();
        }
Пример #6
0
        private int GetPlayerMove(bool emptyMove)
        {
            if (emptyMove)
                return -1;

            if (player1Turn)
            {
                MovesOfPlayer1++;
                if (Player1 == PlayerType.Human)
                {
                    Sw.Restart();
                    int humanMove = GetHumanMove();
                    TimeSpan timeSpan = Sw.Elapsed;
                    TimesOfPlayer1.Add(timeSpan);
                    if(PrintText)
                        Console.WriteLine("Human moved: " + humanMove + "\n Time: " + timeSpan.TotalMilliseconds);
                    return humanMove;
                }
                else if (Player1 == PlayerType.Ai)
                {
                    Sw.Restart();
                    int aiMove = GetAiMove();
                    TimeSpan timeSpan = Sw.Elapsed;
                    TimesOfPlayer1.Add(timeSpan);
                    if (PrintText)
                        Console.WriteLine("Ai moved: " + aiMove + "\n Time: " + timeSpan.TotalMilliseconds);
                    return aiMove;
                }
                // Aplha-Beta
                else
                {
                    Sw.Restart();
                    int aiMove = GetAiMoveAB();
                    TimeSpan timeSpan = Sw.Elapsed;
                    TimesOfPlayer1.Add(timeSpan);
                    if (PrintText)
                        Console.WriteLine("Ai_AB moved: " + aiMove + "\n Time: " + timeSpan.TotalMilliseconds);
                    return aiMove;
                }
            }
            else
            {
                MovesOfPlayer2++;
                if (Player2 == PlayerType.Human)
                {

                    Sw.Restart();
                    int humanMove = GetHumanMove();
                    TimeSpan timeSpan = Sw.Elapsed;
                    TimesOfPlayer2.Add(timeSpan);
                    if (PrintText)
                        Console.WriteLine("Human moved: " + humanMove + "\n Time: " + timeSpan.TotalMilliseconds);
                    return humanMove;
                }
                else if (Player2 == PlayerType.Ai)
                {
                    Sw.Restart();
                    int aiMove = GetAiMove();
                    TimeSpan timeSpan = Sw.Elapsed;
                    TimesOfPlayer2.Add(timeSpan);

                    if (PrintText)
                        Console.WriteLine("Ai moved: " + aiMove + "\n Time: " + timeSpan.TotalMilliseconds);
                    return aiMove;
                }
                // Aplha-Beta
                else
                {
                    Sw.Restart();
                    int aiMove = GetAiMoveAB();
                    TimeSpan timeSpan = Sw.Elapsed;
                    TimesOfPlayer2.Add(timeSpan);

                    if (PrintText)
                        Console.WriteLine("Ai_AB moved: " + aiMove + "\n Time: " + timeSpan.TotalMilliseconds);
                    return aiMove;
                }
            }
        }