Esempio n. 1
0
 public void StopSearching()
 {
     lock (this)
     {
         stateChanged = true;
         result       = null;
         needAim      = false;
     }
 }
Esempio n. 2
0
        private void run()
        {
            while (true)
            {
                needAimEvent.WaitOne();

                while (true)
                {
                    lock (this)
                    {
                        if (!needAim)
                        {
                            break;
                        }

                        if (stateChanged)
                        {
                            if (!searcher.Initialize(state, player))
                            {
                                result  = player.GetInitialPositionAim(state, true);
                                needAim = false;
                                break;
                            }

                            if (reset)
                            {
                                searcher.Reset();
                                reset = false;
                            }
                        }

                        stateChanged = false;
                    }

                    var aim = searcher.Search();

                    if (aim != null)
                    {
                        lock (this)
                        {
                            if (!reset)
                            {
                                result = aim;
                                if (!stateChanged)
                                {
                                    needAim = false;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void StartSearching(State state, Player player, bool reset)
        {
            lock (this)
            {
                this.state  = state.Clone(false);
                this.player = player.Clone();

                stateChanged = true;
                if (reset)
                {
                    this.reset = true;
                }
                result  = null;
                needAim = true;
                needAimEvent.Set();
            }
        }