Link to home
Start Free TrialLog in
Avatar of ytwendy
ytwendy

asked on

Chess Java

Hi guys I would like someone to help me put all this together.
It.s supposed to be a text based chess game capable of AI. I am stuck here because it is returning null when the     pieces.isValid(Baseboard[curY][curY].toString(), desY);    is called
Feel free to change anything. If their is any possibility of getting this up to speed I will appreciate it.


chess.java
Pieces.java
Pawn.java
ASKER CERTIFIED SOLUTION
Avatar of trungk43
trungk43
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ytwendy
ytwendy

ASKER

that helped but I have one problem. I can.t validate the moves. The pawn for example moves anywhere! And the others as well.
The other pieces are similar classes as the Pawn class.
Try this one:
public void makeMove()
	// make the move with the coords suplied from askMove method
	{
		if (Baseboard[curX][curY] != null
				&& Baseboard[curX][curY].isValid(Baseboard[curX][curY]
						.toString(), desY)) {
			Baseboard[desX][desY] = Baseboard[curX][curY]; // Move the piece.

			Baseboard[curX][curY] = null;
			
			reDraw();
		} else {
			System.out.println("Can't go here");
		}
	}

Open in new window