mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Merge changes on dev
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package org.toop;
|
||||
|
||||
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.game.games.reversi.BitboardReversi;
|
||||
import org.toop.game.players.ArtificialPlayer;
|
||||
import org.toop.framework.game.games.reversi.BitboardReversi;
|
||||
import org.toop.framework.game.players.ArtificialPlayer;
|
||||
import org.toop.game.players.ai.MCTSAI;
|
||||
import org.toop.game.players.ai.RandomAI;
|
||||
import org.toop.game.players.ai.mcts.MCTSAI1;
|
||||
@@ -11,19 +11,24 @@ import org.toop.game.players.ai.mcts.MCTSAI2;
|
||||
import org.toop.game.players.ai.mcts.MCTSAI3;
|
||||
import org.toop.game.players.ai.mcts.MCTSAI4;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public final class Main {
|
||||
static void main(String[] args) {
|
||||
// App.run(args);
|
||||
testMCTS(25);
|
||||
ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||
|
||||
executor.execute(() -> testMCTS(25));
|
||||
App.run(args);
|
||||
}
|
||||
|
||||
private static void testMCTS(int games) {
|
||||
var versions = new ArtificialPlayer[5];
|
||||
versions[0] = new ArtificialPlayer<>(new RandomAI<BitboardReversi>(), "Random AI");
|
||||
versions[1] = new ArtificialPlayer<>(new MCTSAI1<BitboardReversi>(1000), "MCTS V1 AI");
|
||||
versions[2] = new ArtificialPlayer<>(new MCTSAI2<BitboardReversi>(1000), "MCTS V2 AI");
|
||||
versions[3] = new ArtificialPlayer<>(new MCTSAI3<BitboardReversi>(10, 10), "MCTS V3 AI");
|
||||
versions[4] = new ArtificialPlayer<>(new MCTSAI4<BitboardReversi>(10, 10), "MCTS V4 AI");
|
||||
versions[0] = new ArtificialPlayer(new RandomAI(), "Random AI");
|
||||
versions[1] = new ArtificialPlayer(new MCTSAI1(1000), "MCTS V1 AI");
|
||||
versions[2] = new ArtificialPlayer(new MCTSAI2(1000), "MCTS V2 AI");
|
||||
versions[3] = new ArtificialPlayer(new MCTSAI3(10, 10), "MCTS V3 AI");
|
||||
versions[4] = new ArtificialPlayer(new MCTSAI4(10, 10), "MCTS V4 AI");
|
||||
|
||||
for (int i = 0; i < versions.length; i++) {
|
||||
for (int j = i + 1; j < versions.length; j++) {
|
||||
@@ -35,12 +40,13 @@ public final class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static void testAI(int games, ArtificialPlayer<BitboardReversi>[] ais) {
|
||||
private static void testAI(int games, ArtificialPlayer[] ais) {
|
||||
int wins = 0;
|
||||
int ties = 0;
|
||||
|
||||
for (int i = 0; i < games; i++) {
|
||||
final BitboardReversi match = new BitboardReversi(ais);
|
||||
final BitboardReversi match = new BitboardReversi();
|
||||
match.init(ais);
|
||||
|
||||
while (!match.isTerminal()) {
|
||||
final int currentAI = match.getCurrentTurn();
|
||||
@@ -48,7 +54,7 @@ public final class Main {
|
||||
|
||||
match.play(move);
|
||||
|
||||
if (ais[currentAI].getAi() instanceof MCTSAI<?> mcts) {
|
||||
if (ais[currentAI].getAi() instanceof MCTSAI mcts) {
|
||||
final int lastIterations = mcts.getLastIterations();
|
||||
System.out.printf("iterations %s: %d\n", ais[currentAI].getName(), lastIterations);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ import org.toop.framework.networking.connection.clients.TournamentNetworkingClie
|
||||
import org.toop.framework.networking.connection.events.NetworkEvents;
|
||||
import org.toop.framework.networking.connection.types.NetworkingConnector;
|
||||
import org.toop.framework.networking.server.gateway.NettyGatewayServer;
|
||||
import org.toop.framework.game.players.LocalPlayer;
|
||||
import org.toop.game.players.ai.MCTSAI3;
|
||||
import org.toop.game.players.ai.mcts.MCTSAI3;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -211,7 +210,7 @@ public final class Server {
|
||||
|
||||
Player[] players = new Player[2];
|
||||
|
||||
players[userStartingTurn] = new ArtificialPlayer(new MCTSAI3(1000), user);
|
||||
players[userStartingTurn] = new ArtificialPlayer(new MCTSAI3(1000, Runtime.getRuntime().availableProcessors()), user);
|
||||
players[opponentStartingTurn] = new OnlinePlayer(response.opponent());
|
||||
|
||||
switch (type) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import javafx.application.Platform;
|
||||
import org.toop.app.GameInformation;
|
||||
import org.toop.app.gameControllers.ReversiBitController;
|
||||
import org.toop.app.gameControllers.TicTacToeBitController;
|
||||
import org.toop.framework.game.players.LocalPlayer;
|
||||
import org.toop.framework.gameFramework.controller.GameController;
|
||||
import org.toop.framework.gameFramework.model.player.Player;
|
||||
import org.toop.framework.game.players.ArtificialPlayer;
|
||||
@@ -12,13 +13,9 @@ import org.toop.app.widget.complex.PlayerInfoWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.app.widget.popup.ErrorPopup;
|
||||
import org.toop.app.widget.tutorial.*;
|
||||
import org.toop.game.players.ai.MCTSAI1;
|
||||
import org.toop.game.players.ai.MCTSAI2;
|
||||
import org.toop.game.players.ai.MCTSAI3;
|
||||
import org.toop.game.players.ai.MCTSAI4;
|
||||
import org.toop.game.players.ai.MCTSAI5;
|
||||
import org.toop.game.players.ai.MiniMaxAI;
|
||||
import org.toop.game.players.ai.RandomAI;
|
||||
import org.toop.game.players.ai.mcts.MCTSAI1;
|
||||
import org.toop.game.players.ai.mcts.MCTSAI3;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
@@ -56,7 +53,7 @@ public class LocalMultiplayerView extends ViewWidget {
|
||||
if (information.players[0].isHuman) {
|
||||
players[0] = new LocalPlayer(information.players[0].name);
|
||||
} else {
|
||||
players[0] = new ArtificialPlayer(new MCTSAI(100), "MCTS AI");
|
||||
players[0] = new ArtificialPlayer(new MCTSAI1(100), "MCTS AI");
|
||||
}
|
||||
if (information.players[1].isHuman) {
|
||||
players[1] = new LocalPlayer(information.players[1].name);
|
||||
@@ -85,12 +82,12 @@ public class LocalMultiplayerView extends ViewWidget {
|
||||
players[0] = new LocalPlayer(information.players[0].name);
|
||||
} else {
|
||||
// players[0] = new ArtificialPlayer(new RandomAI<BitboardReversi>(), "Random AI");
|
||||
players[0] = new ArtificialPlayer(new MCTSAI3(50), "MCTS V3 AI");
|
||||
players[0] = new ArtificialPlayer(new MCTSAI3(50, Runtime.getRuntime().availableProcessors()), "MCTS V3 AI");
|
||||
}
|
||||
if (information.players[1].isHuman) {
|
||||
players[1] = new LocalPlayer(information.players[1].name);
|
||||
} else {
|
||||
players[1] = new ArtificialPlayer(new MCTSAI(50), "MCTS V1 AI");
|
||||
players[1] = new ArtificialPlayer(new MCTSAI1(50), "MCTS V1 AI");
|
||||
}
|
||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstReversi()) {
|
||||
new ShowEnableTutorialWidget(
|
||||
|
||||
Reference in New Issue
Block a user