Ludii Forum
Complete representation as n-dimensional array - Printable Version

+- Ludii Forum (
+-- Forum: Suggestions (
+--- Forum: Ludii Features / Services (
+--- Thread: Complete representation as n-dimensional array (/showthread.php?tid=24)

Complete representation as n-dimensional array - Quentin Cohen-Solal - 01-29-2020

It would be useful to have a method returning for each game state an n-dimensional array in such a way that this representation is unique and if possible the most natural and the most compact possible. It's obviously complicated. It would be interesting to have such a representation at least for some games, as well as a method to find out if such a representation is available.

This would simplify learning experiments and their comparisons by use of a common coding.

RE: Complete representation as n-dimensional array - DennisSoemers - 02-12-2020

I suppose you're looking for a tensor representation of states, for (deep) learning?

In our next version we will be able to construct [n, x, y] tensors for most of our game states, where the number of channels n differs from game to game, and x and y can (mostly) be interpreted in a meaningful way as spatial coordinates. These things will often be pretty big though, and still not always guaranteed to contain perfect information -- in particular in stacking games.

There might still be a few cases that we cannot yet support in our next version -- like games where pieces are placed not solely on the vertices of a board's graph representation, but also on edges and/or faces. The vast majority of our games should be supported though, at least with an initial attempt at building good tensors for states.

RE: Complete representation as n-dimensional array - Quentin Cohen-Solal - 02-12-2020

Yes that's it.
Thank you so much.

What's wrong with stacking games?

RE: Complete representation as n-dimensional array - DennisSoemers - 02-16-2020

The issue with stacking games is that we generally cannot determine a reasonable upper bound on how tall a stack of pieces on a single position can get in any given game in an automated manner. In "normal" gameplay, stacks of pieces usually won't get very tall in most games, but we can't really guarantee that. So if we try to cover everything that's theoretically possible in our tensor-based state-representation, we'd probably end up with thousands of channels -- the vast majority of which (think 95-99%) would be all-zeros during "normal" play.

So it seems sensible to go for some sort of representation where we only include information from a small number of levels of stacks of pieces in our state representation, but in theory we might occasionally miss out on some information then.

RE: Complete representation as n-dimensional array - dale walton - 05-29-2020

In most games, the designer could specify the maximum stack height in a rule.

RE: Complete representation as n-dimensional array - DennisSoemers - 05-29-2020


If you're still interested in experimenting with this, we have some experimental support for tensor representations for both states and moves. Instead of using the Game and Context objects that we normally use, you'd instead have to use LudiiGameWrapper and LudiiStateWrapper objects. These classes provide some methods to construct these tensors.

I don't have much more documentation on this ready right now, because it really is very experimental and hardly tested. I can point you to some example code that using this stuff... but it's not in Java. It's C++ code accessing the Java classes and methods through JNI. So, it's probably a bit more difficult to read than normal code. But if you're interested in having a look at this experimental stuff, it's right here:

Of course we do intend to provide proper information about how to use this stuff once we've gotten around to testing it a bit more ourselves and made sure that it actually works.

(05-29-2020, 07:08 AM)dale walton Wrote: In most games, the designer could specify the maximum stack height in a rule.

Technically a game designer could do so, yes. We generally don't do this explicitly for the games we include in Ludii ourselves though, and we don't like relying on the expectation that game designers would have to do this. Basically we only want to have designers explicitly specifying the rules that are really rules, and not require them to inject additional domain knowledge that emerges from what the real rules are. This design philosophy also helps to facilitate the easy creation of variants of games, and automated generation of new games through evolutionary algorithms. If evolution / manually created variants change a rule in a stacking game, we would want new limits on stack sizes to again emerge automatically from the adjusted ruleset; we wouldn't want an old stack height limit that we artificially added, which in reality should just have been emergent behaviour, to linger.