Page 1 of 1

OpenSpiel: DeepMind's new generic games library

Posted: Tue Aug 27, 2019 5:28 pm
by matthewlai
GitHub: github.com/deepmind/open_spiel

Paper: https://arxiv.org/abs/1908.09453

The library has about 25 games implemented (including chess and Go), all using the same interface, so if you write an AI that plays games using that interface, it will be able to play any of those games (of course, writing an AI that actually plays all those games well is extremely difficult!). Some of the games are imperfect information, some are not zero-sum, some have more than 2 players, and some aren't turn-based.

Here is a list of games: https://github.com/deepmind/open_spiel/ ... s/games.md

There are also many example algorithms implemented that can play those games - CFR, MCTS, minimax (alpha-beta), fictitious play, tabular policies, etc. Some of those algorithms are implemented in both C++ and Python as examples.

Games are implemented in C++, but can be interacted with using either Python or C++.

Contributions very welcomed! https://github.com/deepmind/open_spiel/ ... ibuting.md

I'm happy to answer questions but I'm only a minor contributor (porting chess implementation from AlphaZero).

Re: OpenSpiel: DeepMind's new generic games library

Posted: Tue Aug 27, 2019 6:24 pm
by Raphexon
No checkers or other draughts-like games? :x

Re: OpenSpiel: DeepMind's new generic games library

Posted: Tue Aug 27, 2019 8:27 pm
by thomasahle
Very cool! I've wanted to play around with CFR and similar algorithms.

Re: OpenSpiel: DeepMind's new generic games library

Posted: Wed Aug 28, 2019 8:23 am
by Isaac
Very nice!
Would it be straightforward to implement an AI that plays to tetris?

Where the drawing of tetrominoes would be as random as possible (instead of the fake random function commonly used, which does not allow more than 7 or so tetrominoes to be picked without leaving the other different tetrominoes chosen at least once). We would not care about the speed at which pieces "fall down" at all. Instead, only the given state of the "board" and the available tetromino in hand (as well as possibly the knowledge of the next N tetrominoes) would be given. The AI would then have to make a choice where to place it.

It was proven that such a game eventually ends, it is impossible to make a game last forever. That's because at some point one would get 2 tetrominoes in an alternate way over and over, and there's no way to avoid making holes, eventually leading to losing the game. Note that with the fake random picker commonly used, this sequence has probability 0 to occur so a game may be infinite.

So, an AI could approach the "perfect" play more than humans, I hope. By perfect I mean that in average the game lasts as long as possible (say, a few million moves). I remember Ronald de Man used to think that a professional human player, given enough time to think, would always outperform the AI. I do not see, for the life of me, why this would be the case. It isn't a trivial statement at all, to me, and I wouldn't be the slightest surprised if the AI could outperform any human.

Re: OpenSpiel: DeepMind's new generic games library

Posted: Wed Aug 28, 2019 10:49 am
by Isaac
Here's a tetris AI that uses 4 functions to assess/compute the score of a given position: https://github.com/LeeYiyuan/tetrisai, as explained there: https://codemyroad.wordpress.com/2013/0 ... ct-player/.
The guy apparently used a genetic algorithm to determine the best values of the 4 coefficients of the functions to maximize or minimize. However he implemented the game with the poor random tetrominoes generator so that long sequences of a single tetromino or alternating sequences, are avoided. But I guess it's very easy to modify his code (in particular this file https://github.com/LeeYiyuan/tetrisai/b ... nerator.js) to make it use totally random (or close to it) tetrominoes.

Should one start from such a program to implement tetris in OpenSpiel? Or is it better to start from scratch?

Re: OpenSpiel: DeepMind's new generic games library

Posted: Wed Aug 28, 2019 12:09 pm
by matthewlai
Raphexon wrote:
Tue Aug 27, 2019 6:24 pm
No checkers or other draughts-like games? :x
Contributions warmly welcomed :). We had limited time and wanted to implement a wide range of games from different categories, so some popular games have not been implemented.
Would it be straightforward to implement an AI that plays to tetris?
Yes! Technically, once you have the tetris game implemented, you can already use any of the existing algorithms to play it.

That does sound like a very interesting variant of the game.
Should one start from such a program to implement tetris in OpenSpiel? Or is it better to start from scratch?
In terms of implementing the tetris environment, I would say it's probably easier to start from scratch., especially since that project seems to be in Javascript.

Here are instructions for how to implement a game: https://github.com/deepmind/open_spiel/ ... r_guide.md

The game has to be implemented in C++, but afterwards the AI can be implemented in C++ or Python (potentially Swift and Go in the future).