Exemplo n.º 1
0
        public override async void Start()
        {
            await Task.Run(() =>
            {
                ColossusScreen = WaitForColossusScreen();
                RaiseDisplayed(Screen.FromHandle(ColossusScreen.Process.MainWindowHandle));
                ColossusScreen.WaitForMove();

                while (true)
                {
                    State = "Thinking...";
                    CurrentNode.CalculateValue();
                    CurrentNode = CurrentNode.Children.MinBy(child => child.Value);
                    State       = "Playing...";
                    ColossusScreen.SendMove(CurrentNode.Move);
                    ColossusScreen.WaitForMove();
                    ColossusScreen.GetState();
                    Node nodeAfterColossusMove = null;

                    foreach (var child in CurrentNode.Children)
                    {
                        if (child.State.Player.Equals(ColossusScreen.PlayerState) && child.State.Opponent.Equals(ColossusScreen.OpponentState))
                        {
                            nodeAfterColossusMove = child;
                            break;
                        }
                    }

                    CurrentNode = nodeAfterColossusMove;
                }
            });
        }
Exemplo n.º 2
0
 public override async void Start()
 {
     await Task.Run(() =>
     {
         while (true)
         {
             IsWaitingForIteraction = false;
             IsBusy             = true;
             State              = "Searching...";
             DateTime startTime = DateTime.Now;
             int nodes          = CurrentNode.CalculateValue();
             OnExpanded();
             IsWaitingForIteraction = true;
             IsBusy = false;
             State  = $"{nodes} tree nodes were searched in time {DateTime.Now - startTime}.";
             playEvent.WaitOne();
             playEvent.Reset();
         }
     });
 }