use of suite.weiqi.Weiqi.Occupation in project suite by stupidsing.
the class Judge method checkGroupsLiveness.
public static void checkGroupsLiveness(Board board, Array<Boolean> alives) {
GroupAnalysis ga = new GroupAnalysis(board);
// judge which groups are eyes, i.e. surrounded by only one colour
Map<Group, Boolean> groupIsEye = new HashMap<>();
for (Group group : ga.getGroups()) if (group.color == Occupation.EMPTY) {
Set<Occupation> colors = new HashSet<>();
for (Group neighborGroup : group.touches) {
Occupation color = neighborGroup.color;
if (color != Occupation.EMPTY)
colors.add(color);
}
// has two colours
groupIsEye.put(group, colors.size() <= 1);
}
}
use of suite.weiqi.Weiqi.Occupation in project suite by stupidsing.
the class UserInterface method importBoard.
public static Board importBoard(String s) {
Board board = new Board();
String[] rows = s.split("\n");
for (int x = 0; x < Weiqi.size; x++) {
String[] cols = rows[x].split(" ");
for (int y = 0; y < Weiqi.size; y++) {
Occupation occupation = Occupation.EMPTY;
for (Occupation o : Occupation.values()) if (String_.equals(cols[y], o.display()))
occupation = o;
board.set(Coordinate.c(x, y), occupation);
}
}
return board;
}
use of suite.weiqi.Weiqi.Occupation in project suite by stupidsing.
the class UctTest method evaluateRandomOutcome.
private String evaluateRandomOutcome(Coordinate move) {
Occupation player = Occupation.WHITE;
int nWins = 0, nTotal = 1000;
for (int i = 0; i < nTotal; i++) {
GameSet gameSet = new GameSet(new Board(), player);
UctVisitor<Coordinate> visitor = UctWeiqi.newVisitor(gameSet);
visitor.playMove(move);
nWins += visitor.evaluateRandomOutcome() ? 0 : 1;
}
return nWins + "/" + nTotal;
}
Aggregations