Esempio n. 1
0
 /* Constructor */
 public Node(Player p, State s, float alpha_in, float beta_in, bool root_in)
 {
     player = p;
     state = s;
     alpha = alpha_in;
     beta = beta_in;
     root = root_in;
 }
Esempio n. 2
0
        //For now to start the "tree" pass in the player's last move and our as false. Then it will generate the first level of all possible AI moves
        public State(Player ai, Player opponent, byte[, ,] board, Move move, bool ourMove)
        {
            this.AIPlayer = new Player(ai);
            this.opponent = new Player(opponent);

            this.gameBoard = new byte[Cube.cubeDimension, Cube.cubeDimension, Cube.cubeDimension];
            for (int x = 0; x < Cube.cubeDimension; x++)
            {
                for (int y = 0; y < Cube.cubeDimension; y++)
                {
                    for (int z = 0; z < Cube.cubeDimension; z++)
                    {
                        this.gameBoard[x, y, z] = board[x, y, z];
                    }
                }
            }

            this.ourMove = ourMove;
            this.generatorMove = move;

            if(ourMove)
            {
                if (move != null)
                {
                    Move.fakeMove(this.gameBoard, this.opponent, move);
                }
                this.AIPlayer.getNewMoves(this.gameBoard);
                this.opponent.getNewMoves(this.gameBoard);
            }
            else
            {
                if (move != null)
                {
                    Move.fakeMove(this.gameBoard, this.AIPlayer, move);
                }
                this.opponent.getNewMoves(this.gameBoard);
                this.AIPlayer.getNewMoves(this.gameBoard);
            }

            switch (AIPlayer.playerNumber)
            {
                case 1:
                    this.value = playerOneEvalFunc(this);
                    break;

                case 2:
                    this.value = playerTwoEvalFunc(this);
                    break;
            }
        }
Esempio n. 3
0
        public Player(Player that)
        {
            this.type = that.type;
            this.playerNumber = that.playerNumber;

            if (that.currentPosition == null)
            {
                this.currentPosition = null;
            }
            else
            {
                this.currentPosition = new Move(that.currentPosition);
            }
        }
Esempio n. 4
0
 public static void fakeMove(byte[, ,] board, Player movingPlayer, Move move)
 {
     if (movingPlayer.currentPosition == null)
     {
         board[move.row, move.col, move.distance] = (byte)movingPlayer.playerNumber;
         movingPlayer.currentPosition = move;
     }
     else if(movingPlayer.currentPosition.Equals(move))
     {
         return;
     }
     else
     {
         board[move.row, move.col, move.distance] = (byte)movingPlayer.playerNumber;
         addShadows(board, movingPlayer.currentPosition, move);
         movingPlayer.currentPosition = move;
     }
 }
Esempio n. 5
0
        public static void switchPlayers()
        {
            moveCounter++;

            if(currentPlayer.Equals(playerOne))
            {
                currentPlayer = playerTwo;
                playerTwo.getNewMoves(drawCube.cube);
                playerOne.getNewMoves(drawCube.cube);
                if (playerTwo.possibleMoves.Count == 0)
                {
                    endGame(playerOne.playerNumber);
                }
                else if (playerOne.possibleMoves.Count == 0)
                {
                    endGame(playerTwo.playerNumber);
                }
            }
            else if (currentPlayer.Equals(playerTwo))
            {
                currentPlayer = playerOne;
                playerOne.getNewMoves(drawCube.cube);
                playerTwo.getNewMoves(drawCube.cube);
                if (playerOne.possibleMoves.Count == 0)
                {
                    endGame(playerTwo.playerNumber);
                }
                else if (playerTwo.possibleMoves.Count == 0)
                {
                    endGame(playerOne.playerNumber);
                }
            }
        }
Esempio n. 6
0
        public static void restartGame()
        {
            drawCube = new Cube();

            playerOne.currentPosition = null;
            playerTwo.currentPosition = null;

            switch (Config.convertSettingToInt("game", "starting_player"))
            {
                case 1:
                    currentPlayer = playerOne;
                    break;

                case 2:
                    currentPlayer = playerTwo;
                    break;
            }

            currentPlayer.getNewMoves(drawCube.cube);
        }
Esempio n. 7
0
        //sprivate static Color4 clearColour;
        //Used to draw spheres... Not sure why it's needed...
        //public static IntPtr intptr = GLU.NewQuadric();
        /**
         * Initializes the Core of the program by initliazling everything. Failures here cause program termination
         */
        public static void init()
        {
            Config.init();

            Log.init(Config.convertSettingToInt("log", "default_level"));

            initGL();

            Cube.init();
            drawCube = new Cube();

            playerOne = new Player(1, getPlayerType(1));
            playerTwo = new Player(2, getPlayerType(2));
            switch (Config.convertSettingToInt("game", "starting_player"))
            {
                case 1:
                    currentPlayer = playerOne;
                    break;

                case 2:
                    currentPlayer = playerTwo;
                    break;

                default:
                    MainMethod.die("Core.init : The starting player must either be 1 or 2, not: " + Config.convertSettingToInt("game", "starting_player"));
                    break;
            }

            numberGenerator = new Random();

            simulating = Config.convertSettingToBool("game", "simulating");
            simCount = 0;
            simCountMax = Config.convertSettingToInt("game", "sim_count");

            State.setEvalFunc();
        }