Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
Initial commit, finally porting the project to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasdoe committed Feb 19, 2021
0 parents commit 5552af5
Show file tree
Hide file tree
Showing 20 changed files with 1,577 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/out/
/lib/
/.idea/
17 changes: 17 additions & 0 deletions DomineeringAI.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_15">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="org.processing:core:3.3.7" level="project" />
</component>
</module>
21 changes: 21 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Domineering AI

The game [domineering](https://en.wikipedia.org/wiki/Domineering) has very few rules and is therefore easy to learn.
However, the strategies which evolve can be more complex than one might think at first glance.

Domineering can be played on a chess board in any rectangular shape, increasing the complexity with the overall size of
the board. Two players, here called "V" for vertical and "H" for horizontal, each place a domino pieces onto the board.
The pieces may not overlap each other and can only be placed fully on the board.

The first player who is unable to legally place another piece has lost the game.

To compute the winning strategy for the game, one has to compute a score for the possible board configurations which
result in the currently possible moves, the player could make. Because the number of possible moves and board
configurations eventually rises exponentially with bigger boards, we need a good strategy to sort out bad moves quickly.

For this AI, I chose to use a combination of a min-max-algorithm with alpha-beta-pruning. For move ordering, I based my
board scoring and move evaluation algorithm on methods for move counting and scanning from Nathan Bullocks master thesis.

Depending on how long the AI is allowed to "think" about the next move, the "depthForBoardState" function should be
altered. It is responsible for evaluating the search depth, aka. the number of next moves, the ai should take into
consideration.
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>DomineeringAI</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>

</project>
5 changes: 5 additions & 0 deletions src/main/java/ai/AI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ai;

public abstract class AI {
public abstract Coordinate playMove(char[][] board, Player player);
}
24 changes: 24 additions & 0 deletions src/main/java/ai/Area.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ai;

public abstract class Area {
protected final Coordinate cornerUL; // "upper-left"-corner
protected final Coordinate cornerLR; // "lower-right"-corner

public Area(int startX, int startY, int endX, int endY) {
cornerUL = new Coordinate(startX, startY);
cornerLR = new Coordinate(endX, endY);
}

public Coordinate getCornerUL() {
return cornerUL;
}

public Coordinate getCornerLR() {
return cornerLR;
}

// return true if the given point is not contained in the area
public boolean contains(int x, int y) {
return x >= cornerLR.getX() && x <= cornerLR.getX() && y >= cornerUL.getY() && y <= cornerLR.getY();
}
}
Loading

0 comments on commit 5552af5

Please sign in to comment.