- Reorganized packages so that the computer agents are inside the model package.
- Added support for the player model inside Referee.java; high scores should now persist over a single execution of the program. - Refactored PlayerModel.java to support game logging. All games are now logged so that we can track overall progress. - Added scaffolding to allow saving and importing of PlayerModel.java. It is not yet functional, but it will be with two function implementations and then the appropriate calls.
This commit is contained in:
44
src/model/comPlayer/generator/ValidMoveGenerator.java
Normal file
44
src/model/comPlayer/generator/ValidMoveGenerator.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package model.comPlayer.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import model.Board;
|
||||
import model.Board.TileColor;
|
||||
import model.Move;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class ValidMoveGenerator implements MoveGenerator {
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(ValidMoveGenerator.class.getName());
|
||||
|
||||
@Override
|
||||
public Move genMove(Board board, boolean asHuman) {
|
||||
LOGGER.info("ValidMoveGenerator genMove() stub returning NONE");
|
||||
return Move.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Move> genMoves(Board board, boolean asHuman, int nMoves) {
|
||||
|
||||
List<Move> validMoves = new ArrayList<Move>();
|
||||
|
||||
for (int i = 0; i < Board.NUM_ROWS; i++) {
|
||||
for (int j = 0; j < Board.NUM_COLS; j++) {
|
||||
if (board.getTile(i, j) == TileColor.NONE) {
|
||||
for (TileColor color : TileColor.values()) {
|
||||
if (color == TileColor.NONE) {
|
||||
continue;
|
||||
}
|
||||
validMoves.add(new Move(color, i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(validMoves);
|
||||
return validMoves;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user