コード例 #1
0
ファイル: Game.cs プロジェクト: Tempest12/6601_Project_One
 /* 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;
 }
コード例 #2
0
ファイル: State.cs プロジェクト: Tempest12/6601_Project_One
        //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;
            }
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: Tempest12/6601_Project_One
        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);
            }
        }
コード例 #4
0
ファイル: Move.cs プロジェクト: Tempest12/6601_Project_One
 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;
     }
 }
コード例 #5
0
ファイル: Core.cs プロジェクト: Tempest12/6601_Project_One
        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);
                }
            }
        }
コード例 #6
0
ファイル: Core.cs プロジェクト: Tempest12/6601_Project_One
        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);
        }
コード例 #7
0
ファイル: Core.cs プロジェクト: Tempest12/6601_Project_One
        //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();
        }