Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo 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;
            }
        }
Exemplo 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);
            }
        }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
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;
     }
 }
Exemplo n.º 6
0
        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
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
 public Move(Move that)
 {
     this.row = that.row;
     this.col = that.col;
     this.distance = that.distance;
 }
Exemplo n.º 9
0
        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;
            }
        }
Exemplo n.º 10
0
        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;
        }