Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     this.CurrentState = GameState.PLAYING;
     this.Tester       = new StandardStateEvaluator();
     this.Text         = GameObject.FindWithTag("MainText").GetComponent <GUIText>();
     // One of the scenes is the main menu, do not count that scene as a level.
     this.NumLevels = SceneManager.sceneCountInBuildSettings - 1;
 }
Exemplo n.º 2
0
        public TicTacToeLogic(IGameStateEvaluator evaluator)
        {
            if (null == evaluator)
            {
                throw new ArgumentNullException("evaluator");
            }

            _evaluator = evaluator;
        }
Exemplo n.º 3
0
        public FourInARowLogic(IGameStateEvaluator evaluator)
        {
            if (null == evaluator)
            {
                throw new ArgumentNullException("evaluator");
            }

            _evaluator = evaluator;
        }
Exemplo n.º 4
0
        public void TestMoveEvaluation()
        {
            String[] inputA = new[]
            {
                ".x.o...",
                ".x.....",
                ".......",
                ".......",
                ".......",
                "......."
            };

            String[] inputB = new[]
            {
                "...o.x.",
                ".....x.",
                ".......",
                ".......",
                ".......",
                "......."
            };

            FourInARowState stateA = PrepareState(inputA);

            FourInARowState stateB = PrepareState(inputB);

            FourInARowFactory factory = new FourInARowFactory();

            IGameStateEvaluator evaluator = factory.CreateStateEvaluator();

            Int32 rateA = evaluator.Evaluate(stateA, GamePlayer.PlayerMax);

            Int32 rateB = evaluator.Evaluate(stateB, GamePlayer.PlayerMax);

            Assert.AreEqual(rateA, rateB);

            rateA = evaluator.Evaluate(stateA, GamePlayer.PlayerMin);

            rateB = evaluator.Evaluate(stateB, GamePlayer.PlayerMin);

            Assert.AreEqual(rateA, rateB);
        }
Exemplo n.º 5
0
        public MiniMaxWithAlfaBetaPrunningB(Int32 depth, IGameFactory gameFactory)
        {
            if (depth < 1)
            {
                throw new ArgumentOutOfRangeException("depth");
            }

            if (null == gameFactory)
            {
                throw new ArgumentNullException("gameFactory");
            }

            _depth = depth;

            _gameFactory = gameFactory;

            _gameLogic = gameFactory.CreateLogic();

            _stateEvaluator = gameFactory.CreateStateEvaluator();
        }
Exemplo n.º 6
0
        public MiniMaxAlgorithmImproved(Int32 depth, IGameFactory gameFactory, Boolean useParallel)
        {
            if (depth < 1)
            {
                throw new ArgumentOutOfRangeException("depth");
            }

            if (null == gameFactory)
            {
                throw new ArgumentNullException("gameFactory");
            }

            _useParallel = useParallel;

            _depth = depth;

            _gameFactory = gameFactory;

            _gameLogic = gameFactory.CreateLogic();

            _stateEvaluator = gameFactory.CreateStateEvaluator();
        }