コード例 #1
0
ファイル: Player.cs プロジェクト: Tempest12/6601_Project_One
        public Player(int playerNumber, PlayerType type)
        {
            this.playerNumber = playerNumber;

            this.currentPosition = null;
            this.possibleMoves = Move.getPossibleMoves(Core.drawCube.cube, currentPosition);

            this.type = type;

            if (type == PlayerType.AI)
            {
                switch (playerNumber)
                {
                    case 1:

                        setAIFunc(Config.getValue("ai", "player_one"));
                        break;

                    case 2:

                        setAIFunc(Config.getValue("ai", "player_two"));
                        break;
                }
            }
        }
コード例 #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 addShadows(byte[, ,] board, Move start, Move end)
        {
            if (start == null)
            {
                return;
            }

            if (Config.convertSettingToBool("game", "shadow_line"))
            {

            }
            else
            {
                board[start.row, start.col, start.distance] = (byte)Cube.SHADOW;
            }
        }
コード例 #5
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;
     }
 }
コード例 #6
0
ファイル: Cube.cs プロジェクト: Tempest12/6601_Project_One
        public void fillSmallCube(Move location)
        {
            //Bottom Face
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);

            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);

            //Top Face
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1 ) * cubeSize, startCoordinate + location.distance * cubeSize);
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);

            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);

            //Front Face
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//Origin
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);//y++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);//x and y ++

            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//Origin
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//x++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);//x and y ++

            //Back Face
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//z++
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//y and z++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//end

            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//z++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//x and z++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//end

            //Left Face
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//Origin
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//z++
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//y and z++

            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//Origin
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);//y++
            GL.Vertex3(startCoordinate + location.col * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//y and z++

            //Right Face
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//x++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//x and z++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//end

            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + location.row * cubeSize, startCoordinate + location.distance * cubeSize);//x++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + location.distance * cubeSize);//x and y++
            GL.Vertex3(startCoordinate + (location.col + 1) * cubeSize, startCoordinate + (location.row + 1) * cubeSize, startCoordinate + (location.distance + 1) * cubeSize);//end
        }
コード例 #7
0
ファイル: Move.cs プロジェクト: Tempest12/6601_Project_One
        public static List<Move> getPossibleMoves(byte[, ,] board, Move currentPosition)
        {
            List<Move> possibleMoves = new List<Move>();

            //if we just started and are placing our piece we can go anywhere that isn't already taken
            if (currentPosition == null)
            {
                for (int z = 0; z < Cube.cubeDimension; z++)
                {
                    for (int y = 0; y < Cube.cubeDimension; y++)
                    {
                        for (int x = 0; x < Cube.cubeDimension; x++)
                        {
                            if (board[x, y, z] == Cube.EMPTY)
                            {
                                possibleMoves.Add(new Move(x, y, z));
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }

                return possibleMoves;
            }

            //Log.writeDebug("The move sent to get possible moves is: " + currentPosition.ToString());

            if (Config.convertSettingToBool("game", "rock_move"))
            {
                //Left
                for (int left = (currentPosition.col + 1); left < Cube.cubeDimension; left++)
                {
                    if (board[currentPosition.row, left, currentPosition.distance] == Cube.EMPTY)
                    {
                        possibleMoves.Add(new Move(currentPosition.row, left, currentPosition.distance));
                    }
                    else
                    {
                        break;
                    }
                }

                //Right
                for (int right = (currentPosition.col - 1); right >= 0; right--)
                {
                    if (board[currentPosition.row, right, currentPosition.distance] == Cube.EMPTY)
                    {
                        possibleMoves.Add(new Move(currentPosition.row, right, currentPosition.distance));
                    }
                    else
                    {
                        break;
                    }
                }

                //Front
                for (int front = (currentPosition.distance - 1); front >= 0; front--)
                {
                    if (board[currentPosition.row, currentPosition.col, front] == Cube.EMPTY)
                    {
                        possibleMoves.Add(new Move(currentPosition.row, currentPosition.col, front));
                    }
                    else
                    {
                        break;
                    }
                }

                //Back
                for (int back = (currentPosition.distance + 1); back < Cube.cubeDimension; back++)
                {
                    if (board[currentPosition.row, currentPosition.col, back] == Cube.EMPTY)
                    {
                        possibleMoves.Add(new Move(currentPosition.row, currentPosition.col, back));
                    }
                    else
                    {
                        break;
                    }
                }

                //Up
                for (int up = (currentPosition.row + 1); up < Cube.cubeDimension; up++)
                {
                    if (board[up, currentPosition.col, currentPosition.distance] == Cube.EMPTY)
                    {
                        possibleMoves.Add(new Move(up, currentPosition.col, currentPosition.distance));
                    }
                    else
                    {
                        break;
                    }
                }

                //Down
                for(int down = (currentPosition.row - 1); down >= 0 ; down--)
                {
                    if (board[down, currentPosition.col, currentPosition.distance] == Cube.EMPTY)
                    {
                        possibleMoves.Add(new Move(down, currentPosition.col, currentPosition.distance));
                    }
                    else
                    {
                        break;
                    }
                }

                /*if (possibleMoves.Count < 25)
                {
                    Log.writeDebug("The possible moves are:");

                    foreach (Move move in possibleMoves)
                    {
                        Log.writeDebug("    " + move.ToString());
                    }
                }*/
            }
            if(Config.convertSettingToBool("game", "horizontal_queen_move"))
            {

            }
            if(Config.convertSettingToBool("game", "vertical_queen_move"))
            {

            }

            return possibleMoves;
        }
コード例 #8
0
ファイル: Move.cs プロジェクト: Tempest12/6601_Project_One
 public Move(Move that)
 {
     this.row = that.row;
     this.col = that.col;
     this.distance = that.distance;
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: Tempest12/6601_Project_One
        public bool tryMove(Move move)
        {
            if (possibleMoves.Contains(move))
            {
                //Fill in all of the moves between where we are and where we are going.
                Core.drawCube.cube[move.row, move.col, move.distance] = (byte)playerNumber;
                if (currentPosition != null)
                {
                    //Core.drawCube.cube[currentPosition.row, currentPosition.col, currentPosition.distance] = (byte)Cube.SHADOW;
                    Move.addShadows(Core.drawCube.cube, currentPosition, move);
                }
                Core.moveCounter++;

                Log.writeSpecial("Player has moved to: " + move.ToString());

                currentPosition = move;

                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #10
0
ファイル: Player.cs プロジェクト: Tempest12/6601_Project_One
        public void makeMove(State currentState)
        {
            if (type != PlayerType.AI)
            {
                MainMethod.die("Player.makeMove : makeMove called on a human player.");
            }

            Move move = aiFunc(currentState);

            if (move == null)
            {
                return;
            }

            //Log.writeSpecial("Move sent back by AI is: " + move.ToString());

            Core.drawCube.cube[move.row, move.col, move.distance] = (byte)playerNumber;
            Move.addShadows(Core.drawCube.cube, currentPosition, move);
            currentPosition = move;
        }