Пример #1
0
 public void OnPlayersMove(int segID)
 {
     curStateMask &= segmentProhibitMask[segID];
     if (curStateMask.Equals(Bitmask128.Zero))
     {
         StatusChanged?.Invoke(GameStatus.Win);
         return;
     }
     StatusChanged?.Invoke(GameStatus.BotsTurn);
     DelayAction(MakeBotMove, BotThinkingDuration);
 }
Пример #2
0
        void MakeBotMove()
        {
            float      minProb = 2;
            List <int> segIDs  = new List <int>();

            for (int i = 0; i < fieldData.segmentsCnt; ++i)
            {
                if (!curStateMask[i])
                {
                    continue;
                }
                Bitmask128 nxt     = curStateMask & segmentProhibitMask[i];
                float      curProb = statePredictions[nxt][BotDepth];
                if (curProb < minProb)
                {
                    segIDs.Clear();
                    minProb = curProb;
                }
                if (Math.Abs(curProb - minProb) < float.Epsilon)
                {
                    segIDs.Add(i);
                }
            }
            int chosenSegID = segIDs[random.Next(segIDs.Count)];

            BotMoved?.Invoke(chosenSegID);
            curStateMask &= segmentProhibitMask[chosenSegID];
            GameStatus nextStatus;

            if (curStateMask.Equals(Bitmask128.Zero))
            {
                nextStatus = GameStatus.Lose;
            }
            else
            {
                nextStatus = GameStatus.PlayersTurn;
            }
            DelayAction(() => StatusChanged?.Invoke(nextStatus), BotMovingDuration);
        }