Skip to content

Commit

Permalink
YX/NT fix issue ucsb-cs56-projects#14 random move
Browse files Browse the repository at this point in the history
  • Loading branch information
meredithxu committed Mar 12, 2018
1 parent e8cb3ed commit 3d27ebf
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/edu/ucsb/cs56/projects/games/gomoku/GomokuSinglePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void actionPerformed(ActionEvent e) {
}

/**
* the method to set the color of each grid
* the method to set the color of each grid
*/
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Expand Down Expand Up @@ -302,21 +302,21 @@ public void mouseMoved(MouseEvent mouse) {
}

public void computerMove() {
int win = CheckWins.checkForWin(grid, playStandard);
int win = CheckWins.checkForWin(grid, playStandard);
if (win != 1) {
int x = (int) (Math.random() * boardSize.x);
int y = (int) (Math.random() * boardSize.y);
boolean empty = true;
while (empty) {
if (grid[x][y] != 1 && grid[x][y] != 2) {
setGrid(x, y, 2);
empty = false;
} else {
x = (int) (Math.random() * boardSize.x);
y = (int) (Math.random() * boardSize.y);
int x = (int) (Math.random() * boardSize.x);
int y = (int) (Math.random() * boardSize.y);
boolean empty = true;
while (empty) {
if (grid[x][y] != 1 && grid[x][y] != 2) {
setGrid(x, y, 2);
empty = false;
} else {
x = (int) (Math.random() * boardSize.x);
y = (int) (Math.random() * boardSize.y);
}
}
}
}
}

/**
Expand Down

0 comments on commit 3d27ebf

Please sign in to comment.