コード例 #1
0
        protected override void Update()
        {
            if (IsTransitioning())
            {
                _transitionTimer += Time.deltaTime;
                float t = _easeFunc(_transitionTimer / _transitionDuration);

                // Fade the audio volume
                NextPlayer.Control.SetVolume(1f - t);
                CurrentPlayer.Control.SetVolume(t);

                // TODO: support going from mono to stereo
                // TODO: support videos of different aspect ratios by rendering with scaling to fit
                // This can be done by blitting twice, once for each eye
                // If the stereo mode is different for playera/b then both should be set to stereo during the transition
                // if (CurrentPlayer.m_StereoPacking == StereoPacking.TopBottom)....
                _material.SetFloat(_propT, t);
                _rt.DiscardContents();
                Graphics.Blit(CurrentPlayer.TextureProducer.GetTexture(), _rt, _material);

                // After the transition is complete, pause the previous video
                if (!_pausePreviousOnTransition && !IsTransitioning())
                {
                    if (NextPlayer != null && NextPlayer.Control.IsPlaying())
                    {
                        NextPlayer.Pause();
                    }
                }
            }

            base.Update();
        }
コード例 #2
0
        // Dog positions can be out of order; they will be sorted.
        // Returns -1 on invalid input.
        private static int EncodeState(int[] dogs, int rabbit, NextPlayer next_player)
        {
            Array.Sort(dogs);
            if (dogs[0] == dogs[1])
            {
                return(-1);
            }
            if (dogs[1] == dogs[2])
            {
                return(-1);
            }
            if (dogs[0] == rabbit)
            {
                return(-1);
            }
            if (dogs[1] == rabbit)
            {
                return(-1);
            }
            if (dogs[2] == rabbit)
            {
                return(-1);
            }
            int board_state = dogs[0] * 1331 + dogs[1] * 121 + dogs[2] * 11 + rabbit;

            return(board_state * 2 + (int)next_player);
        }
コード例 #3
0
        public void LINQTestJoin4()
        {
            var lowNums = from player in context.HOCKEY
                          join p in context.HOCKEY on player.NUMBER equals p.NUMBER + 1 into NextPlayer
                          from p2 in NextPlayer.DefaultIfEmpty()
                          orderby player.NUMBER
                          select new
            {
                Team             = player.TEAM,
                Player           = player.NAME,
                PlayerNumber     = player.NUMBER,
                NextPlayer       = p2 == null ? "<none>" : p2.NAME,
                NextPlayerNumber = p2 == null ? -1 : p2.NUMBER
            };

            int count = 0;

            Console.WriteLine("Each player with the player having the previous number:");
            foreach (var x in lowNums)
            {
                Console.WriteLine(x.Team + " " + x.Player + " (" + x.PlayerNumber + ") " + x.NextPlayer + " (" + x.NextPlayerNumber + ")");
                if (x.NextPlayerNumber != -1)
                {
                    Assert.AreEqual(x.PlayerNumber, x.NextPlayerNumber + 1);
                }
                count++;
            }
            Assert.AreEqual(tableRows, count);
        }
コード例 #4
0
ファイル: Game.cs プロジェクト: Juansero29/CSharp
        private int mIndex; //Variable to control the value of 'Index'.

        public void Play()
        {
            Player FirstPlayer = GetFirstPlayer(Players);

            Index = Array.IndexOf(Players, FirstPlayer); //Gets the index of the FirstPlayer to make him play.

            //The first player plays and is moved accordingly to his result
            Console.WriteLine("\n -- STARTING GAME -- \n");
            Console.WriteLine("\n");

            while (!IsFinished)              //While the game is not finished...
            {
                NextPlayer = Players[Index]; //The next player is the player at the Index's value.

                if (NextPlayer != null)      //If it isn't null, we make him Play and we move him.
                {
                    NextPlayer.Play();
                    board.ActivateSpace(NextPlayer, NextPlayer.CurrentSpace);
                    Index++;  //Next player is going to play
                }
                else
                {
                    Index++; //If it is null, we skip it.
                }

                if (NextPlayer != null && NextPlayer.CurrentSpace == Board.NUMBER_OF_SPACES)
                {
                    IsFinished = true; //Game is finished when NextPlayer is not null and his current space is equal to the last space avaible.
                    Console.WriteLine($"\n -- GAME FINISHED! WINNER IS {NextPlayer.Name}  -- \n");
                }

                Console.WriteLine("\n");
            }
        }
コード例 #5
0
        public void LINQTestJoin4()
        {
            using (var context = new EFCodeFirstContext())
            {
                var lowNums = from player in context.Hockey
                              join p in context.Hockey on player.Number equals p.Number + 1 into NextPlayer
                              from p2 in NextPlayer.DefaultIfEmpty()
                              orderby player.Number
                              select new
                {
                    Team             = player.Team,
                    Player           = player.Name,
                    PlayerNumber     = player.Number,
                    NextPlayer       = p2 == null ? "<none>" : p2.Name,
                    NextPlayerNumber = p2 == null ? -1 : p2.Number
                };

                int count = 0;
                Console.WriteLine("Each player with the player having the previous number:");
                foreach (var x in lowNums)
                {
                    Console.WriteLine(x.Team + " " + x.Player + " (" + x.PlayerNumber + ") " + x.NextPlayer + " (" + x.NextPlayerNumber + ")");
                    if (x.NextPlayerNumber != -1)
                    {
                        Assert.AreEqual(x.PlayerNumber, x.NextPlayerNumber + 1);
                    }
                    count++;
                }
                Assert.AreEqual(tableRows, count);
            }
        }
コード例 #6
0
 public IBoardGame <TicTacToeToken> Clone()
 {
     return(new TicTacToeGame(
                Width, Height,
                _grid.Clone(),
                CurrentPlayer.Clone(),
                NextPlayer.Clone()));
 }
コード例 #7
0
 public override int GetHashCode()
 {
     return(Width
            ^ Height
            ^ _grid.GetHashCode()
            ^ Players.Select(p => p.GetHashCode()).Aggregate((a, b) => a ^ b)
            ^ CurrentPlayer.GetHashCode()
            ^ NextPlayer.GetHashCode());
 }
コード例 #8
0
        protected override void Update()
        {
            if (IsTransitioning())
            {
                _transitionTimer += Time.deltaTime;
                float t = _easeFunc(Mathf.Clamp01(_transitionTimer / _currentTransitionDuration));

                // Fade the audio volume
                NextPlayer.Control.SetVolume(1f - t);
                CurrentPlayer.Control.SetVolume(t);

                // TODO: support going from mono to stereo
                // TODO: support videos of different aspect ratios by rendering with scaling to fit
                // This can be done by blitting twice, once for each eye
                // If the stereo mode is different for playera/b then both should be set to stereo during the transition
                // if (CurrentPlayer.m_StereoPacking == StereoPacking.TopBottom)....
                _material.SetFloat(_propT, t);
                _rt.DiscardContents();
                Graphics.Blit(GetCurrentTexture(), _rt, _material);

                // After the transition is now complete, close/pause the previous video if required
                bool isTransitioning = IsTransitioning();
                if (!isTransitioning)
                {
                    if (_autoCloseVideo)
                    {
                        if (NextPlayer != null)
                        {
                            NextPlayer.m_VideoPath = string.Empty;
                            NextPlayer.CloseVideo();
                        }
                    }
                    else if (!_pausePreviousOnTransition)
                    {
                        if (NextPlayer != null && NextPlayer.Control.IsPlaying())
                        {
                            NextPlayer.Pause();
                        }
                    }
                }
            }
            else
            {
                if (_playlistAutoProgress && _nextItem == null && _currentItem != null && _currentItem.progressMode == ProgressMode.BeforeFinish && Control != null && Control.GetCurrentTimeMs() >= (Info.GetDurationMs() - (_currentItem.progressTimeSeconds * 1000f)))
                {
                    this.NextItem();
                }
            }

            base.Update();
        }
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            if (NextPlayer.MediaPath == mediaItem.mediaPath)
            {
                isMediaAlreadyLoaded = true;
            }

            if (!mediaItem.isOverrideTransition)
            {
                SetTransition(_defaultTransition, _defaultTransitionDuration, _defaultTransitionEasing);
            }
            else
            {
                SetTransition(mediaItem.overrideTransition, mediaItem.overrideTransitionDuration, mediaItem.overrideTransitionEasing);
            }

            this.Loop              = NextPlayer.Loop = mediaItem.loop;
            NextPlayer.MediaPath   = new MediaPath(mediaItem.mediaPath);
            this.MediaPath         = new MediaPath(mediaItem.mediaPath);
            NextPlayer.AudioMuted  = _playlistAudioMuted;
            NextPlayer.AudioVolume = _playlistAudioVolume;
            if (_transitionTimer < _currentTransitionDuration && _currentTransition != Transition.None)
            {
                NextPlayer.AudioVolume = 0f;
            }

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                if (_nextItem.startMode == StartMode.Immediate)
                {
                    NextPlayer.Play();
                }
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.MediaPath.Path))
                {
                    NextPlayer.CloseMedia();
                }
                else
                {
                    NextPlayer.OpenMedia(NextPlayer.MediaPath.PathType, NextPlayer.MediaPath.Path, _nextItem.startMode == StartMode.Immediate);
                }
            }
        }
コード例 #10
0
        public void NextPlayersTurn()
        {
            List <eActionType> playerActions = new List <eActionType>(); // Stores possible player actions

            // Loop until isPlaying player who waits for turn
            do
            {
                _activePlayer = (_activePlayer + 1) % (PlayerRank.GetLength(0));
            }while (!ActivePlayer.IsPlayering && ActivePlayer.NextAction.Peek() == eActionType.WaitingForTurn);

            if (_activePlayer == 0)
            {
                this.Statistics.Lap += 1;
            }

            NextPlayer?.Invoke(ActivePlayer);

            // Should only dequeue waiting!?
            ActivePlayer.NextAction.Dequeue();

            // Find possible actions till next turn or NIL
            do
            {
                playerActions.Clear();
                do
                {
                    playerActions.Add(ActivePlayer.NextAction.Dequeue());
                }while (!(ActivePlayer.NextAction.Count == 0 || ActivePlayer.NextAction.Peek() == eActionType.WaitingForTurn));
                ActivePlayer.onDelegateControl(new DelegateEventArgs(playerActions.ToArray()));
            }while (!(ActivePlayer.NextAction.Count == 0 || ActivePlayer.NextAction.Peek() == eActionType.WaitingForTurn));

            // Enqueue next default action, isnt't needed
            if (ActivePlayer.IsPlayering)
            {
                if (ActivePlayer.NextAction.Count == 0)
                {
                    ActivePlayer.NextAction.Enqueue(eActionType.WaitingForTurn);
                    ActivePlayer.NextAction.Enqueue(eActionType.Move);
                }

                // Should notify end turn
                if (Settings.END_TURN_EVENT)
                {
                    ActivePlayer.onDelegateControl(new DelegateEventArgs(eActionType.EndTurn));
                }
            }

            ActivePlayer.DoublesCount = 0;
        }
コード例 #11
0
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            /*
             * if (NextPlayer.m_VideoPath == mediaItem.filePath && NextPlayer.m_VideoLocation == mediaItem.fileLocation)
             * {
             *      isMediaAlreadyLoaded = true;
             * }*/

            if (mediaItem.isOverrideTransition)
            {
                SetTransition(mediaItem.overrideTransition, mediaItem.overrideTransitionDuration, mediaItem.overrideTransitionEasing.preset);
            }
            else
            {
                SetTransition(_nextTransition, _transitionDuration, _transitionEasing.preset);
            }

            this.m_Loop          = NextPlayer.m_Loop = mediaItem.loop;
            this.m_AutoStart     = NextPlayer.m_AutoStart = mediaItem.autoPlay;
            this.m_VideoLocation = NextPlayer.m_VideoLocation = mediaItem.fileLocation;
            this.m_VideoPath     = NextPlayer.m_VideoPath = mediaItem.filePath;
            this.m_StereoPacking = NextPlayer.m_StereoPacking = mediaItem.stereoPacking;
            this.m_AlphaPacking  = NextPlayer.m_AlphaPacking = mediaItem.alphaPacking;

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                if (_nextItem.startMode == StartMode.Immediate)
                {
                    NextPlayer.Play();
                }
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.m_VideoPath))
                {
                    NextPlayer.CloseVideo();
                }
                else
                {
                    //NextPlayer.m_AutoStart = false;
                    NextPlayer.OpenVideoFromFile(NextPlayer.m_VideoLocation, NextPlayer.m_VideoPath, _nextItem.startMode == StartMode.Immediate);
                }
            }
        }
コード例 #12
0
        private void TellCardProperty(TellCardPropertyAction action)
        {
            var propertyName  = action.PropertyName;
            var propertyValue = action.Value;
            var cards         = action.Cards;

            foreach (var card in cards)
            {
                NextPlayer[card].CheckProperty(propertyValue);
            }

            if (NextPlayer.Count(card => card.GetProperty(propertyName).Equals(propertyValue)) != cards.Count)
            {
                throw new GameOverException($"Lie! Not full info about {propertyName}!");
            }
        }
コード例 #13
0
ファイル: Session.cs プロジェクト: aydoganf/chess-api
        private void IsCheck(IStone stone)
        {
            King king = NextPlayer.GetKing();

            if (stone.TryMove(king.Location, Table, out IStone k))
            {
                Check      = true;
                CheckStone = stone;
            }

            if (Check)
            {
                IsCheckmate(stone);
                if (Checkmate)
                {
                    Check = false;
                }
            }
        }
コード例 #14
0
        private void InitPlayers()
        {
            System.Collections.SortedList playerRankSort = new System.Collections.SortedList();
            int playerSortKey;

            // Initialize without rank
            for (var i = 0; i < PlayerRank.Length; i++)
            {
                PlayerRank[i].Initialize(this, i);
            }

            // Give every Player On dial for rank
            foreach (var p in PlayerRank)
            {
                _activePlayer = p.Index;
                NextPlayer?.Invoke(ActivePlayer);
                DiceRollResult result = p.DelegateDiceRoll();
                playerSortKey = result.DiceSum * 10;
                while (playerRankSort.ContainsKey(-playerSortKey))
                {
                    playerSortKey += 1;
                }
                playerRankSort.Add(-playerSortKey, p); // negativ for sorting
            }


            playerRankSort.Values.CopyTo(PlayerRank, 0);

            // Initialize Part 2 with rank
            for (ushort i = 0; i < PlayerRank.Length; i++)
            {
                PlayerRank[i].Index = i;
            }

            _activePlayer = -1;

            RaisePlayerRankChanged();
        }
コード例 #15
0
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            if (NextPlayer.m_VideoPath == mediaItem.filePath && NextPlayer.m_VideoLocation == mediaItem.fileLocation)
            {
                isMediaAlreadyLoaded = true;
            }

            SetTransition(_nextTransition);

            this.m_Loop          = NextPlayer.m_Loop = mediaItem.loop;
            this.m_VideoLocation = NextPlayer.m_VideoLocation = mediaItem.fileLocation;
            this.m_VideoPath     = NextPlayer.m_VideoPath = mediaItem.filePath;
            this.m_StereoPacking = NextPlayer.m_StereoPacking = mediaItem.stereoPacking;
            this.m_AlphaPacking  = NextPlayer.m_AlphaPacking = mediaItem.alphaPacking;

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                NextPlayer.Play();
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.m_VideoPath))
                {
                    NextPlayer.CloseVideo();
                }
                else
                {
                    //NextPlayer.m_AutoStart = false;
                    NextPlayer.OpenVideoFromFile(NextPlayer.m_VideoLocation, NextPlayer.m_VideoPath, true);
                }
            }
        }
コード例 #16
0
ファイル: Session.cs プロジェクト: aydoganf/chess-api
        private void IsCheckmate(IStone stone)
        {
            var king = NextPlayer.GetKing();

            // check yapan taşı yiyebilecek bir taş var mı?
            bool   checkStoneCouldEated = false;
            IStone checkStoneEater      = null;

            foreach (var nextPlayerStone in NextPlayer.Stones)
            {
                if (nextPlayerStone.TryMove(stone.Location, Table, out IStone _s))
                {
                    bool checkStoneEaterCouldMove = true;
                    // şah çeken taşı yiyebilecek olan taş bu hareketi yapabilir mi?
                    nextPlayerStone.GhostMove(stone.Location);

                    foreach (var currentPlayerStone in CurrentPlayer.Stones)
                    {
                        if (currentPlayerStone == stone)
                        {
                            // şah çeken taşı yediğini varsayıyoruz
                            continue;
                        }

                        if (currentPlayerStone.TryMove(stone.Location, Table, out IStone _k))
                        {
                            // danger
                            // nextPlayerStone could not move!!
                            checkStoneEaterCouldMove = false;
                            break;
                        }
                    }

                    nextPlayerStone.UndoGhost();

                    if (checkStoneEaterCouldMove)
                    {
                        checkStoneCouldEated = true;
                        checkStoneEater      = nextPlayerStone;
                        break;
                    }
                }
            }

            if (checkStoneCouldEated)
            {
                if (checkStoneEater is King)
                {
                    // stone'u o lokasyondan geçici olarak alalım
                    // daha sonra o lokasyona bir taş gidebilir mi ona bakalım.
                    // gidemiyorsa stone'u o laskyona geri alalım
                    stone.GhostMove(null);

                    foreach (var currentPlayerStone in CurrentPlayer.Stones)
                    {
                        if (currentPlayerStone == stone)
                        {
                            continue;
                        }

                        if (currentPlayerStone.TryMove(stone.StoredLocation, Table, out IStone _k))
                        {
                            //Checkmate = true;
                            //stone.UndoGhost();
                            //return;

                            checkStoneCouldEated = false;
                            break;
                        }
                    }

                    stone.UndoGhost();
                }

                //return;
            }


            // başka bir taş kral ile check yapan taş arasına girebilir mi?

            bool someStoneBroked = false;

            List <Location> checkLocations = stone.GetMovementLocations(king.Location, Table);

            if (checkLocations != null)
            {
                foreach (var checkLocation in checkLocations)
                {
                    foreach (var nextPlayerStone in NextPlayer.Stones)
                    {
                        if (nextPlayerStone is King)
                        {
                            continue;
                        }

                        if (nextPlayerStone.TryMove(checkLocation, Table, out IStone _s))
                        {
                            someStoneBroked = true;
                            break;
                        }
                    }

                    if (someStoneBroked)
                    {
                        break;
                    }
                }
            }


            // king kaçabilir mi?
            if (checkStoneCouldEated == false && someStoneBroked == false && king.CouldRun(Table, stone.Location) == false)
            {
                Checkmate = true;
                Check     = false;
            }
        }
コード例 #17
0
 public static void UnsubscribeAllSubscriber()
 {
     if (NextPhase != null)
     {
         System.Delegate[] delegates = NextPhase.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             NextPhase -= delegates [i] as NextPhaseEvent;
         }
     }
     if (AllowCurrentPlayerToMove != null)
     {
         System.Delegate[] delegates = AllowCurrentPlayerToMove.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             AllowCurrentPlayerToMove -= delegates [i] as AllowCurrentPlayerToMoveEvent;
         }
     }
     if (DisallowCurrentPlayerToMove != null)
     {
         System.Delegate[] delegates = DisallowCurrentPlayerToMove.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             DisallowCurrentPlayerToMove -= delegates [i] as DisallowCurrentPlayerToMoveEvent;
         }
     }
     if (AllowCurrentPlayerToFire != null)
     {
         System.Delegate[] delegates = AllowCurrentPlayerToFire.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             AllowCurrentPlayerToFire -= delegates [i] as AllowCurrentPlayerToFireEvent;
         }
     }
     if (DisallowCurrentPlayerToFire != null)
     {
         System.Delegate[] delegates = DisallowCurrentPlayerToFire.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             DisallowCurrentPlayerToFire -= delegates [i] as DisallowCurrentPlayerToFireEvent;
         }
     }
     if (NextPlayer != null)
     {
         System.Delegate[] delegates = NextPlayer.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             NextPlayer -= delegates [i] as NextPlayerEvent;
         }
     }
     if (PlayerDead != null)
     {
         System.Delegate[] delegates = PlayerDead.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             PlayerDead -= delegates [i] as PlayerDeadEvent;
         }
     }
     if (PlayerWon != null)
     {
         System.Delegate[] delegates = PlayerWon.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             PlayerWon -= delegates [i] as PlayerWonEvent;
         }
     }
     if (TimerEnd != null)
     {
         System.Delegate[] delegates = TimerEnd.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             TimerEnd -= delegates [i] as TimerEndEvent;
         }
     }
     if (PlayerCast != null)
     {
         System.Delegate[] delegates = PlayerCast.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             PlayerCast -= delegates [i] as PlayerCastEvent;
         }
     }
     if (SpellEnd != null)
     {
         System.Delegate[] delegates = SpellEnd.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             SpellEnd -= delegates [i] as SpellEndEvent;
         }
     }
     if (NextPlayerButtonClick != null)
     {
         System.Delegate[] delegates = NextPlayerButtonClick.GetInvocationList();
         for (int i = 0; i < delegates.Length; i++)
         {
             NextPlayerButtonClick -= delegates [i] as NextPlayerButtonClickEvent;
         }
     }
 }
コード例 #18
0
 public void CloseVideoExt()
 {
     NextPlayer.CloseVideo();
     CurrentPlayer.CloseVideo();
 }
コード例 #19
0
        public State(int id)
        {
            this.id          = id;
            prev_states      = new List <int>();
            next_states      = new List <int>();
            expected_outcome = Outcome.Undecided;

            // Decode ID.
            next_player = (NextPlayer)(id % 2);
            int board_state = id / 2;

            cells = new CellContent[9];
            for (int i = 8; i >= 0; i--)
            {
                cells[i]     = (CellContent)(board_state % 3);
                board_state /= 3;
            }

            // Is there an outcome?
            outcome = Outcome.Undecided;
            int[] lines = { 12, 345, 678, 36, 147, 258, 48, 246 };
            foreach (int line in lines)
            {
                int pos_0 = line / 100;
                int pos_1 = (line % 100) / 10;
                int pos_2 = line % 10;
                if (cells[pos_0] == CellContent.O && cells[pos_1] == CellContent.O && cells[pos_2] == CellContent.O)
                {
                    outcome = Outcome.OWins;
                    break;
                }
                if (cells[pos_0] == CellContent.X && cells[pos_1] == CellContent.X && cells[pos_2] == CellContent.X)
                {
                    outcome = Outcome.XWins;
                    break;
                }
            }
            if (outcome == Outcome.Undecided)
            {
                bool any_cell_empty = false;
                foreach (CellContent c in cells)
                {
                    if (c == CellContent.Empty)
                    {
                        any_cell_empty = true;
                        break;
                    }
                }
                if (!any_cell_empty)
                {
                    outcome = Outcome.Draw;
                }
            }

            // PS. Some boards are impossible, such as ones with multiple lines of Os and Xs.
            // However, boards with an outcome have no next states, so these impossible
            // states should be isolated from the game tree.
            // Thus there's no need to handle them.

            // If no outcome, find next states.
            // Previous states will be filled by the Solver class.
            if (outcome != Outcome.Undecided)
            {
                expected_outcome = outcome;
                return;
            }
            CellContent next_cell        = (next_player == NextPlayer.O) ? CellContent.O : CellContent.X;
            NextPlayer  next_next_player = (next_player == NextPlayer.O) ? NextPlayer.X : NextPlayer.O;

            board_state = id / 2;
            int delta_state = 6561;

            for (int i = 0; i < 9; i++)
            {
                if (cells[i] == CellContent.Empty)
                {
                    int next_board = board_state + (int)next_cell * delta_state;
                    next_states.Add(next_board * 2 + (int)next_next_player);
                }
                delta_state /= 3;
            }
        }
コード例 #20
0
 protected virtual void OnNextPlayer(NextPlayerEventArgs e)
 {
     NextPlayer?.Invoke(this, e);
 }