TheGamerPlayz TheGamerPlayz - 1 month ago 8x
Java Question

For loop and if statements acting odd

I am making a chess game and so far everything is good and I am writing the rules of each piece now. The problem is that a for loop is acting oddly. Its for the bishop so x is going down and y is going up. At this point it acts oddly whenever I try to add the point to a possible move

for (int i = 0; i < 8; i++) {
Point newLoc = new Point(x-i, y+i);

if(team.equals("white")) {
if(containsPiece(newLoc)) {
if( {
possibilities.put(newLoc, rating);
else {
} else
possibilities.put(newLoc, rating);

is working just fine and
is the
I am storing the possible moves in.

The way I see it it should be working perfect because if the tile at
is white it shouldn't add it to the possible moves and stop getting any moves after it in that direction. Does anyone see why it seems to abandon all the previous possible moves added to

What it should look like

What it is looking like with the code above


i should start in 1, not 0, since when i==0, newLoc is the position of the bishop ((x-0,y+0)), so you break from the loop, since the bishop is a white tile.