-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAiMain.java
41 lines (34 loc) · 1.14 KB
/
AiMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package at.dropical.wolliAI;
// Created by julian on 25.05.18.
import at.dropical.wolliAI.bestPossibility.BestPossibilityAI;
import at.dropical.wolliAI.types.AI;
import at.dropical.wolliAI.types.AlwaysLeftAI;
import at.dropical.wolliAI.types.TryToLoseAI;
/**
* Starts the AI and connects to the default
* localhost server.
*/
public class AiMain {
/** Execute direktly */
public static void main(String[] args) throws InterruptedException {
new AiMain(new ServerAdapter()).loop();
}
/** Called from Server.
* May be wise to execute in other thread. */
public static void newAIconnection(String gameID) throws InterruptedException {
new AiMain(new ServerAdapter(gameID)).loop();
}
private AI ai;
/** The AI type is fixed. */
public AiMain(ServerAdapter adapter) {
ai = new BestPossibilityAI(adapter);
}
private void loop() throws InterruptedException{
while(!Thread.currentThread().isInterrupted()) {
Thread.sleep(100);
ai.process();
}
}
/* I have bugs in my code and they won't go,
* Glitches in my code and they won't go. */
}