Esempio n. 1
0
        private void AiMove(int player, int depth)
        {
            if (Input.anyKeyDown)
            {
                var aiMove = _ai.GetAiMove(depth, player);
                _b.PlaceMove(aiMove, player);

                _b.DisplayBoard();
                var gameResult = _ai.GameResult(_b);

                switch (gameResult)
                {
                case 1:
                    Player1Win();
                    break;

                case 2:
                    Player2Win();
                    break;

                case 0:
                    Draw();
                    break;
                }

                _firstPlayerTurn = !_firstPlayerTurn;
            }
        }
Esempio n. 2
0
        private void DoPostScreen()
        {
            if (Input.anyKeyDown)
            {
                _state = GameState.ConfigPlayer1;
                _b     = new Board(this);
                _ai    = new Connect4Ai(_b);

                InfoText.text = "";

                _b.DisplayBoard();
            }
        }
Esempio n. 3
0
        private void StartGame()
        {
            for (var y = 0; y < 6; y++)
            {
                for (var x = 0; x < 7; x++)
                {
                    BoardObjets[y, x] = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    BoardObjets[y, x].transform.SetParent(transform);
                    BoardObjets[y, x].transform.position = new Vector3(x * 2 - 6, 14 - y * 2 - 7, 0);
                }
            }

            _b  = new Board(this);
            _ai = new Connect4Ai(_b);

            _b.DisplayBoard();
        }