diff --git a/.idea/misc.xml b/.idea/misc.xml
index 062a7aa..accd629 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2bb65a5..58f9c6e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,14 +5,11 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -52,6 +49,11 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "last_opened_file_path": "/home/william/Dev/Projects/Uni/Log320/LOG320_Lab4",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
"vue.rearranger.settings.migration": "true"
}
}]]>
@@ -84,6 +86,7 @@
1679255648701
+
diff --git a/src/main/java/laboratoire4/GameTree.java b/src/main/java/laboratoire4/GameTree.java
new file mode 100644
index 0000000..0502068
--- /dev/null
+++ b/src/main/java/laboratoire4/GameTree.java
@@ -0,0 +1,23 @@
+package laboratoire4;
+
+import java.util.Collection;
+
+public class GameTree {
+ private Node root;
+
+ public Node getRoot() {
+ return root;
+ }
+
+ static class Node {
+ private final Collection childs;
+
+ Node(Collection childs) {
+ this.childs = childs;
+ }
+
+ public Collection getChilds() {
+ return childs;
+ }
+ }
+}
diff --git a/src/main/java/laboratoire4/MiniMax.java b/src/main/java/laboratoire4/MiniMax.java
index 980416d..91c7028 100644
--- a/src/main/java/laboratoire4/MiniMax.java
+++ b/src/main/java/laboratoire4/MiniMax.java
@@ -1,10 +1,49 @@
package laboratoire4;
-public enum Player {
- MIN,
- MAX
-}
-
public class MiniMax {
- public static void miniMax(player)
+ private static final int MAX_DEPTH = 4;
+
+ public static int miniMax(GameTree tree) {
+ return miniMax(tree.getRoot(), Player.MAX, 0);
+ }
+
+ private static int miniMax(GameTree.Node node, Player player, int depth) {
+ if (depth == MAX_DEPTH) {
+ return evaluate(node);
+ }
+
+ return player == Player.MAX ?
+ max(node, depth) :
+ min(node, depth);
+ }
+
+ private static int max(GameTree.Node node, int depth) {
+ int maxScore = Integer.MIN_VALUE;
+
+ for (GameTree.Node child : node.getChilds()) {
+ int score = miniMax(child, Player.MIN, depth + 1);
+ if (score > maxScore) {
+ maxScore = score;
+ }
+ }
+
+ return maxScore;
+ }
+
+ private static int min(GameTree.Node node, int depth) {
+ int minScore = Integer.MAX_VALUE;
+
+ for (GameTree.Node child : node.getChilds()) {
+ int score = miniMax(child, Player.MIN, depth + 1);
+ if (score < minScore) {
+ minScore = score;
+ }
+ }
+
+ return minScore;
+ }
+
+ private static int evaluate(GameTree.Node node) {
+
+ }
}
diff --git a/src/main/java/laboratoire4/Player.java b/src/main/java/laboratoire4/Player.java
new file mode 100644
index 0000000..99a2b53
--- /dev/null
+++ b/src/main/java/laboratoire4/Player.java
@@ -0,0 +1,6 @@
+package laboratoire4;
+
+public enum Player {
+ MIN,
+ MAX
+}