예제 #1
0
            public override void Execute()
            {
                PreSimulationStep();

                // signal that the game ended, just to publish signals to both players
                if (m_stepsToEnd >= 0)
                {
                    // all signals sent, new game
                    if (m_stepsToEnd == 0)
                    {
                        ResetGame();
                        PostSimulationStep(true);
                        return;
                    }
                    m_stepsToEnd--;
                    PostSimulationStep(true);
                    return;
                }

                int action = DecodeAction();

                if (!Owner.game.ApplyAction(action, m_justPlayed, Owner.m_currentState))
                {
                    Owner.GetOutput((int)m_justPlayed + 1).Host[Owner.INCORRECT_MOVE_POS] = 1;
                    PostSimulationStep(false);
                    return;
                }
                if (Owner.game.CheckWinner(m_justPlayed, Owner.m_currentState))
                {
                    m_stepsToEnd = 1;
                    Owner.GetOutput((int)m_justPlayed + 1).Host[Owner.REWARD_POS]        = 1;
                    Owner.GetOutput((int)m_justNotPlayed + 1).Host[Owner.PUNISHMENT_POS] = 1;
                    PostSimulationStep(true);
                    return;
                }

                if (MyTicTacToeGame.NoFreePlace(Owner.m_currentState))
                {
                    m_stepsToEnd = 0;
                }

                PostSimulationStep(true);
            }
예제 #2
0
            public override void Execute()
            {
                Owner.DecodeState();
                UpdateDifficulty();

                if (MyTicTacToeGame.NoFreePlace(Owner.m_currentState))
                {
                    Owner.m_selectedAction = 0;
                    Owner.EncodeAction();
                    return;
                }

                Owner.m_selectedAction = m_computer.GenerateAction(Owner.m_currentState);

                while (!Owner.game.ApplyAction(Owner.m_selectedAction, Owner.Me, Owner.m_currentState))
                {
                    Owner.m_selectedAction = m_computer.GenerateAction(Owner.m_currentState);
                }

                Owner.EncodeAction();
            }