Skip to content

Commit 850a9b9

Browse files
committed
updated repo for Ludii 0.4.1
1 parent 0c2629c commit 850a9b9

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Alternatively, the following email address may be used: `ludii(dot)games(at)gmai
142142

143143
## Changelog
144144

145+
- 27 November, 2019: Updated repository for compatibility with new version 0.4.1 of Ludii.
145146
- 6 September, 2019: Updated repository for compatibility with new version 0.3.0 of Ludii.
146147
- 13 August, 2019: Initial release.
147148

src/experiments/RunCustomMatch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
import java.util.List;
55

66
import game.Game;
7-
import game.mode.model.Model;
87
import player.GameLoader;
98
import random.RandomAI;
109
import search.mcts.MCTS;
1110
import util.AI;
1211
import util.Context;
1312
import util.Trial;
13+
import util.model.Model;
1414

1515
/**
1616
* An example of a custom implementation of a match between different AIs,
1717
* i.e. not using the built-in Match functionality of Ludii.
1818
*
1919
* By creating custom implementations of matches/experiments, we can more
20-
* easily add our own custom stats to track, and request mvoes from AIs
20+
* easily add our own custom stats to track, and request moves from AIs
2121
* that do not implement Ludii's abstract AI class. The downside is that
2222
* more boilerplate code must be written.
2323
*

src/experiments/Tutorial.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.List;
66

77
import game.Game;
8-
import game.mode.model.Model;
98
import main.FastArrayList;
109
import mcts.ExampleUCT;
1110
import player.GameLoader;
@@ -14,7 +13,8 @@
1413
import util.Context;
1514
import util.Move;
1615
import util.Trial;
17-
import util.state.StateType;
16+
import util.model.Model;
17+
import util.state.GameType;
1818
import util.state.containerState.ContainerState;
1919

2020
/**
@@ -42,14 +42,14 @@ public static void main(final String[] args)
4242
final int stateFlags = game.stateFlags();
4343

4444
// for example, we may like to know whether our game has stochastic elements
45-
final boolean isStochastic = ((stateFlags & StateType.Stochastic) != 0);
45+
final boolean isStochastic = ((stateFlags & GameType.Stochastic) != 0);
4646
if (isStochastic)
4747
System.out.println(game.name() + " is stochastic.");
4848
else
4949
System.out.println(game.name() + " is not stochastic.");
5050

5151
// figure out how many players are expected to play this game
52-
final int numPlayers = game.mode().numPlayers();
52+
final int numPlayers = game.players().count();
5353
System.out.println(game.name() + " is a " + numPlayers + "-player game.");
5454

5555
// to be able to play the game, we need to instantiate "Trial" and "Context" objects
@@ -66,7 +66,7 @@ public static void main(final String[] args)
6666
// for every container state we find (often just 1), we'll print a few things:
6767

6868
// print the collection of locations that are empty
69-
System.out.println("Empty locations = " + containerState.empty().bitSet());
69+
System.out.println("Empty locations = " + containerState.emptyChunkSet());
7070

7171
// for every location that is owned by a player, print the owner
7272
System.out.println("Who = " + containerState.cloneWho().toChunkString());
@@ -88,7 +88,7 @@ public static void main(final String[] args)
8888
// let's print our empty/who/what again, see how they have changed
8989
for (final ContainerState containerState : trial.state().containerStates())
9090
{
91-
System.out.println("Empty locations = " + containerState.empty().bitSet());
91+
System.out.println("Empty locations = " + containerState.emptyChunkSet());
9292
System.out.println("Who = " + containerState.cloneWho().toChunkString());
9393
System.out.println("What = " + containerState.cloneWhat().toChunkString());
9494
}
@@ -102,7 +102,7 @@ public static void main(final String[] args)
102102
// let's have a final look at how our state looks after this second move
103103
for (final ContainerState containerState : trial.state().containerStates())
104104
{
105-
System.out.println("Empty locations = " + containerState.empty().bitSet());
105+
System.out.println("Empty locations = " + containerState.emptyChunkSet());
106106
System.out.println("Who = " + containerState.cloneWho().toChunkString());
107107
System.out.println("What = " + containerState.cloneWhat().toChunkString());
108108
}

src/mcts/ExampleDUCT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public ExampleDUCT()
124124
if (current.totalVisitCount > 0)
125125
{
126126
// This node was not newly expanded in this iteration
127-
for (int p = 1; p <= game.mode().numPlayers(); ++p)
127+
for (int p = 1; p <= game.players().count(); ++p)
128128
{
129129
current.visitCounts[p][current.lastSelectedMovesPerPlayer[p]] += 1;
130130
current.scoreSums[p][current.lastSelectedMovesPerPlayer[p]] += utilities[p];
@@ -156,7 +156,7 @@ public static Node select(final Node current)
156156
// Every player selects its move based on its own, decoupled statistics
157157
final List<Action> playerMoves = new ArrayList<Action>();
158158
final Game game = current.context.game();
159-
final int numPlayers = game.mode().numPlayers();
159+
final int numPlayers = game.players().count();
160160

161161
for (int p = 1; p <= numPlayers; ++p)
162162
{
@@ -331,7 +331,7 @@ public Node(final Node parent, final Context context)
331331
this.parent = parent;
332332
this.context = context;
333333
final Game game = context.game();
334-
final int numPlayers = game.mode().numPlayers();
334+
final int numPlayers = game.players().count();
335335

336336
final FastArrayList<Move> allLegalMoves = game.moves(context).moves();
337337

src/mcts/ExampleUCT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public ExampleUCT()
114114
while (current != null)
115115
{
116116
current.visitCount += 1;
117-
for (int p = 1; p <= game.mode().numPlayers(); ++p)
117+
for (int p = 1; p <= game.players().count(); ++p)
118118
{
119119
current.scoreSums[p] += utilities[p];
120120
}
@@ -294,7 +294,7 @@ public Node(final Node parent, final Move moveFromParent, final Context context)
294294
this.moveFromParent = moveFromParent;
295295
this.context = context;
296296
final Game game = context.game();
297-
scoreSums = new double[game.mode().numPlayers() + 1];
297+
scoreSums = new double[game.players().count() + 1];
298298

299299
// For simplicity, we just take ALL legal moves.
300300
// This means we do not support simultaneous-move games.

src/random/RandomAI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import util.Context;
99
import util.Move;
1010
import util.action.ActionPass;
11-
import util.state.StateType;
11+
import util.state.GameType;
1212
import utils.AIUtils;
1313

1414
/**
@@ -57,7 +57,7 @@ public RandomAI()
5757

5858
// If we're playing a simultaneous-move game, some of the legal moves may be
5959
// for different players. Extract only the ones that we can choose.
60-
if ((game.stateFlags() & StateType.Simultaneous) != 0)
60+
if ((game.stateFlags() & GameType.Simultaneous) != 0)
6161
legalMoves = AIUtils.extractMovesForMover(legalMoves, player);
6262

6363
final int r = ThreadLocalRandom.current().nextInt(legalMoves.size());

0 commit comments

Comments
 (0)