Esempio n. 1
0
        private Intent GetBestIntent(TicTacTardStateWithAction action)
        {
            float  maxValue = -1;
            Intent intent   = action.intent;

            TicTacTardPlayer fakePlayer = new TicTacTardPlayer(2, "1");

            for (int i = 5; i < 14; ++i)
            {
                Intent tempIntent = (Intent)i;

                if (TicTacTardGame.CanPlayIntent(action, tempIntent))
                {
                    TicTacTardState nextState = TicTacTardGame.PlayAction(action, fakePlayer, tempIntent, false);

                    TicTacTardState calculatedState = ticTacTardStateWithActions.Find(state => state.IsSameState(nextState));

                    if (calculatedState != null && calculatedState.value > maxValue)
                    {
                        maxValue = calculatedState.value;
                        intent   = tempIntent;
                    }
                }
            }

            return(intent);
        }
Esempio n. 2
0
        public override Intent GetPlayerIntent(int currentX, int currentY)
        {
            TicTacTardState state = TicTacTardGame.currentState;

            Intent intent = TicTacTardGame.GetRandomPossibleMove(state);

            foreach (TicTacTardStateWithAction action in ticTacTardStateWithActions)
            {
                if (action.IsSameState(state) && TicTacTardGame.CanPlayIntent(state, action.intent))
                {
                    Debug.Log("Found intent !");
                    intent = action.intent;
                    break;
                }
            }

            return(intent);
        }