From d1bf24f3854571dffe9c79a318c3228af73e4442 Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Sat, 26 Oct 2024 16:32:34 +0100 Subject: [PATCH 1/6] Einstein Wurfelt Nicht implementation --- docs/games.md | 1 + open_spiel/games/CMakeLists.txt | 6 + .../einstein_wurfelt_nicht.cc | 508 ++++++++++++++++++ .../einstein_wurfelt_nicht.h | 160 ++++++ .../einstein_wurfelt_nicht_test.cc | 277 ++++++++++ .../playthroughs/einstein_wurfelt_nicht.txt | 424 +++++++++++++++ open_spiel/python/tests/pyspiel_test.py | 1 + 7 files changed, 1377 insertions(+) create mode 100644 open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc create mode 100644 open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h create mode 100644 open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc create mode 100644 open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt diff --git a/docs/games.md b/docs/games.md index cb145568c3..14b49eb648 100644 --- a/docs/games.md +++ b/docs/games.md @@ -33,6 +33,7 @@ Status | Game 🟒 | [Dots and Boxes](https://en.wikipedia.org/wiki/Dots_and_boxes) | 2 | βœ… | βœ… | Players put lines between dots to form boxes to get points. πŸ”Ά | [Dou Dizhu](https://en.wikipedia.org/wiki/Dou_dizhu) | 3 | ❌ | ❌ | A three-player games where one player (dizhu) plays against a team of two (peasants). πŸ”Ά | [Euchre](https://en.wikipedia.org/wiki/Euchre) | 4 | ❌ | ❌ | Trick-taking card game where players compete in pairs. +πŸ”Ά | [EinStein wΓΌrfelt nicht!](https://en.wikipedia.org/wiki/EinStein_w%C3%BCrfelt_nicht!) | 2 | ❌ | βœ… | Players control 6 numbered cubes, selected randomly by the roll of a die. The player that gets on the opponent's board corner, or captures all the opponent's cubes wins. 🟒 | [First-price Sealed-Bid Auction](https://en.wikipedia.org/wiki/First-price_sealed-bid_auction) | 2-10 | ❌ | ❌ | Agents submit bids simultaneously; highest bid wins, and that's the price paid. 🟒 | [Gin Rummy](https://en.wikipedia.org/wiki/Gin_rummy) | 2 | ❌ | ❌ | Players score points by forming specific sets with the cards in their hands. 🟒 | [Go](https://en.wikipedia.org/wiki/Go_\(game\)) | 2 | βœ… | βœ… | Players place tokens on the board with the goal of encircling territory. diff --git a/open_spiel/games/CMakeLists.txt b/open_spiel/games/CMakeLists.txt index 3500805a66..c2419ae6d8 100644 --- a/open_spiel/games/CMakeLists.txt +++ b/open_spiel/games/CMakeLists.txt @@ -71,6 +71,8 @@ set(GAME_SOURCES efg_game/efg_game.h efg_game/efg_game_data.cc efg_game/efg_game_data.h + einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc + einstein_wurfelt_nicht/einstein_wurfelt_nicht.h euchre/euchre.cc euchre/euchre.h first_sealed_auction/first_sealed_auction.cc @@ -422,6 +424,10 @@ add_executable(efg_game_test efg_game/efg_game_test.cc ${OPEN_SPIEL_OBJECTS} $) add_test(efg_game_test efg_game_test) +add_executable(einstein_wurfelt_nicht_test einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc ${OPEN_SPIEL_OBJECTS} + $) +add_test(einstein_wurfelt_nicht_test einstein_wurfelt_nicht_test) + add_executable(euchre_test euchre/euchre_test.cc ${OPEN_SPIEL_OBJECTS} $) add_test(euchre_test euchre_test) diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc new file mode 100644 index 0000000000..0dae508e64 --- /dev/null +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc @@ -0,0 +1,508 @@ +// Copyright 2024 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h" + +#include +#include +#include +#include + +#include "open_spiel/game_parameters.h" +#include "open_spiel/utils/tensor_view.h" + +namespace open_spiel { +namespace einstein_wurfelt_nicht { +namespace { + +const std::vector> kChanceOutcomes = { + std::pair(0, 1.0 / 6), + std::pair(1, 1.0 / 6), + std::pair(2, 1.0 / 6), + std::pair(3, 1.0 / 6), + std::pair(4, 1.0 / 6), + std::pair(5, 1.0 / 6) +}; + +// Number of unique directions each cube can take. +constexpr int kNumDirections = 6; + +// Direction offsets for black, then white. +constexpr std::array kDirRowOffsets = { + {1, 1, 0, -1, -1, 0}}; + +constexpr std::array kDirColOffsets = { + {1, 0, 1, 0, -1, -1}}; + +// Facts about the game +const GameType kGameType{/*short_name=*/"einstein_wurfelt_nicht", + /*long_name=*/"einstein_wurfelt_nicht", + GameType::Dynamics::kSequential, + GameType::ChanceMode::kExplicitStochastic, + GameType::Information::kPerfectInformation, + GameType::Utility::kZeroSum, + GameType::RewardModel::kTerminal, + /*max_num_players=*/2, + /*min_num_players=*/2, + /*provides_information_state_string=*/false, + /*provides_information_state_tensor=*/false, + /*provides_observation_string=*/true, + /*provides_observation_tensor=*/true, + /*parameter_specification=*/ + {{"seed", GameParameter(-1)}}}; + +std::shared_ptr Factory(const GameParameters& params) { + return std::shared_ptr(new EinsteinWurfeltNichtGame(params)); +} + +REGISTER_SPIEL_GAME(kGameType, Factory); + +RegisterSingleTensorObserver single_tensor(kGameType.short_name); + +Color PlayerToColor(Player player) { + SPIEL_CHECK_NE(player, kInvalidPlayer); + return static_cast(player); +} + +Player ColorToPlayer(Color color) { + switch (color) { + case Color::kBlack: + return kBlackPlayerId; + case Color::kWhite: + return kWhitePlayerId; + default: + SpielFatalError("No player for this color"); + } +} + +Color OpponentColor(Player player) { + Color player_color = PlayerToColor(player); + if (player_color == Color::kBlack) { + return Color::kWhite; + } else if (player_color == Color::kWhite) { + return Color::kBlack; + } else { + SpielFatalError("Player should be either black or white"); + } +} + +std::string CoordinatesToDirection(int row, int col) { + std::string direction; + if (row == col) { + direction = "diag"; + } else if (row == -1) { + direction = "up"; + } else if (row == 1) { + direction = "down"; + } else if (col == 1) { + direction = "right"; + } else if (col == -1) { + direction = "left"; + } else { + std::cout << "r2: " << row << "c2: " << col << std::endl; + SpielFatalError("Unrecognized cube's movement"); + } + return direction; +} + +} // namespace + +EinsteinWurfeltNichtState::EinsteinWurfeltNichtState( + std::shared_ptr game, int rows, int cols, int seed) + : State(game), + rows_(rows), + cols_(cols), + seed_(seed), + cur_player_(kChancePlayerId), + prev_player_(kBlackPlayerId) { + SPIEL_CHECK_GT(rows_, 1); + SPIEL_CHECK_GT(cols_, 1); + + std::vector> players_cubes{{1, 2, 3, 4, 5, 6}, + {1, 2, 3, 4, 5, 6}}; + int player_cube_seed = seed_; + for (int i = 0; i < 2; ++i) { + if (seed_ == -1) { + player_cube_seed = + std::chrono::system_clock::now().time_since_epoch().count(); + } + player_cube_seed += 1; // make sure to have different seeds for each player + std::default_random_engine rng(player_cube_seed); + std::shuffle(players_cubes[i].begin(), players_cubes[i].end(), rng); + } + + // Values in the upper-left corner (black cubes) have a postion identified + // as rows+cols <= 2. Values in the lower-right corner (white cubes) have a + // position identified as rows+cols >= 6. The rest of the board is empty. + for (int r = 0; r < kDefaultRows; r++) { + for (int c = 0; c < kDefaultColumns; c++) { + if (r+c <= 2) { + board_[r*kDefaultColumns+c] = + Cube{Color::kBlack, players_cubes[0].back()}; + players_cubes[0].pop_back(); + } else if (r+c >= 6) { + board_[r*kDefaultColumns+c] = + Cube{Color::kWhite, players_cubes[1].back()}; + players_cubes[1].pop_back(); + } else { + board_[r*kDefaultColumns+c] = Cube{Color::kEmpty, -1}; + } + } + } + + winner_ = kInvalidPlayer; + cubes_[0] = cubes_[1] = kNumPlayerCubes; +} + +int EinsteinWurfeltNichtState::CurrentPlayer() const { + if (IsTerminal()) { + return kTerminalPlayerId; + } else { + return cur_player_; + } +} + +int EinsteinWurfeltNichtState::Opponent(int player) const { return 1 - player; } + +std::vector> +EinsteinWurfeltNichtState::AvailableCubesPosition(Color player_color) const { + std::vector> player_cubes; + for (int r = 0; r < rows_; r++) { + for (int c = 0; c < cols_; c++) { + if (board(r, c).color == player_color) { + if (board(r, c).value == die_roll_) { + // If there is a cube with the same value as the die, + // return only this one + std::vector> player_cube; + player_cube.push_back({board(r, c).value, r, c}); + return player_cube; + } else { + player_cubes.push_back({r, c}); + } + } + } + } + + // Initialise lowest/highest cube values to out-of-bound cube's values + std::vector lowest_cube = {0, 0, 0}; // cube value, r, c + std::vector highest_cube = {7, 0, 0}; // cube value, r, c + for (int i = 0; i < player_cubes.size(); ++i) { + int r = player_cubes[i].first; + int c = player_cubes[i].second; + if (board(r, c).value > lowest_cube[0] && board(r, c).value < die_roll_) { + lowest_cube[0] = board(r, c).value; + lowest_cube[1] = r; + lowest_cube[2] = c; + } else if (board(r, c).value < highest_cube[0] && + board(r, c).value > die_roll_) { + highest_cube[0] = board(r, c).value; + highest_cube[1] = r; + highest_cube[2] = c; + } + } + + std::vector> selected_cubes; + if (lowest_cube[0] > 0) { + selected_cubes.push_back(lowest_cube); + } + if (highest_cube[0] < 7) { + selected_cubes.push_back(highest_cube); + } + + // Legal actions have to be sorted. Sort by row first, then by column + std::sort(selected_cubes.begin(), selected_cubes.end(), + [](const std::vector& a, const std::vector& b) { + if (a[1] != b[1]) return a[1] < b[1]; + return a[2] < b[2]; + }); + + return selected_cubes; +} + +void EinsteinWurfeltNichtState::DoApplyAction(Action action) { + if (IsChanceNode()) { + SPIEL_CHECK_GE(action, 0); + SPIEL_CHECK_LE(action, 5); + turn_history_info_.push_back(TurnHistoryInfo(kChancePlayerId, + prev_player_, + die_roll_, + action, + Cube{Color::kEmpty, -1})); + cur_player_ = Opponent(prev_player_); + prev_player_ = cur_player_; + die_roll_ = action + 1; + return; + } + + // The die should have been rolled at least once at this point + SPIEL_CHECK_GE(die_roll_, 1); + SPIEL_CHECK_LE(die_roll_, 6); + + std::vector values = + UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); + int r1 = values[0]; + int c1 = values[1]; + int dir = values[2]; + bool capture = values[3] == 1; + int r2 = r1 + kDirRowOffsets[dir]; + int c2 = c1 + kDirColOffsets[dir]; + + SPIEL_CHECK_TRUE(InBounds(r1, c1)); + SPIEL_CHECK_TRUE(InBounds(r2, c2)); + + // Remove cubes if captured. + if (board(r2, c2).color == Color::kBlack) { + cubes_[ColorToPlayer(Color::kBlack)]--; + } else if (board(r2, c2).color == Color::kWhite) { + cubes_[ColorToPlayer(Color::kWhite)]--; + } + + Cube captured_cube = (capture) ? board(r2, c2) : Cube{Color::kEmpty, -1}; + turn_history_info_.push_back( + TurnHistoryInfo(cur_player_, + prev_player_, + die_roll_, + action, + captured_cube)); + + SetBoard(r2, c2, board(r1, c1)); + SetBoard(r1, c1, Cube{Color::kEmpty, -1}); + + // Check for winner. + if ((cur_player_ == 0 && r2 == (rows_ - 1) && c2 == (cols_ - 1)) || + (cubes_[ColorToPlayer(Color::kWhite)] == 0)) { + winner_ = 0; + } else if ((cur_player_ == 1 && r2 == 0 && c2 == 0) || + (cubes_[ColorToPlayer(Color::kBlack)] == 0)) { + winner_ = 1; + } + + cur_player_ = NextPlayerRoundRobin(cur_player_, kNumPlayers); + cur_player_ = kChancePlayerId; +} + +std::string EinsteinWurfeltNichtState::ActionToString(Player player, + Action action) const { + std::vector values = + UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); + int r1 = values[0]; + int c1 = values[1]; + int dir = values[2]; + bool capture = values[3] == 1; + int r2 = kDirRowOffsets[dir]; + int c2 = kDirColOffsets[dir]; + + std::string action_string = ""; + + if (IsChanceNode()) { + absl::StrAppend(&action_string, "roll ", action+1); + return action_string; + } + + Cube cube = board(r1, c1); + std::string color = (cube.color == Color::kBlack) ? "B" : "W"; + + std::string direction = CoordinatesToDirection(r2, c2); + absl::StrAppend(&action_string, color); + absl::StrAppend(&action_string, cube.value); + absl::StrAppend(&action_string, "-"); + absl::StrAppend(&action_string, direction); + if (capture) { + absl::StrAppend(&action_string, "*"); + } + return action_string; +} + +std::vector EinsteinWurfeltNichtState::LegalActions() const { + if (IsChanceNode()) return LegalChanceOutcomes(); + if (IsTerminal()) return {}; + + std::vector movelist; + if (IsTerminal()) return movelist; + const Player player = CurrentPlayer(); + Color player_color = PlayerToColor(player); + std::vector action_bases = {rows_, cols_, kNumDirections, 2}; + std::vector action_values = {0, 0, 0, 0}; + + std::vector> available_cubes; + available_cubes = AvailableCubesPosition(player_color); + + for (int i = 0; i < available_cubes.size(); ++i) { + int r = available_cubes[i][1]; + int c = available_cubes[i][2]; + for (int o = 0; o < kNumDirections / 2; o++) { + int dir = player * kNumDirections / 2 + o; + int rp = r + kDirRowOffsets[dir]; + int cp = c + kDirColOffsets[dir]; + if (InBounds(rp, cp)) { + action_values[0] = r; + action_values[1] = c; + action_values[2] = dir; + if (board(rp, cp).color == Color::kEmpty) { + action_values[3] = 0; // no capture + movelist.push_back( + RankActionMixedBase(action_bases, action_values)); + } else { + action_values[3] = 1; // capture + movelist.push_back( + RankActionMixedBase(action_bases, action_values)); + } + } + } + } + return movelist; +} + +std::vector> +EinsteinWurfeltNichtState::ChanceOutcomes() const { + SPIEL_CHECK_TRUE(IsChanceNode()); + return kChanceOutcomes; +} + +bool EinsteinWurfeltNichtState::InBounds(int r, int c) const { + return (r >= 0 && r < rows_ && c >= 0 && c < cols_); +} + +std::string EinsteinWurfeltNichtState::ToString() const { + std::string W_result = ""; + + for (int r = 0; r < kDefaultRows; r++) { + for (int c = 0; c < kDefaultColumns; c++) { + if (board_[r*kDefaultColumns+c].color == Color::kBlack) { + absl::StrAppend(&W_result, "|b"); + absl::StrAppend(&W_result, board_[r*kDefaultColumns+c].value); + absl::StrAppend(&W_result, "|"); + } else if (board_[r*kDefaultColumns+c].color == Color::kWhite) { + absl::StrAppend(&W_result, "|w"); + absl::StrAppend(&W_result, board_[r*kDefaultColumns+c].value); + absl::StrAppend(&W_result, "|"); + } else { + absl::StrAppend(&W_result, "|__|"); + } + } + W_result.append("\n"); + } + return W_result; +} + +bool EinsteinWurfeltNichtState::IsTerminal() const { + return (winner_ >= 0 || (cubes_[0] == 0 || cubes_[1] == 0)); +} + +std::vector EinsteinWurfeltNichtState::Returns() const { + if (winner_ == 0 || cubes_[1] == 0) { + return {1.0, -1.0}; + } else if (winner_ == 1 || cubes_[0] == 0) { + return {-1.0, 1.0}; + } else { + return {0.0, 0.0}; + } +} + +std::string EinsteinWurfeltNichtState::ObservationString(Player player) const { + SPIEL_CHECK_GE(player, 0); + SPIEL_CHECK_LT(player, num_players_); + return ToString(); +} + +void EinsteinWurfeltNichtState::ObservationTensor(Player player, + absl::Span values) const { + SPIEL_CHECK_GE(player, 0); + SPIEL_CHECK_LT(player, num_players_); + + auto value_it = values.begin(); + + for (int cube_num = 1; cube_num < kNumPlayerCubes+1; ++cube_num) { + for (int player_idx = 0; player_idx < kNumPlayers; ++player_idx) { + for (int8_t y = 0; y < kDefaultRows; ++y) { + for (int8_t x = 0; x < kDefaultColumns; ++x) { + *value_it++ = + (board(x, y).value == cube_num && + board(x, y).color == PlayerToColor(player_idx) + ? 1.0 + : 0.0); + } + } + } + } +} + +void EinsteinWurfeltNichtState::UndoAction(Player player, Action action) { + const TurnHistoryInfo& thi = turn_history_info_.back(); + SPIEL_CHECK_EQ(thi.player, player); + SPIEL_CHECK_EQ(action, thi.action); + + if (player != kChancePlayerId) { + std::vector values = + UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); + int r1 = values[0]; + int c1 = values[1]; + int dir = values[2]; + bool capture = values[3] == 1; + int r2 = r1 + kDirRowOffsets[dir]; + int c2 = c1 + kDirColOffsets[dir]; + Cube captured_cube = thi.captured_cube; + + SetBoard(r1, c1, board(r2, c2)); + if (captured_cube.value != -1) { + SetBoard(r2, c2, captured_cube); + if (captured_cube.color == Color::kBlack) { + cubes_[ColorToPlayer(Color::kBlack)]++; + } else if (captured_cube.color == Color::kWhite) { + cubes_[ColorToPlayer(Color::kWhite)]++; + } + } else { + SetBoard(r2, c2, Cube{Color::kEmpty, -1}); + } + } + // Undo win status. + winner_ = kInvalidPlayer; + + turn_history_info_.pop_back(); + history_.pop_back(); + --move_number_; +} + +std::unique_ptr EinsteinWurfeltNichtState::Clone() const { + return std::unique_ptr(new EinsteinWurfeltNichtState(*this)); +} + +// Setter function used for debugging and tests. Note: this does not set the +// historical information properly, so Undo likely will not work on states +// set this way! +void EinsteinWurfeltNichtState::SetState(int cur_player, + int die_roll, + const std::array board, + int cubes_black, + int cubes_white) { + cur_player_ = cur_player; + die_roll_ = die_roll; + board_ = board; + cubes_[ColorToPlayer(Color::kBlack)] = cubes_black; + cubes_[ColorToPlayer(Color::kWhite)] = cubes_white; +} + +EinsteinWurfeltNichtGame::EinsteinWurfeltNichtGame(const GameParameters& params) + : Game(kGameType, params), + rows_(kDefaultRows), + cols_(kDefaultColumns), + seed_(ParameterValue("seed")) {} + +int EinsteinWurfeltNichtGame::NumDistinctActions() const { + return rows_ * cols_ * kNumDirections * 2; +} + +} // namespace einstein_wurfelt_nicht +} // namespace open_spiel diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h new file mode 100644 index 0000000000..6268566340 --- /dev/null +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h @@ -0,0 +1,160 @@ +// Copyright 2024 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPEN_SPIEL_GAMES_EINSTEIN_WURFELT_NICHT_H_ +#define OPEN_SPIEL_GAMES_EINSTEIN_WURFELT_NICHT_H_ + +#include +#include +#include +#include +#include +#include + +#include "open_spiel/spiel.h" +#include "open_spiel/spiel_utils.h" + +// An implementation of the game EinStein wΓΌrfelt nicht! +// This is the implementation of the basic game with a 5x5 board and 6 cubes +// per player. +// https://en.wikipedia.org/wiki/EinStein_w%C3%BCrfelt_nicht! +// +// Parameters: +// "seed" int random seed for placement of cubes on the board [1] (default=-1) +// +// [1] When the seed is -1, the current time is used as the seed, so that the +// assignment of cubes is random each time the game is played. + +namespace open_spiel { +namespace einstein_wurfelt_nicht { + +enum class Color : int8_t { kBlack = 0, kWhite = 1, kEmpty = 2 }; + +struct Cube { + Color color; + int value; // player's die value +}; + +inline constexpr int kNumPlayers = 2; +inline constexpr int kBlackPlayerId = 0; +inline constexpr int kWhitePlayerId = 1; +inline constexpr int kNumPlayerCubes = 6; +inline constexpr int kDefaultRows = 5; +inline constexpr int kDefaultColumns = 5; +inline constexpr int k2dMaxBoardSize = kDefaultRows * kDefaultColumns; +inline constexpr const int kStateEncodingSize = kNumPlayers * kNumPlayerCubes * + kDefaultRows * kDefaultColumns; + +// This is a small helper to track historical turn info not stored in the moves. +// It is only needed for proper implementation of Undo. +struct TurnHistoryInfo { + int player; + int prev_player; + int die_roll_; + Action action; + Cube captured_cube; + TurnHistoryInfo(int _player, int _prev_player, int _die_roll, + int _action, Cube _captured_cube) + : player(_player), + prev_player(_prev_player), + die_roll_(_die_roll), + action(_action), + captured_cube(_captured_cube) {} +}; + +class EinsteinWurfeltNichtState : public State { + public: + explicit EinsteinWurfeltNichtState(std::shared_ptr game, int rows, + int cols, int seed); + Player CurrentPlayer() const override; + // Returns the opponent of the specified player. + int Opponent(int player) const; + std::vector> AvailableCubesPosition(Color color) const; + std::string ActionToString(Player player, Action action) const override; + std::string ToString() const override; + bool IsTerminal() const override; + std::vector Returns() const override; + std::string ObservationString(Player player) const override; + void ObservationTensor(Player player, + absl::Span values) const override; + std::unique_ptr Clone() const override; + void UndoAction(Player player, Action action) override; + + bool InBounds(int r, int c) const; + void SetBoard(int r, int c, Cube cube) { board_[r * cols_ + c] = cube; } + Cube board(int row, int col) const { return board_[row * cols_ + col]; } + std::vector LegalActions() const override; + std::vector> ChanceOutcomes() const override; + void SetState(int cur_player, int die_roll, + const std::array board, + int cubes_black, int cubes_white); + + protected: + void DoApplyAction(Action action) override; + + private: + Player cur_player_ = kInvalidPlayer; + Player prev_player_ = kInvalidPlayer; + int winner_ = kInvalidPlayer; + int total_moves_ = -1; + std::array cubes_; + int rows_ = -1; + int cols_ = -1; + int seed_ = -1; + int die_roll_ = 0; + std::array board_; // for (row,col) we use row*cols_+col + std::vector turn_history_info_; +}; + +class EinsteinWurfeltNichtGame : public Game { + public: + explicit EinsteinWurfeltNichtGame(const GameParameters& params); + int NumDistinctActions() const override; + std::unique_ptr NewInitialState() const override { + return std::unique_ptr( + new EinsteinWurfeltNichtState(shared_from_this(), rows_, cols_, seed_)); + } + + int MaxChanceOutcomes() const override { return 6; } + + int NumPlayers() const override { return kNumPlayers; } + double MinUtility() const override { return -1; } + absl::optional UtilitySum() const override { return 0; } + double MaxUtility() const override { return 1; } + std::vector ObservationTensorShape() const override { + return {kStateEncodingSize}; + } + + // Assuming that each cube is moved first along the horizontal axis and then + // along the vertical axis, which is the maximum number of moves for a cube + // (only the cubes in the corners). This accounts for (row-1) * (cols-1) + // moves. If we assume that each player makes all these moves we get + // (row-1) * (cols-1) * num_players. If we consider the chance player as + // the third player which makes the same number of moves, the upper bound + // for the number of moves is (row-1) * (cols-1) * (num_players + 1). + int MaxGameLength() const override { + return (kDefaultRows - 1) * (kDefaultColumns - 1) * (kNumPlayerCubes + 1); + } + + private: + int rows_ = -1; + int cols_ = -1; + int seed_ = -1; +}; + +} // namespace einstein_wurfelt_nicht +} // namespace open_spiel + +#endif // OPEN_SPIEL_GAMES_EINSTEIN_WURFELT_NICHT_H_ diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc new file mode 100644 index 0000000000..50fd3da486 --- /dev/null +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc @@ -0,0 +1,277 @@ +// Copyright 2024 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h" + +#include "open_spiel/spiel.h" +#include "open_spiel/tests/basic_tests.h" + +namespace open_spiel { +namespace einstein_wurfelt_nicht { +namespace { + +namespace testing = open_spiel::testing; + +void BasicEinsteinWurfeltNitchTests() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + testing::RandomSimTest(*game, 100, true, true); + testing::RandomSimTestWithUndo(*game, 1); +} + +void BlackPlayerSimpleWinTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + EinsteinWurfeltNichtState* bstate = + static_cast(state.get()); + + int values[] = {-1, 2, -1, -1, -1, -1, -1, -1, 5, -1, 6, -1, -1, -1, -1, -1, + 3, -1, -1, 3, -1, -1, -1, -1, -1}; + Color colors[] = {Color::kEmpty, Color::kWhite, Color::kEmpty, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kBlack, Color::kEmpty, Color::kBlack, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kWhite, Color::kEmpty, Color::kEmpty, Color::kBlack, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty}; + std::array board; + for (int i = 0; i < k2dMaxBoardSize; i++) { + board[i] = {colors[i], values[i]}; + } + + bstate->SetState(kBlackPlayerId, 2, board, 3, 2); + + std::string expected_state = + "|__||w2||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state); + SPIEL_CHECK_EQ(bstate->CurrentPlayer(), kBlackPlayerId); + SPIEL_CHECK_FALSE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(bstate->LegalActions().size(), 1); + Action action = 230; // Move B3 down + SPIEL_CHECK_EQ(bstate->LegalActions()[0], 230); + SPIEL_CHECK_EQ(bstate->ActionToString(kBlackPlayerId, 230), "B3-down"); + + bstate->ApplyAction(230); + std::string expected_state_final = + "|__||w2||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||__|\n" + "|__||__||__||__||b3|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state_final); + std::vector returns = bstate->Returns(); + SPIEL_CHECK_TRUE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_EQ(returns[0], 1); + SPIEL_CHECK_EQ(returns[1], -1); +} + +void WhitePlayerSimpleWinTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + EinsteinWurfeltNichtState* bstate = + static_cast(state.get()); + + int values[] = {-1, 2, -1, -1, -1, -1, -1, -1, 5, -1, 6, -1, -1, -1, -1, -1, + 3, -1, -1, 3, -1, -1, -1, -1, -1}; + Color colors[] = {Color::kEmpty, Color::kWhite, Color::kEmpty, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kBlack, Color::kEmpty, Color::kBlack, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kWhite, Color::kEmpty, Color::kEmpty, Color::kBlack, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty}; + std::array board; + for (int i = 0; i < k2dMaxBoardSize; i++) { + board[i] = {colors[i], values[i]}; + } + bstate->SetState(kWhitePlayerId, 2, board, 3, 2); + + std::string expected_state = + "|__||w2||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state); + SPIEL_CHECK_EQ(bstate->CurrentPlayer(), kWhitePlayerId); + SPIEL_CHECK_FALSE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(bstate->LegalActions().size(), 1); + Action action = 22; // Move W2 to the left + SPIEL_CHECK_EQ(bstate->LegalActions()[0], action); + SPIEL_CHECK_EQ(bstate->ActionToString(kWhitePlayerId, action), "W2-left"); + + bstate->ApplyAction(action); + std::string expected_state_final = + "|w2||__||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state_final); + std::vector returns = bstate->Returns(); + SPIEL_CHECK_TRUE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_EQ(returns[0], -1); + SPIEL_CHECK_EQ(returns[1], 1); +} + +void WinByCapturingAllOpponentCubesTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + EinsteinWurfeltNichtState* bstate = + static_cast(state.get()); + + int values[] = {-1, -1, -1, -1, -1, -1, -1, -1, 5, -1, 6, -1, -1, -1, -1, -1, + 3, -1, -1, 3, -1, -1, -1, -1, -1}; + Color colors[] = {Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kBlack, Color::kEmpty, Color::kBlack, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kWhite, Color::kEmpty, Color::kEmpty, Color::kBlack, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty}; + std::array board; + for (int i = 0; i < k2dMaxBoardSize; i++) { + board[i] = {colors[i], values[i]}; + } + bstate->SetState(kBlackPlayerId, 6, board, 3, 1); + + std::string expected_state = + "|__||__||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state); + SPIEL_CHECK_EQ(bstate->CurrentPlayer(), kBlackPlayerId); + SPIEL_CHECK_FALSE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(bstate->LegalActions().size(), 3); + Action action = 121; // Move B6 diagonally down-right + SPIEL_CHECK_EQ(bstate->LegalActions()[0], action); + SPIEL_CHECK_EQ(bstate->ActionToString(kBlackPlayerId, action), "B6-diag*"); + + bstate->ApplyAction(action); + std::string expected_state_final = + "|__||__||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|__||__||__||__||__|\n" + "|__||b6||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state_final); + std::vector returns = bstate->Returns(); + SPIEL_CHECK_TRUE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_EQ(returns[0], 1); + SPIEL_CHECK_EQ(returns[1], -1); +} + +void CheckAlternateChancePlayerAndNormalPlayerTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + + int previous_player = state->CurrentPlayer(); + + while (!state->IsTerminal()) { + if (state->CurrentPlayer() == open_spiel::kChancePlayerId) { + state->ApplyAction(state->LegalActions()[0]); + } else { + std::vector legal_actions = state->LegalActions(); + state->ApplyAction(legal_actions[0]); + } + int current_player = state->CurrentPlayer(); + if (current_player != open_spiel::kChancePlayerId) { + SPIEL_CHECK_NE(current_player, previous_player); + } + previous_player = current_player; + } +} + +void InitialStateTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + SPIEL_CHECK_EQ(state->CurrentPlayer(), open_spiel::kChancePlayerId); + SPIEL_CHECK_FALSE(state->IsTerminal()); +} + +void LegalActionsTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(42); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + + while (!state->IsTerminal()) { + std::vector legal_actions = state->LegalActions(); + SPIEL_CHECK_FALSE(legal_actions.empty()); + state->ApplyAction(legal_actions[0]); + } + + std::vector returns = state->Returns(); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_TRUE(returns[0] == 1.0 || returns[1] == 1.0); +} + +void RandomBoardSetupTest() { + open_spiel::GameParameters params; + params["seed"] = open_spiel::GameParameter(-1); + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state = game->NewInitialState(); + + std::shared_ptr game2 = + open_spiel::LoadGame("einstein_wurfelt_nicht", params); + std::unique_ptr state2 = game->NewInitialState(); + + SPIEL_CHECK_NE(state->ToString(), state2->ToString()); +} + +} // namespace +} // namespace einstein_wurfelt_nicht +} // namespace open_spiel + +int main(int argc, char** argv) { + open_spiel::testing::LoadGameTest("einstein_wurfelt_nicht"); + open_spiel::einstein_wurfelt_nicht::BasicEinsteinWurfeltNitchTests(); + open_spiel::einstein_wurfelt_nicht::WinByCapturingAllOpponentCubesTest(); + open_spiel::einstein_wurfelt_nicht:: + CheckAlternateChancePlayerAndNormalPlayerTest(); + open_spiel::einstein_wurfelt_nicht::InitialStateTest(); + open_spiel::einstein_wurfelt_nicht::LegalActionsTest(); + open_spiel::einstein_wurfelt_nicht::BlackPlayerSimpleWinTest(); + open_spiel::einstein_wurfelt_nicht::WhitePlayerSimpleWinTest(); + open_spiel::einstein_wurfelt_nicht::WinByCapturingAllOpponentCubesTest(); + open_spiel::einstein_wurfelt_nicht::RandomBoardSetupTest(); +} diff --git a/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt b/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt new file mode 100644 index 0000000000..87b125e1eb --- /dev/null +++ b/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt @@ -0,0 +1,424 @@ +game: einstein_wurfelt_nicht + +GameType.chance_mode = ChanceMode.EXPLICIT_STOCHASTIC +GameType.dynamics = Dynamics.SEQUENTIAL +GameType.information = Information.PERFECT_INFORMATION +GameType.long_name = "einstein_wurfelt_nicht" +GameType.max_num_players = 2 +GameType.min_num_players = 2 +GameType.parameter_specification = ["columns", "rows", "seed"] +GameType.provides_information_state_string = False +GameType.provides_information_state_tensor = False +GameType.provides_observation_string = True +GameType.provides_observation_tensor = True +GameType.provides_factored_observation_string = False +GameType.reward_model = RewardModel.TERMINAL +GameType.short_name = "einstein_wurfelt_nicht" +GameType.utility = Utility.ZERO_SUM + +NumDistinctActions() = 300 +PolicyTensorShape() = [300] +MaxChanceOutcomes() = 6 +GetParameters() = {columns=5,rows=5,seed=-1} +NumPlayers() = 2 +MinUtility() = -1.0 +MaxUtility() = 1.0 +UtilitySum() = 0.0 +ObservationTensorShape() = [300] +ObservationTensorLayout() = TensorLayout.CHW +ObservationTensorSize() = 300 +MaxGameLength() = 71 +ToString() = "einstein_wurfelt_nicht()" + +# State 0 +# |b2||b1||b6||__||__| +# |b4||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||__||w1||w6| +# |__||__||w4||w5||w3| +IsTerminal() = False +History() = [] +HistoryString() = "" +IsChanceNode() = True +IsSimultaneousNode() = False +CurrentPlayer() = -1 +ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" +ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" +ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) +ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) +ChanceOutcomes() = [(0,0.166667), (1,0.166667), (2,0.166667), (3,0.166667), (4,0.166667), (5,0.166667)] +LegalActions() = [0, 1, 2, 3, 4, 5] +StringLegalActions() = ["roll 1", "roll 2", "roll 3", "roll 4", "roll 5", "roll 6"] + +# Apply action "roll 3" +action: 2 + +# State 1 +# |b2||b1||b6||__||__| +# |b4||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||__||w1||w6| +# |__||__||w4||w5||w3| +IsTerminal() = False +History() = [2] +HistoryString() = "2" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" +ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" +ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) +ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [295, 297, 299] +StringLegalActions() = ["W3-up*", "W3-diag*", "W3-left*"] + +# Apply action "W3-left*" +action: 299 + +# State 2 +# |b2||b1||b6||__||__| +# |b4||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||__||w1||w6| +# |__||__||w4||w3||__| +IsTerminal() = False +History() = [2, 299] +HistoryString() = "2, 299" +IsChanceNode() = True +IsSimultaneousNode() = False +CurrentPlayer() = -1 +ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" +ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" +ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) +ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) +ChanceOutcomes() = [(0,0.166667), (1,0.166667), (2,0.166667), (3,0.166667), (4,0.166667), (5,0.166667)] +LegalActions() = [0, 1, 2, 3, 4, 5] +StringLegalActions() = ["roll 1", "roll 2", "roll 3", "roll 4", "roll 5", "roll 6"] + +# Apply action "roll 2" +action: 1 + +# State 3 +# |b2||b1||b6||__||__| +# |b4||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||__||w1||w6| +# |__||__||w4||w3||__| +IsTerminal() = False +History() = [2, 299, 1] +HistoryString() = "2, 299, 1" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" +ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" +ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) +ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [1, 3, 5] +StringLegalActions() = ["B2-diag*", "B2-down*", "B2-right*"] + +# Apply action "B2-down*" +action: 3 + +# State 4 +# Apply action "roll 5" +action: 4 + +# State 5 +# |__||b1||b6||__||__| +# |b2||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||__||w1||w6| +# |__||__||w4||w3||__| +IsTerminal() = False +History() = [2, 299, 1, 3, 4] +HistoryString() = "2, 299, 1, 3, 4" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" +ObservationString(1) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" +ObservationTensor(0): binvec(300, 0x40000000010100000000000420000000000800000000004000200000000000008000000002) +ObservationTensor(1): binvec(300, 0x40000000010100000000000420000000000800000000004000200000000000008000000002) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [270, 272, 274, 235, 236, 239] +StringLegalActions() = ["W4-up", "W4-diag", "W4-left", "W6-up*", "W6-diag", "W6-left*"] + +# Apply action "W4-up" +action: 270 + +# State 6 +# Apply action "roll 1" +action: 0 + +# State 7 +# |__||b1||b6||__||__| +# |b2||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||w4||w1||w6| +# |__||__||__||w3||__| +IsTerminal() = False +History() = [2, 299, 1, 3, 4, 270, 0] +HistoryString() = "2, 299, 1, 3, 4, 270, 0" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" +ObservationString(1) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" +ObservationTensor(0): binvec(300, 0x40000000010100000000000420000000000800000000008000200000000000008000000002) +ObservationTensor(1): binvec(300, 0x40000000010100000000000420000000000800000000008000200000000000008000000002) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [12, 15, 17] +StringLegalActions() = ["B1-diag", "B1-down*", "B1-right*"] + +# Apply action "B1-right*" +action: 17 + +# State 8 +# Apply action "roll 3" +action: 2 + +# State 9 +# |__||__||b1||__||__| +# |b2||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||w4||w1||w6| +# |__||__||__||w3||__| +IsTerminal() = False +History() = [2, 299, 1, 3, 4, 270, 0, 17, 2] +HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" +ObservationString(1) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" +ObservationTensor(0): binvec(300, 0x2000000010100000000000420000000000800000000008000200000000000000000000002) +ObservationTensor(1): binvec(300, 0x2000000010100000000000420000000000800000000008000200000000000000000000002) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [283, 285, 286] +StringLegalActions() = ["W3-up*", "W3-diag*", "W3-left"] + +# Apply action "W3-left" +action: 286 + +# State 10 +# Apply action "roll 4" +action: 3 + +# State 11 +# |__||__||b1||__||__| +# |b2||b5||__||__||__| +# |b3||__||__||__||w2| +# |__||__||w4||w1||w6| +# |__||__||w3||__||__| +IsTerminal() = False +History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3] +HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||w3||__||__|\n" +ObservationString(1) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||w3||__||__|\n" +ObservationTensor(0): binvec(300, 0x2000000010100000000000420000000010000000000008000200000000000000000000002) +ObservationTensor(1): binvec(300, 0x2000000010100000000000420000000010000000000008000200000000000000000000002) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [120, 122, 124, 72, 74, 76] +StringLegalActions() = ["B3-diag", "B3-down", "B3-right", "B5-diag", "B5-down", "B5-right"] + +# Apply action "B5-right" +action: 76 + +# State 12 +# Apply action "roll 2" +action: 1 + +# State 13 +# Apply action "W2-left" +action: 178 + +# State 14 +# Apply action "roll 3" +action: 2 + +# State 15 +# Apply action "B3-diag" +action: 120 + +# State 16 +# Apply action "roll 6" +action: 5 + +# State 17 +# Apply action "W6-diag*" +action: 237 + +# State 18 +# Apply action "roll 2" +action: 1 + +# State 19 +# Apply action "B2-down" +action: 62 + +# State 20 +# Apply action "roll 3" +action: 2 + +# State 21 +# Apply action "W3-left" +action: 274 + +# State 22 +# Apply action "roll 3" +action: 2 + +# State 23 +# Apply action "B3-diag" +action: 192 + +# State 24 +# Apply action "roll 6" +action: 5 + +# State 25 +# Apply action "W6-diag*" +action: 165 + +# State 26 +# Apply action "roll 6" +action: 5 + +# State 27 +# Apply action "B3-right" +action: 268 + +# State 28 +# Apply action "roll 2" +action: 1 + +# State 29 +# Apply action "W1-diag" +action: 224 + +# State 30 +# Apply action "roll 1" +action: 0 + +# State 31 +# Apply action "B1-diag" +action: 24 + +# State 32 +# Apply action "roll 5" +action: 4 + +# State 33 +# Apply action "W4-diag" +action: 212 + +# State 34 +# Apply action "roll 2" +action: 1 + +# State 35 +# Apply action "B2-down" +action: 122 + +# State 36 +# Apply action "roll 4" +action: 3 + +# State 37 +# Apply action "W4-left" +action: 142 + +# State 38 +# Apply action "roll 2" +action: 1 + +# State 39 +# Apply action "B2-right" +action: 184 + +# State 40 +# Apply action "roll 1" +action: 0 + +# State 41 +# |__||__||__||__||__| +# |__||__||w6||b1||__| +# |w4||__||w1||__||__| +# |__||b2||__||__||__| +# |__||w3||__||b3||__| +IsTerminal() = False +History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0] +HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|__||__||__||__||__|\n|__||__||w6||b1||__|\n|w4||__||w1||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" +ObservationString(1) = "|__||__||__||__||__|\n|__||__||w6||b1||__|\n|w4||__||w1||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" +ObservationTensor(0): binvec(300, 0x80000400002000000000000001000200000000004000000000000000000000000002000) +ObservationTensor(1): binvec(300, 0x80000400002000000000000001000200000000004000000000000000000000000002000) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [151, 152, 154] +StringLegalActions() = ["W1-up*", "W1-diag", "W1-left"] + +# Apply action "W1-up*" +action: 151 + +# State 42 +# Apply action "roll 6" +action: 5 + +# State 43 +# |__||__||__||__||__| +# |__||__||w1||b1||__| +# |w4||__||__||__||__| +# |__||b2||__||__||__| +# |__||w3||__||b3||__| +IsTerminal() = False +History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5] +HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" +ObservationString(1) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" +ObservationTensor(0): binvec(300, 0x80000800002000000000000001000200000000004000000000000000000000000000000) +ObservationTensor(1): binvec(300, 0x80000800002000000000000001000200000000004000000000000000000000000000000) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [280] +StringLegalActions() = ["B3-right"] + +# Apply action "B3-right" +action: 280 + +# State 44 +# |__||__||__||__||__| +# |__||__||w1||b1||__| +# |w4||__||__||__||__| +# |__||b2||__||__||__| +# |__||w3||__||__||b3| +IsTerminal() = True +History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5, 280] +HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5, 280" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = -4 +ObservationString(0) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||__||b3|\n" +ObservationString(1) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||__||b3|\n" +ObservationTensor(0): binvec(300, 0x80000800002000000000000000080200000000004000000000000000000000000000000) +ObservationTensor(1): binvec(300, 0x80000800002000000000000000080200000000004000000000000000000000000000000) +Rewards() = [1, -1] +Returns() = [1, -1] diff --git a/open_spiel/python/tests/pyspiel_test.py b/open_spiel/python/tests/pyspiel_test.py index f34ad4f153..7b7f7a0f18 100644 --- a/open_spiel/python/tests/pyspiel_test.py +++ b/open_spiel/python/tests/pyspiel_test.py @@ -56,6 +56,7 @@ "dots_and_boxes", "dou_dizhu", "efg_game", + "einstein_wurfelt_nicht", "euchre", "first_sealed_auction", "gin_rummy", From b86e691dc48f8fa36e41af1d1bae2228d84aa938 Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Sun, 17 Nov 2024 13:03:01 +0000 Subject: [PATCH 2/6] Fix seed and update playthrough. --- .../einstein_wurfelt_nicht.cc | 2 +- .../playthroughs/einstein_wurfelt_nicht.txt | 452 +++++++++--------- 2 files changed, 239 insertions(+), 215 deletions(-) diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc index 0dae508e64..be7a2f1573 100644 --- a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc @@ -60,7 +60,7 @@ const GameType kGameType{/*short_name=*/"einstein_wurfelt_nicht", /*provides_observation_string=*/true, /*provides_observation_tensor=*/true, /*parameter_specification=*/ - {{"seed", GameParameter(-1)}}}; + {{"seed", GameParameter(42)}}}; std::shared_ptr Factory(const GameParameters& params) { return std::shared_ptr(new EinsteinWurfeltNichtGame(params)); diff --git a/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt b/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt index 87b125e1eb..2cc4866e3b 100644 --- a/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt +++ b/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt @@ -6,7 +6,7 @@ GameType.information = Information.PERFECT_INFORMATION GameType.long_name = "einstein_wurfelt_nicht" GameType.max_num_players = 2 GameType.min_num_players = 2 -GameType.parameter_specification = ["columns", "rows", "seed"] +GameType.parameter_specification = ["seed"] GameType.provides_information_state_string = False GameType.provides_information_state_tensor = False GameType.provides_observation_string = True @@ -19,7 +19,7 @@ GameType.utility = Utility.ZERO_SUM NumDistinctActions() = 300 PolicyTensorShape() = [300] MaxChanceOutcomes() = 6 -GetParameters() = {columns=5,rows=5,seed=-1} +GetParameters() = {seed=42} NumPlayers() = 2 MinUtility() = -1.0 MaxUtility() = 1.0 @@ -27,25 +27,25 @@ UtilitySum() = 0.0 ObservationTensorShape() = [300] ObservationTensorLayout() = TensorLayout.CHW ObservationTensorSize() = 300 -MaxGameLength() = 71 +MaxGameLength() = 112 ToString() = "einstein_wurfelt_nicht()" # State 0 -# |b2||b1||b6||__||__| -# |b4||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||__||w1||w6| -# |__||__||w4||w5||w3| +# |b3||b6||b4||__||__| +# |b1||b2||__||__||__| +# |b5||__||__||__||w5| +# |__||__||__||w3||w6| +# |__||__||w2||w1||w4| IsTerminal() = False History() = [] HistoryString() = "" IsChanceNode() = True IsSimultaneousNode() = False CurrentPlayer() = -1 -ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" -ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" -ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) -ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) +ObservationString(0) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||__||w5|\n|__||__||__||w3||w6|\n|__||__||w2||w1||w4|\n" +ObservationString(1) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||__||w5|\n|__||__||__||w3||w6|\n|__||__||w2||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000040080000000001000080000000012000000000010100000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000040080000000001000080000000012000000000010100000000002) ChanceOutcomes() = [(0,0.166667), (1,0.166667), (2,0.166667), (3,0.166667), (4,0.166667), (5,0.166667)] LegalActions() = [0, 1, 2, 3, 4, 5] StringLegalActions() = ["roll 1", "roll 2", "roll 3", "roll 4", "roll 5", "roll 6"] @@ -54,275 +54,275 @@ StringLegalActions() = ["roll 1", "roll 2", "roll 3", "roll 4", "roll 5", "roll action: 2 # State 1 -# |b2||b1||b6||__||__| -# |b4||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||__||w1||w6| -# |__||__||w4||w5||w3| +# |b3||b6||b4||__||__| +# |b1||b2||__||__||__| +# |b5||__||__||__||w5| +# |__||__||__||w3||w6| +# |__||__||w2||w1||w4| IsTerminal() = False History() = [2] HistoryString() = "2" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 1 -ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" -ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w5||w3|\n" -ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) -ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000050000000004000200000000080008000000002) +ObservationString(0) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||__||w5|\n|__||__||__||w3||w6|\n|__||__||w2||w1||w4|\n" +ObservationString(1) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||__||w5|\n|__||__||__||w3||w6|\n|__||__||w2||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000040080000000001000080000000012000000000010100000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000040080000000001000080000000012000000000010100000000002) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [295, 297, 299] -StringLegalActions() = ["W3-up*", "W3-diag*", "W3-left*"] +LegalActions() = [222, 224, 226] +StringLegalActions() = ["W3-up", "W3-diag", "W3-left"] -# Apply action "W3-left*" -action: 299 +# Apply action "W3-up" +action: 222 # State 2 -# |b2||b1||b6||__||__| -# |b4||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||__||w1||w6| -# |__||__||w4||w3||__| +# |b3||b6||b4||__||__| +# |b1||b2||__||__||__| +# |b5||__||__||w3||w5| +# |__||__||__||__||w6| +# |__||__||w2||w1||w4| IsTerminal() = False -History() = [2, 299] -HistoryString() = "2, 299" +History() = [2, 222] +HistoryString() = "2, 222" IsChanceNode() = True IsSimultaneousNode() = False CurrentPlayer() = -1 -ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" -ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" -ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) -ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) +ObservationString(0) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||w3||w5|\n|__||__||__||__||w6|\n|__||__||w2||w1||w4|\n" +ObservationString(1) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||w3||w5|\n|__||__||__||__||w6|\n|__||__||w2||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000040080000000002000080000000012000000000010100000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000040080000000002000080000000012000000000010100000000002) ChanceOutcomes() = [(0,0.166667), (1,0.166667), (2,0.166667), (3,0.166667), (4,0.166667), (5,0.166667)] LegalActions() = [0, 1, 2, 3, 4, 5] StringLegalActions() = ["roll 1", "roll 2", "roll 3", "roll 4", "roll 5", "roll 6"] -# Apply action "roll 2" -action: 1 +# Apply action "roll 6" +action: 5 # State 3 -# |b2||b1||b6||__||__| -# |b4||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||__||w1||w6| -# |__||__||w4||w3||__| +# |b3||b6||b4||__||__| +# |b1||b2||__||__||__| +# |b5||__||__||w3||w5| +# |__||__||__||__||w6| +# |__||__||w2||w1||w4| IsTerminal() = False -History() = [2, 299, 1] -HistoryString() = "2, 299, 1" +History() = [2, 222, 5] +HistoryString() = "2, 222, 5" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 0 -ObservationString(0) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" -ObservationString(1) = "|b2||b1||b6||__||__|\n|b4||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" -ObservationTensor(0): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) -ObservationTensor(1): binvec(300, 0x40000000010200000000000420000000000810000000004000200000000000008000000002) +ObservationString(0) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||w3||w5|\n|__||__||__||__||w6|\n|__||__||w2||w1||w4|\n" +ObservationString(1) = "|b3||b6||b4||__||__|\n|b1||b2||__||__||__|\n|b5||__||__||w3||w5|\n|__||__||__||__||w6|\n|__||__||w2||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000040080000000002000080000000012000000000010100000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000040080000000002000080000000012000000000010100000000002) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [1, 3, 5] -StringLegalActions() = ["B2-diag*", "B2-down*", "B2-right*"] +LegalActions() = [12, 15, 17] +StringLegalActions() = ["B6-diag", "B6-down*", "B6-right*"] -# Apply action "B2-down*" -action: 3 +# Apply action "B6-diag" +action: 12 # State 4 -# Apply action "roll 5" -action: 4 +# Apply action "roll 2" +action: 1 # State 5 -# |__||b1||b6||__||__| -# |b2||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||__||w1||w6| -# |__||__||w4||w3||__| +# |b3||__||b4||__||__| +# |b1||b2||b6||__||__| +# |b5||__||__||w3||w5| +# |__||__||__||__||w6| +# |__||__||w2||w1||w4| IsTerminal() = False -History() = [2, 299, 1, 3, 4] -HistoryString() = "2, 299, 1, 3, 4" +History() = [2, 222, 5, 12, 1] +HistoryString() = "2, 222, 5, 12, 1" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 1 -ObservationString(0) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" -ObservationString(1) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||__||w1||w6|\n|__||__||w4||w3||__|\n" -ObservationTensor(0): binvec(300, 0x40000000010100000000000420000000000800000000004000200000000000008000000002) -ObservationTensor(1): binvec(300, 0x40000000010100000000000420000000000800000000004000200000000000008000000002) +ObservationString(0) = "|b3||__||b4||__||__|\n|b1||b2||b6||__||__|\n|b5||__||__||w3||w5|\n|__||__||__||__||w6|\n|__||__||w2||w1||w4|\n" +ObservationString(1) = "|b3||__||b4||__||__|\n|b1||b2||b6||__||__|\n|b5||__||__||w3||w5|\n|__||__||__||__||w6|\n|__||__||w2||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000040080000000002000080000000012000000000010004000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000040080000000002000080000000012000000000010004000000002) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [270, 272, 274, 235, 236, 239] -StringLegalActions() = ["W4-up", "W4-diag", "W4-left", "W6-up*", "W6-diag", "W6-left*"] +LegalActions() = [270, 272, 274] +StringLegalActions() = ["W2-up", "W2-diag", "W2-left"] -# Apply action "W4-up" +# Apply action "W2-up" action: 270 # State 6 -# Apply action "roll 1" -action: 0 +# Apply action "roll 4" +action: 3 # State 7 -# |__||b1||b6||__||__| -# |b2||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||w4||w1||w6| -# |__||__||__||w3||__| +# |b3||__||b4||__||__| +# |b1||b2||b6||__||__| +# |b5||__||__||w3||w5| +# |__||__||w2||__||w6| +# |__||__||__||w1||w4| IsTerminal() = False -History() = [2, 299, 1, 3, 4, 270, 0] -HistoryString() = "2, 299, 1, 3, 4, 270, 0" +History() = [2, 222, 5, 12, 1, 270, 3] +HistoryString() = "2, 222, 5, 12, 1, 270, 3" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 0 -ObservationString(0) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" -ObservationString(1) = "|__||b1||b6||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" -ObservationTensor(0): binvec(300, 0x40000000010100000000000420000000000800000000008000200000000000008000000002) -ObservationTensor(1): binvec(300, 0x40000000010100000000000420000000000800000000008000200000000000008000000002) +ObservationString(0) = "|b3||__||b4||__||__|\n|b1||b2||b6||__||__|\n|b5||__||__||w3||w5|\n|__||__||w2||__||w6|\n|__||__||__||w1||w4|\n" +ObservationString(1) = "|b3||__||b4||__||__|\n|b1||b2||b6||__||__|\n|b5||__||__||w3||w5|\n|__||__||w2||__||w6|\n|__||__||__||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000080080000000002000080000000012000000000010004000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000080080000000002000080000000012000000000010004000000002) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [12, 15, 17] -StringLegalActions() = ["B1-diag", "B1-down*", "B1-right*"] +LegalActions() = [24, 27, 28] +StringLegalActions() = ["B4-diag", "B4-down*", "B4-right"] -# Apply action "B1-right*" -action: 17 +# Apply action "B4-down*" +action: 27 # State 8 -# Apply action "roll 3" -action: 2 +# Apply action "roll 6" +action: 5 # State 9 -# |__||__||b1||__||__| -# |b2||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||w4||w1||w6| -# |__||__||__||w3||__| +# |b3||__||__||__||__| +# |b1||b2||b4||__||__| +# |b5||__||__||w3||w5| +# |__||__||w2||__||w6| +# |__||__||__||w1||w4| IsTerminal() = False -History() = [2, 299, 1, 3, 4, 270, 0, 17, 2] -HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2" +History() = [2, 222, 5, 12, 1, 270, 3, 27, 5] +HistoryString() = "2, 222, 5, 12, 1, 270, 3, 27, 5" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 1 -ObservationString(0) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" -ObservationString(1) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||__||w3||__|\n" -ObservationTensor(0): binvec(300, 0x2000000010100000000000420000000000800000000008000200000000000000000000002) -ObservationTensor(1): binvec(300, 0x2000000010100000000000420000000000800000000008000200000000000000000000002) +ObservationString(0) = "|b3||__||__||__||__|\n|b1||b2||b4||__||__|\n|b5||__||__||w3||w5|\n|__||__||w2||__||w6|\n|__||__||__||w1||w4|\n" +ObservationString(1) = "|b3||__||__||__||__|\n|b1||b2||b4||__||__|\n|b5||__||__||w3||w5|\n|__||__||w2||__||w6|\n|__||__||__||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000080080000000002000040000000012000000000010000000000002) +ObservationTensor(1): binvec(300, 0x400000000008008000000080080000000002000040000000012000000000010000000000002) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [283, 285, 286] -StringLegalActions() = ["W3-up*", "W3-diag*", "W3-left"] +LegalActions() = [235, 237, 238] +StringLegalActions() = ["W6-up*", "W6-diag*", "W6-left"] -# Apply action "W3-left" -action: 286 +# Apply action "W6-up*" +action: 235 # State 10 -# Apply action "roll 4" -action: 3 +# Apply action "roll 6" +action: 5 # State 11 -# |__||__||b1||__||__| -# |b2||b5||__||__||__| -# |b3||__||__||__||w2| -# |__||__||w4||w1||w6| -# |__||__||w3||__||__| +# |b3||__||__||__||__| +# |b1||b2||b4||__||__| +# |b5||__||__||w3||w6| +# |__||__||w2||__||__| +# |__||__||__||w1||w4| IsTerminal() = False -History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3] -HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3" +History() = [2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5] +HistoryString() = "2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 0 -ObservationString(0) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||w3||__||__|\n" -ObservationString(1) = "|__||__||b1||__||__|\n|b2||b5||__||__||__|\n|b3||__||__||__||w2|\n|__||__||w4||w1||w6|\n|__||__||w3||__||__|\n" -ObservationTensor(0): binvec(300, 0x2000000010100000000000420000000010000000000008000200000000000000000000002) -ObservationTensor(1): binvec(300, 0x2000000010100000000000420000000010000000000008000200000000000000000000002) +ObservationString(0) = "|b3||__||__||__||__|\n|b1||b2||b4||__||__|\n|b5||__||__||w3||w6|\n|__||__||w2||__||__|\n|__||__||__||w1||w4|\n" +ObservationString(1) = "|b3||__||__||__||__|\n|b1||b2||b4||__||__|\n|b5||__||__||w3||w6|\n|__||__||w2||__||__|\n|__||__||__||w1||w4|\n" +ObservationTensor(0): binvec(300, 0x400000000008008000000080080000000002000040000000012000000000000000000000004) +ObservationTensor(1): binvec(300, 0x400000000008008000000080080000000002000040000000012000000000000000000000004) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [120, 122, 124, 72, 74, 76] -StringLegalActions() = ["B3-diag", "B3-down", "B3-right", "B5-diag", "B5-down", "B5-right"] +LegalActions() = [120, 122, 124] +StringLegalActions() = ["B5-diag", "B5-down", "B5-right"] # Apply action "B5-right" -action: 76 +action: 124 # State 12 -# Apply action "roll 2" -action: 1 +# Apply action "roll 6" +action: 5 # State 13 -# Apply action "W2-left" -action: 178 +# Apply action "W6-up" +action: 174 # State 14 -# Apply action "roll 3" -action: 2 +# Apply action "roll 5" +action: 4 # State 15 -# Apply action "B3-diag" -action: 120 +# Apply action "B5-right" +action: 136 # State 16 -# Apply action "roll 6" -action: 5 +# Apply action "roll 5" +action: 4 # State 17 -# Apply action "W6-diag*" -action: 237 +# Apply action "W4-left*" +action: 299 # State 18 -# Apply action "roll 2" -action: 1 +# Apply action "roll 5" +action: 4 # State 19 -# Apply action "B2-down" -action: 62 +# Apply action "B5-right*" +action: 149 # State 20 -# Apply action "roll 3" -action: 2 +# Apply action "roll 1" +action: 0 # State 21 -# Apply action "W3-left" -action: 274 +# Apply action "W2-diag" +action: 212 # State 22 # Apply action "roll 3" action: 2 # State 23 -# Apply action "B3-diag" -action: 192 +# Apply action "B3-right" +action: 4 # State 24 -# Apply action "roll 6" -action: 5 +# Apply action "roll 4" +action: 3 # State 25 -# Apply action "W6-diag*" -action: 165 +# Apply action "W4-left" +action: 286 # State 26 -# Apply action "roll 6" -action: 5 +# Apply action "roll 1" +action: 0 # State 27 -# Apply action "B3-right" -action: 268 +# Apply action "B1-down" +action: 62 # State 28 -# Apply action "roll 2" -action: 1 +# Apply action "roll 4" +action: 3 # State 29 -# Apply action "W1-diag" -action: 224 +# Apply action "W4-diag" +action: 272 # State 30 -# Apply action "roll 1" -action: 0 +# Apply action "roll 5" +action: 4 # State 31 -# Apply action "B1-diag" -action: 24 +# Apply action "B5-right" +action: 160 # State 32 -# Apply action "roll 5" -action: 4 +# Apply action "roll 1" +action: 0 # State 33 -# Apply action "W4-diag" -action: 212 +# Apply action "W2-left*" +action: 143 # State 34 # Apply action "roll 2" @@ -330,95 +330,119 @@ action: 1 # State 35 # Apply action "B2-down" -action: 122 +action: 74 # State 36 -# Apply action "roll 4" -action: 3 +# Apply action "roll 5" +action: 4 # State 37 -# Apply action "W4-left" -action: 142 +# Apply action "W6-up" +action: 114 # State 38 -# Apply action "roll 2" -action: 1 +# Apply action "roll 3" +action: 2 # State 39 -# Apply action "B2-right" -action: 184 +# Apply action "B3-right" +action: 16 # State 40 -# Apply action "roll 1" -action: 0 +# Apply action "roll 3" +action: 2 # State 41 +# |__||__||b3||__||w6| +# |__||__||b4||__||__| +# |w2||b2||__||__||b5| +# |__||w4||__||__||__| # |__||__||__||__||__| -# |__||__||w6||b1||__| -# |w4||__||w1||__||__| -# |__||b2||__||__||__| -# |__||w3||__||b3||__| IsTerminal() = False -History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0] -HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0" +History() = [2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5, 124, 5, 174, 4, 136, 4, 299, 4, 149, 0, 212, 2, 4, 3, 286, 0, 62, 3, 272, 4, 160, 0, 143, 1, 74, 4, 114, 2, 16, 2] +HistoryString() = "2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5, 124, 5, 174, 4, 136, 4, 299, 4, 149, 0, 212, 2, 4, 3, 286, 0, 62, 3, 272, 4, 160, 0, 143, 1, 74, 4, 114, 2, 16, 2" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 1 -ObservationString(0) = "|__||__||__||__||__|\n|__||__||w6||b1||__|\n|w4||__||w1||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" -ObservationString(1) = "|__||__||__||__||__|\n|__||__||w6||b1||__|\n|w4||__||w1||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" -ObservationTensor(0): binvec(300, 0x80000400002000000000000001000200000000004000000000000000000000000002000) -ObservationTensor(1): binvec(300, 0x80000400002000000000000001000200000000004000000000000000000000000002000) +ObservationString(0) = "|__||__||b3||__||w6|\n|__||__||b4||__||__|\n|w2||b2||__||__||b5|\n|__||w4||__||__||__|\n|__||__||__||__||__|\n" +ObservationString(1) = "|__||__||b3||__||w6|\n|__||__||b4||__||__|\n|w2||b2||__||__||b5|\n|__||w4||__||__||__|\n|__||__||__||__||__|\n" +ObservationTensor(0): binvec(300, 0x4000040000000200000000000040000100000000020000000000000000010) +ObservationTensor(1): binvec(300, 0x4000040000000200000000000040000100000000020000000000000000010) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [151, 152, 154] -StringLegalActions() = ["W1-up*", "W1-diag", "W1-left"] +LegalActions() = [126, 199, 201, 202] +StringLegalActions() = ["W2-up", "W4-up*", "W4-diag*", "W4-left"] -# Apply action "W1-up*" -action: 151 +# Apply action "W4-up*" +action: 199 # State 42 -# Apply action "roll 6" -action: 5 +# Apply action "roll 3" +action: 2 # State 43 +# |__||__||b3||__||w6| +# |__||__||b4||__||__| +# |w2||w4||__||__||b5| +# |__||__||__||__||__| # |__||__||__||__||__| -# |__||__||w1||b1||__| -# |w4||__||__||__||__| -# |__||b2||__||__||__| -# |__||w3||__||b3||__| IsTerminal() = False -History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5] -HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5" +History() = [2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5, 124, 5, 174, 4, 136, 4, 299, 4, 149, 0, 212, 2, 4, 3, 286, 0, 62, 3, 272, 4, 160, 0, 143, 1, 74, 4, 114, 2, 16, 2, 199, 2] +HistoryString() = "2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5, 124, 5, 174, 4, 136, 4, 299, 4, 149, 0, 212, 2, 4, 3, 286, 0, 62, 3, 272, 4, 160, 0, 143, 1, 74, 4, 114, 2, 16, 2, 199, 2" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = 0 -ObservationString(0) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" -ObservationString(1) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||b3||__|\n" -ObservationTensor(0): binvec(300, 0x80000800002000000000000001000200000000004000000000000000000000000000000) -ObservationTensor(1): binvec(300, 0x80000800002000000000000001000200000000004000000000000000000000000000000) +ObservationString(0) = "|__||__||b3||__||w6|\n|__||__||b4||__||__|\n|w2||w4||__||__||b5|\n|__||__||__||__||__|\n|__||__||__||__||__|\n" +ObservationString(1) = "|__||__||b3||__||w6|\n|__||__||b4||__||__|\n|w2||w4||__||__||b5|\n|__||__||__||__||__|\n|__||__||__||__||__|\n" +ObservationTensor(0): binvec(300, 0x40000000200000000000040000200000000020000000000000000010) +ObservationTensor(1): binvec(300, 0x40000000200000000000040000200000000020000000000000000010) Rewards() = [0, 0] Returns() = [0, 0] -LegalActions() = [280] -StringLegalActions() = ["B3-right"] +LegalActions() = [24, 27, 28] +StringLegalActions() = ["B3-diag", "B3-down*", "B3-right"] -# Apply action "B3-right" -action: 280 +# Apply action "B3-down*" +action: 27 # State 44 +# Apply action "roll 2" +action: 1 + +# State 45 +# Apply action "W2-up" +action: 126 + +# State 46 +# Apply action "roll 5" +action: 4 + +# State 47 +# Apply action "B5-down" +action: 170 + +# State 48 +# Apply action "roll 1" +action: 0 + +# State 49 +# Apply action "W2-up" +action: 66 + +# State 50 +# |w2||__||__||__||w6| +# |__||__||b3||__||__| +# |__||w4||__||__||__| +# |__||__||__||__||b5| # |__||__||__||__||__| -# |__||__||w1||b1||__| -# |w4||__||__||__||__| -# |__||b2||__||__||__| -# |__||w3||__||__||b3| IsTerminal() = True -History() = [2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5, 280] -HistoryString() = "2, 299, 1, 3, 4, 270, 0, 17, 2, 286, 3, 76, 1, 178, 2, 120, 5, 237, 1, 62, 2, 274, 2, 192, 5, 165, 5, 268, 1, 224, 0, 24, 4, 212, 1, 122, 3, 142, 1, 184, 0, 151, 5, 280" +History() = [2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5, 124, 5, 174, 4, 136, 4, 299, 4, 149, 0, 212, 2, 4, 3, 286, 0, 62, 3, 272, 4, 160, 0, 143, 1, 74, 4, 114, 2, 16, 2, 199, 2, 27, 1, 126, 4, 170, 0, 66] +HistoryString() = "2, 222, 5, 12, 1, 270, 3, 27, 5, 235, 5, 124, 5, 174, 4, 136, 4, 299, 4, 149, 0, 212, 2, 4, 3, 286, 0, 62, 3, 272, 4, 160, 0, 143, 1, 74, 4, 114, 2, 16, 2, 199, 2, 27, 1, 126, 4, 170, 0, 66" IsChanceNode() = False IsSimultaneousNode() = False CurrentPlayer() = -4 -ObservationString(0) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||__||b3|\n" -ObservationString(1) = "|__||__||__||__||__|\n|__||__||w1||b1||__|\n|w4||__||__||__||__|\n|__||b2||__||__||__|\n|__||w3||__||__||b3|\n" -ObservationTensor(0): binvec(300, 0x80000800002000000000000000080200000000004000000000000000000000000000000) -ObservationTensor(1): binvec(300, 0x80000800002000000000000000080200000000004000000000000000000000000000000) -Rewards() = [1, -1] -Returns() = [1, -1] +ObservationString(0) = "|w2||__||__||__||w6|\n|__||__||b3||__||__|\n|__||w4||__||__||__|\n|__||__||__||__||b5|\n|__||__||__||__||__|\n" +ObservationString(1) = "|w2||__||__||__||w6|\n|__||__||b3||__||__|\n|__||w4||__||__||__|\n|__||__||__||__||b5|\n|__||__||__||__||__|\n" +ObservationTensor(0): binvec(300, 0x100000000100000000000000000200000000010000000000000000010) +ObservationTensor(1): binvec(300, 0x100000000100000000000000000200000000010000000000000000010) +Rewards() = [-1, 1] +Returns() = [-1, 1] From de331875f1c314d19b95ac19bece0506b563e7e6 Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Mon, 18 Nov 2024 18:38:51 +0000 Subject: [PATCH 3/6] Modify description about default seed value. --- .../games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h index 6268566340..1689bc1b58 100644 --- a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h @@ -31,7 +31,7 @@ // https://en.wikipedia.org/wiki/EinStein_w%C3%BCrfelt_nicht! // // Parameters: -// "seed" int random seed for placement of cubes on the board [1] (default=-1) +// "seed" int random seed for placement of cubes on the board [1] (default=42) // // [1] When the seed is -1, the current time is used as the seed, so that the // assignment of cubes is random each time the game is played. From 7acd3954d085c2f46f7fc5496650180bff07a26a Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Sat, 26 Oct 2024 16:32:34 +0100 Subject: [PATCH 4/6] Remove random board setup --- docs/games.md | 1 + open_spiel/games/CMakeLists.txt | 6 + .../einstein_wurfelt_nicht.cc | 557 ++++++++++++++++++ .../einstein_wurfelt_nicht.h | 157 +++++ .../einstein_wurfelt_nicht_test.cc | 298 ++++++++++ .../playthroughs/einstein_wurfelt_nicht.txt | 376 ++++++++++++ open_spiel/python/tests/pyspiel_test.py | 1 + 7 files changed, 1396 insertions(+) create mode 100644 open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc create mode 100644 open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h create mode 100644 open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc create mode 100644 open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt diff --git a/docs/games.md b/docs/games.md index cb145568c3..14b49eb648 100644 --- a/docs/games.md +++ b/docs/games.md @@ -33,6 +33,7 @@ Status | Game 🟒 | [Dots and Boxes](https://en.wikipedia.org/wiki/Dots_and_boxes) | 2 | βœ… | βœ… | Players put lines between dots to form boxes to get points. πŸ”Ά | [Dou Dizhu](https://en.wikipedia.org/wiki/Dou_dizhu) | 3 | ❌ | ❌ | A three-player games where one player (dizhu) plays against a team of two (peasants). πŸ”Ά | [Euchre](https://en.wikipedia.org/wiki/Euchre) | 4 | ❌ | ❌ | Trick-taking card game where players compete in pairs. +πŸ”Ά | [EinStein wΓΌrfelt nicht!](https://en.wikipedia.org/wiki/EinStein_w%C3%BCrfelt_nicht!) | 2 | ❌ | βœ… | Players control 6 numbered cubes, selected randomly by the roll of a die. The player that gets on the opponent's board corner, or captures all the opponent's cubes wins. 🟒 | [First-price Sealed-Bid Auction](https://en.wikipedia.org/wiki/First-price_sealed-bid_auction) | 2-10 | ❌ | ❌ | Agents submit bids simultaneously; highest bid wins, and that's the price paid. 🟒 | [Gin Rummy](https://en.wikipedia.org/wiki/Gin_rummy) | 2 | ❌ | ❌ | Players score points by forming specific sets with the cards in their hands. 🟒 | [Go](https://en.wikipedia.org/wiki/Go_\(game\)) | 2 | βœ… | βœ… | Players place tokens on the board with the goal of encircling territory. diff --git a/open_spiel/games/CMakeLists.txt b/open_spiel/games/CMakeLists.txt index 3500805a66..c2419ae6d8 100644 --- a/open_spiel/games/CMakeLists.txt +++ b/open_spiel/games/CMakeLists.txt @@ -71,6 +71,8 @@ set(GAME_SOURCES efg_game/efg_game.h efg_game/efg_game_data.cc efg_game/efg_game_data.h + einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc + einstein_wurfelt_nicht/einstein_wurfelt_nicht.h euchre/euchre.cc euchre/euchre.h first_sealed_auction/first_sealed_auction.cc @@ -422,6 +424,10 @@ add_executable(efg_game_test efg_game/efg_game_test.cc ${OPEN_SPIEL_OBJECTS} $) add_test(efg_game_test efg_game_test) +add_executable(einstein_wurfelt_nicht_test einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc ${OPEN_SPIEL_OBJECTS} + $) +add_test(einstein_wurfelt_nicht_test einstein_wurfelt_nicht_test) + add_executable(euchre_test euchre/euchre_test.cc ${OPEN_SPIEL_OBJECTS} $) add_test(euchre_test euchre_test) diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc new file mode 100644 index 0000000000..98ab16e359 --- /dev/null +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc @@ -0,0 +1,557 @@ +// Copyright 2024 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h" + +#include +#include +#include +#include + +#include "open_spiel/game_parameters.h" +#include "open_spiel/utils/tensor_view.h" + +namespace open_spiel { +namespace einstein_wurfelt_nicht { +namespace { + +const std::vector> kChanceOutcomes = { + std::pair(0, 1.0 / 6), + std::pair(1, 1.0 / 6), + std::pair(2, 1.0 / 6), + std::pair(3, 1.0 / 6), + std::pair(4, 1.0 / 6), + std::pair(5, 1.0 / 6) +}; + +// Number of unique directions each cube can take. +constexpr int kNumDirections = 6; + +// Direction offsets for black, then white. +constexpr std::array kDirRowOffsets = { + {1, 1, 0, -1, -1, 0}}; + +constexpr std::array kDirColOffsets = { + {1, 0, 1, 0, -1, -1}}; + +// Facts about the game +const GameType kGameType{/*short_name=*/"einstein_wurfelt_nicht", + /*long_name=*/"einstein_wurfelt_nicht", + GameType::Dynamics::kSequential, + GameType::ChanceMode::kExplicitStochastic, + GameType::Information::kPerfectInformation, + GameType::Utility::kZeroSum, + GameType::RewardModel::kTerminal, + /*max_num_players=*/2, + /*min_num_players=*/2, + /*provides_information_state_string=*/false, + /*provides_information_state_tensor=*/false, + /*provides_observation_string=*/true, + /*provides_observation_tensor=*/true, + /*parameter_specification=*/{} // no parameters + }; + +std::shared_ptr Factory(const GameParameters& params) { + return std::shared_ptr(new EinsteinWurfeltNichtGame(params)); +} + +REGISTER_SPIEL_GAME(kGameType, Factory); + +RegisterSingleTensorObserver single_tensor(kGameType.short_name); + +Color PlayerToColor(Player player) { + SPIEL_CHECK_NE(player, kInvalidPlayer); + return static_cast(player); +} + +Player ColorToPlayer(Color color) { + switch (color) { + case Color::kBlack: + return kBlackPlayerId; + case Color::kWhite: + return kWhitePlayerId; + default: + SpielFatalError("No player for this color"); + } +} + +Color OpponentColor(Player player) { + Color player_color = PlayerToColor(player); + if (player_color == Color::kBlack) { + return Color::kWhite; + } else if (player_color == Color::kWhite) { + return Color::kBlack; + } else { + SpielFatalError("Player should be either black or white"); + } +} + +std::vector> GetAllPermutations() { + std::vector> all_permutations; + std::vector nums = {1, 2, 3, 4, 5, 6}; + + do { + all_permutations.push_back(nums); + } while (std::next_permutation(nums.begin(), nums.end())); + + return all_permutations; +} + +std::string CoordinatesToDirection(int row, int col) { + std::string direction; + if (row == col) { + direction = "diag"; + } else if (row == -1) { + direction = "up"; + } else if (row == 1) { + direction = "down"; + } else if (col == 1) { + direction = "right"; + } else if (col == -1) { + direction = "left"; + } else { + std::cout << "r2: " << row << "c2: " << col << std::endl; + SpielFatalError("Unrecognized cube's movement"); + } + return direction; +} + +} // namespace + +EinsteinWurfeltNichtState::EinsteinWurfeltNichtState( + std::shared_ptr game, int rows, int cols) + : State(game), + rows_(rows), + cols_(cols), + turns_(-1), + cur_player_(kChancePlayerId), + prev_player_(kBlackPlayerId) { + SPIEL_CHECK_GT(rows_, 1); + SPIEL_CHECK_GT(cols_, 1); + board_.fill(Cube{Color::kEmpty, -1}); + + winner_ = kInvalidPlayer; + cubes_[0] = cubes_[1] = kNumPlayerCubes; +} + +void EinsteinWurfeltNichtState::SetupInitialBoard( + Player player, Action action) { + auto perms = GetAllPermutations(); + int perm_idx = 0; + + // Values in the upper-left corner (black cubes) have a postion identified + // as rows+cols <= 2. Values in the lower-right corner (white cubes) have a + // position identified as rows+cols >= 6. The rest of the board is empty. + for (int r = 0; r < kDefaultRows; r++) { + for (int c = 0; c < kDefaultColumns; c++) { + if (r+c <= 2 && player == kBlackPlayerId) { + board_[r*kDefaultColumns+c] = + Cube{Color::kBlack, perms[action][perm_idx]}; + perm_idx++; + } else if (r+c >= 6 && player == kWhitePlayerId) { + board_[r*kDefaultColumns+c] = + Cube{Color::kWhite, perms[action][perm_idx]}; + perm_idx++; + } + } + } +} + +int EinsteinWurfeltNichtState::CurrentPlayer() const { + if (IsTerminal()) { + return kTerminalPlayerId; + } else { + return cur_player_; + } +} + +int EinsteinWurfeltNichtState::Opponent(int player) const { return 1 - player; } + +std::vector> +EinsteinWurfeltNichtState::AvailableCubesPosition(Color player_color) const { + std::vector> player_cubes; + for (int r = 0; r < rows_; r++) { + for (int c = 0; c < cols_; c++) { + if (board(r, c).color == player_color) { + if (board(r, c).value == die_roll_) { + // If there is a cube with the same value as the die, + // return only this one + std::vector> player_cube; + player_cube.push_back({board(r, c).value, r, c}); + return player_cube; + } else { + player_cubes.push_back({r, c}); + } + } + } + } + + // Initialise lowest/highest cube values to out-of-bound cube's values + std::vector lowest_cube = {0, 0, 0}; // cube value, r, c + std::vector highest_cube = {7, 0, 0}; // cube value, r, c + for (int i = 0; i < player_cubes.size(); ++i) { + int r = player_cubes[i].first; + int c = player_cubes[i].second; + if (board(r, c).value > lowest_cube[0] && board(r, c).value < die_roll_) { + lowest_cube[0] = board(r, c).value; + lowest_cube[1] = r; + lowest_cube[2] = c; + } else if (board(r, c).value < highest_cube[0] && + board(r, c).value > die_roll_) { + highest_cube[0] = board(r, c).value; + highest_cube[1] = r; + highest_cube[2] = c; + } + } + + std::vector> selected_cubes; + if (lowest_cube[0] > 0) { + selected_cubes.push_back(lowest_cube); + } + if (highest_cube[0] < 7) { + selected_cubes.push_back(highest_cube); + } + + // Legal actions have to be sorted. Sort by row first, then by column + std::sort(selected_cubes.begin(), selected_cubes.end(), + [](const std::vector& a, const std::vector& b) { + if (a[1] != b[1]) return a[1] < b[1]; + return a[2] < b[2]; + }); + + return selected_cubes; +} + +void EinsteinWurfeltNichtState::DoApplyAction(Action action) { + if (IsChanceNode()) { + SPIEL_CHECK_GE(action, 0); + SPIEL_CHECK_LE(action, kNumCubesPermutations -1); + turn_history_info_.push_back(TurnHistoryInfo(kChancePlayerId, + prev_player_, + die_roll_, + action, + Cube{Color::kEmpty, -1})); + if (turns_ == -1) { + SetupInitialBoard(kBlackPlayerId, action); + turns_ = 0; + return; + } else if (turns_ == 0) { + SetupInitialBoard(kWhitePlayerId, action); + turns_++; + return; + } else { + cur_player_ = Opponent(prev_player_); + prev_player_ = cur_player_; + die_roll_ = action + 1; + turns_++; + return; + } + } + + // The die should have been rolled at least once at this point + SPIEL_CHECK_GE(die_roll_, 1); + SPIEL_CHECK_LE(die_roll_, 6); + + std::vector values = + UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); + int r1 = values[0]; + int c1 = values[1]; + int dir = values[2]; + bool capture = values[3] == 1; + int r2 = r1 + kDirRowOffsets[dir]; + int c2 = c1 + kDirColOffsets[dir]; + + SPIEL_CHECK_TRUE(InBounds(r1, c1)); + SPIEL_CHECK_TRUE(InBounds(r2, c2)); + + // Remove cubes if captured. + if (board(r2, c2).color == Color::kBlack) { + cubes_[ColorToPlayer(Color::kBlack)]--; + } else if (board(r2, c2).color == Color::kWhite) { + cubes_[ColorToPlayer(Color::kWhite)]--; + } + + Cube captured_cube = (capture) ? board(r2, c2) : Cube{Color::kEmpty, -1}; + turn_history_info_.push_back( + TurnHistoryInfo(cur_player_, + prev_player_, + die_roll_, + action, + captured_cube)); + + SetBoard(r2, c2, board(r1, c1)); + SetBoard(r1, c1, Cube{Color::kEmpty, -1}); + + // Check for winner. + if ((cur_player_ == 0 && r2 == (rows_ - 1) && c2 == (cols_ - 1)) || + (cubes_[ColorToPlayer(Color::kWhite)] == 0)) { + winner_ = 0; + } else if ((cur_player_ == 1 && r2 == 0 && c2 == 0) || + (cubes_[ColorToPlayer(Color::kBlack)] == 0)) { + winner_ = 1; + } + + cur_player_ = NextPlayerRoundRobin(cur_player_, kNumPlayers); + cur_player_ = kChancePlayerId; + turns_++; +} + +std::string EinsteinWurfeltNichtState::ActionToString(Player player, + Action action) const { + std::string action_string = ""; + + if (IsChanceNode()) { + if (turns_ == -1) { + absl::StrAppend(&action_string, + "Placing black cubes on the board - action ", action); + return action_string; + } else if (turns_ == 0) { + absl::StrAppend(&action_string, + "Placing white cubes on the board - action ", action); + return action_string; + } else if (turns_ >= 0) { + absl::StrAppend(&action_string, "roll ", action+1); + return action_string; + } + } + + std::vector values = + UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); + int r1 = values[0]; + int c1 = values[1]; + int dir = values[2]; + bool capture = values[3] == 1; + int r2 = kDirRowOffsets[dir]; + int c2 = kDirColOffsets[dir]; + + Cube cube = board(r1, c1); + std::string color = (cube.color == Color::kBlack) ? "B" : "W"; + + std::string direction = CoordinatesToDirection(r2, c2); + absl::StrAppend(&action_string, color); + absl::StrAppend(&action_string, cube.value); + absl::StrAppend(&action_string, "-"); + absl::StrAppend(&action_string, direction); + if (capture) { + absl::StrAppend(&action_string, "*"); + } + return action_string; +} + +std::vector EinsteinWurfeltNichtState::LegalActions() const { + if (IsChanceNode()) return LegalChanceOutcomes(); + if (IsTerminal()) return {}; + + std::vector movelist; + if (IsTerminal()) return movelist; + const Player player = CurrentPlayer(); + Color player_color = PlayerToColor(player); + std::vector action_bases = {rows_, cols_, kNumDirections, 2}; + std::vector action_values = {0, 0, 0, 0}; + + std::vector> available_cubes; + available_cubes = AvailableCubesPosition(player_color); + + for (int i = 0; i < available_cubes.size(); ++i) { + int r = available_cubes[i][1]; + int c = available_cubes[i][2]; + for (int o = 0; o < kNumDirections / 2; o++) { + int dir = player * kNumDirections / 2 + o; + int rp = r + kDirRowOffsets[dir]; + int cp = c + kDirColOffsets[dir]; + if (InBounds(rp, cp)) { + action_values[0] = r; + action_values[1] = c; + action_values[2] = dir; + if (board(rp, cp).color == Color::kEmpty) { + action_values[3] = 0; // no capture + movelist.push_back( + RankActionMixedBase(action_bases, action_values)); + } else { + action_values[3] = 1; // capture + movelist.push_back( + RankActionMixedBase(action_bases, action_values)); + } + } + } + } + return movelist; +} + +std::vector> +EinsteinWurfeltNichtState::ChanceOutcomes() const { + SPIEL_CHECK_TRUE(IsChanceNode()); + if (turns_ <= 0) { + // First 2 moves corresponds to the initial board setup. + // There are 6! = 720 possible permutations of the cubes. + std::vector> chance_outcomes; + double action_prob = 1.0 / kNumCubesPermutations; + chance_outcomes.reserve(kNumCubesPermutations); + + for (Action i = 0; i < kNumCubesPermutations; ++i) { + chance_outcomes.emplace_back(i, action_prob); + } + return chance_outcomes; + } else { + return kChanceOutcomes; + } +} + +bool EinsteinWurfeltNichtState::InBounds(int r, int c) const { + return (r >= 0 && r < rows_ && c >= 0 && c < cols_); +} + +std::string EinsteinWurfeltNichtState::ToString() const { + std::string W_result = ""; + + for (int r = 0; r < kDefaultRows; r++) { + for (int c = 0; c < kDefaultColumns; c++) { + if (board_[r*kDefaultColumns+c].color == Color::kBlack) { + absl::StrAppend(&W_result, "|b"); + absl::StrAppend(&W_result, board_[r*kDefaultColumns+c].value); + absl::StrAppend(&W_result, "|"); + } else if (board_[r*kDefaultColumns+c].color == Color::kWhite) { + absl::StrAppend(&W_result, "|w"); + absl::StrAppend(&W_result, board_[r*kDefaultColumns+c].value); + absl::StrAppend(&W_result, "|"); + } else { + absl::StrAppend(&W_result, "|__|"); + } + } + W_result.append("\n"); + } + return W_result; +} + +bool EinsteinWurfeltNichtState::IsTerminal() const { + return (winner_ >= 0 || (cubes_[0] == 0 || cubes_[1] == 0)); +} + +std::vector EinsteinWurfeltNichtState::Returns() const { + if (winner_ == 0 || cubes_[1] == 0) { + return {1.0, -1.0}; + } else if (winner_ == 1 || cubes_[0] == 0) { + return {-1.0, 1.0}; + } else { + return {0.0, 0.0}; + } +} + +std::string EinsteinWurfeltNichtState::ObservationString(Player player) const { + SPIEL_CHECK_GE(player, 0); + SPIEL_CHECK_LT(player, num_players_); + return ToString(); +} + +void EinsteinWurfeltNichtState::ObservationTensor(Player player, + absl::Span values) const { + SPIEL_CHECK_GE(player, 0); + SPIEL_CHECK_LT(player, num_players_); + + auto value_it = values.begin(); + + for (int cube_num = 1; cube_num < kNumPlayerCubes+1; ++cube_num) { + for (int player_idx = 0; player_idx < kNumPlayers; ++player_idx) { + for (int8_t y = 0; y < kDefaultRows; ++y) { + for (int8_t x = 0; x < kDefaultColumns; ++x) { + *value_it++ = + (board(x, y).value == cube_num && + board(x, y).color == PlayerToColor(player_idx) + ? 1.0 + : 0.0); + } + } + } + } +} + +void EinsteinWurfeltNichtState::UndoAction(Player player, Action action) { + const TurnHistoryInfo& thi = turn_history_info_.back(); + SPIEL_CHECK_EQ(thi.player, player); + SPIEL_CHECK_EQ(action, thi.action); + + if (player != kChancePlayerId) { + std::vector values = + UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); + int r1 = values[0]; + int c1 = values[1]; + int dir = values[2]; + bool capture = values[3] == 1; + int r2 = r1 + kDirRowOffsets[dir]; + int c2 = c1 + kDirColOffsets[dir]; + Cube captured_cube = thi.captured_cube; + + SetBoard(r1, c1, board(r2, c2)); + if (captured_cube.value != -1) { + SetBoard(r2, c2, captured_cube); + if (captured_cube.color == Color::kBlack) { + cubes_[ColorToPlayer(Color::kBlack)]++; + } else if (captured_cube.color == Color::kWhite) { + cubes_[ColorToPlayer(Color::kWhite)]++; + } + } else { + SetBoard(r2, c2, Cube{Color::kEmpty, -1}); + } + } else { + for (int r = 0; r < kDefaultRows; r++) { + for (int c = 0; c < kDefaultColumns; c++) { + if (turns_ == 1 && board(r, c).color == Color::kWhite) { + board_[r*kDefaultColumns+c] = Cube{Color::kEmpty, -1}; + } else if (turns_ == 0 && board(r, c).color == Color::kBlack) { + board_[r*kDefaultColumns+c] = Cube{Color::kEmpty, -1}; + } + } + } + } + + // Undo win status. + winner_ = kInvalidPlayer; + + turn_history_info_.pop_back(); + history_.pop_back(); + --turns_; + --move_number_; +} + +std::unique_ptr EinsteinWurfeltNichtState::Clone() const { + return std::unique_ptr(new EinsteinWurfeltNichtState(*this)); +} + +// Setter function used for debugging and tests. Note: this does not set the +// historical information properly, so Undo likely will not work on states +// set this way! +void EinsteinWurfeltNichtState::SetState(int cur_player, + int die_roll, + const std::array board, + int cubes_black, + int cubes_white) { + cur_player_ = cur_player; + die_roll_ = die_roll; + board_ = board; + cubes_[ColorToPlayer(Color::kBlack)] = cubes_black; + cubes_[ColorToPlayer(Color::kWhite)] = cubes_white; +} + +EinsteinWurfeltNichtGame::EinsteinWurfeltNichtGame(const GameParameters& params) + : Game(kGameType, params), + rows_(kDefaultRows), + cols_(kDefaultColumns) {} + +int EinsteinWurfeltNichtGame::NumDistinctActions() const { + return rows_ * cols_ * kNumDirections * 2; +} + +} // namespace einstein_wurfelt_nicht +} // namespace open_spiel diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h new file mode 100644 index 0000000000..ead2daf9f7 --- /dev/null +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h @@ -0,0 +1,157 @@ +// Copyright 2024 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPEN_SPIEL_GAMES_EINSTEIN_WURFELT_NICHT_H_ +#define OPEN_SPIEL_GAMES_EINSTEIN_WURFELT_NICHT_H_ + +#include +#include +#include +#include +#include +#include + +#include "open_spiel/spiel.h" +#include "open_spiel/spiel_utils.h" + +// An implementation of the game EinStein wΓΌrfelt nicht! +// This is the implementation of the basic game with a 5x5 board and 6 cubes +// per player. +// https://en.wikipedia.org/wiki/EinStein_w%C3%BCrfelt_nicht! + +namespace open_spiel { +namespace einstein_wurfelt_nicht { + +enum class Color : int8_t { kBlack = 0, kWhite = 1, kEmpty = 2 }; + +struct Cube { + Color color; + int value; // player's die value +}; + +inline constexpr int kNumPlayers = 2; +inline constexpr int kBlackPlayerId = 0; +inline constexpr int kWhitePlayerId = 1; +inline constexpr int kNumPlayerCubes = 6; +// 720 possible permutations of 6 cubes on the board +inline constexpr int kNumCubesPermutations = 720; +inline constexpr int kDefaultRows = 5; +inline constexpr int kDefaultColumns = 5; +inline constexpr int k2dMaxBoardSize = kDefaultRows * kDefaultColumns; +inline constexpr const int kStateEncodingSize = kNumPlayers * kNumPlayerCubes * + kDefaultRows * kDefaultColumns; + +// This is a small helper to track historical turn info not stored in the moves. +// It is only needed for proper implementation of Undo. +struct TurnHistoryInfo { + int player; + int prev_player; + int die_roll_; + Action action; + Cube captured_cube; + TurnHistoryInfo(int _player, int _prev_player, int _die_roll, + int _action, Cube _captured_cube) + : player(_player), + prev_player(_prev_player), + die_roll_(_die_roll), + action(_action), + captured_cube(_captured_cube) {} +}; + +class EinsteinWurfeltNichtState : public State { + public: + explicit EinsteinWurfeltNichtState(std::shared_ptr game, int rows, + int cols); + Player CurrentPlayer() const override; + // Returns the opponent of the specified player. + int Opponent(int player) const; + std::vector> AvailableCubesPosition(Color color) const; + std::string ActionToString(Player player, Action action) const override; + std::string ToString() const override; + bool IsTerminal() const override; + std::vector Returns() const override; + std::string ObservationString(Player player) const override; + void ObservationTensor(Player player, + absl::Span values) const override; + std::unique_ptr Clone() const override; + void UndoAction(Player player, Action action) override; + + bool InBounds(int r, int c) const; + void SetBoard(int r, int c, Cube cube) { board_[r * cols_ + c] = cube; } + Cube board(int row, int col) const { return board_[row * cols_ + col]; } + std::vector LegalActions() const override; + std::vector> ChanceOutcomes() const override; + void SetState(int cur_player, int die_roll, + const std::array board, + int cubes_black, int cubes_white); + + protected: + void DoApplyAction(Action action) override; + + private: + void SetupInitialBoard(Player player, Action action); + + Player cur_player_ = kInvalidPlayer; + Player prev_player_ = kInvalidPlayer; + int winner_ = kInvalidPlayer; + int total_moves_ = -1; + int turns_ = -1; + std::array cubes_; + int rows_ = -1; + int cols_ = -1; + int die_roll_ = 0; + std::array board_; // for (row,col) we use row*cols_+col + std::vector turn_history_info_; +}; + +class EinsteinWurfeltNichtGame : public Game { + public: + explicit EinsteinWurfeltNichtGame(const GameParameters& params); + int NumDistinctActions() const override; + std::unique_ptr NewInitialState() const override { + return std::unique_ptr( + new EinsteinWurfeltNichtState(shared_from_this(), rows_, cols_)); + } + + int MaxChanceOutcomes() const override { return kNumCubesPermutations; } + + int NumPlayers() const override { return kNumPlayers; } + double MinUtility() const override { return -1; } + absl::optional UtilitySum() const override { return 0; } + double MaxUtility() const override { return 1; } + std::vector ObservationTensorShape() const override { + return {kStateEncodingSize}; + } + + // Assuming that each cube is moved first along the horizontal axis and then + // along the vertical axis, which is the maximum number of moves for a cube + // (only the cubes in the corners). This accounts for (row-1) * (cols-1) + // moves. If we assume that each player makes all these moves we get + // (row-1) * (cols-1) * num_players. If we consider the chance player as + // the third player which makes the same number of moves, the upper bound + // for the number of moves is (row-1) * (cols-1) * (num_players + 1). + int MaxGameLength() const override { + return (kDefaultRows - 1) * (kDefaultColumns - 1) * (kNumPlayerCubes + 1); + } + + private: + int rows_ = -1; + int cols_ = -1; +}; + +} // namespace einstein_wurfelt_nicht +} // namespace open_spiel + +#endif // OPEN_SPIEL_GAMES_EINSTEIN_WURFELT_NICHT_H_ diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc new file mode 100644 index 0000000000..1cfa6e63e0 --- /dev/null +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht_test.cc @@ -0,0 +1,298 @@ +// Copyright 2024 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h" + +#include "open_spiel/spiel.h" +#include "open_spiel/tests/basic_tests.h" + +namespace open_spiel { +namespace einstein_wurfelt_nicht { +namespace { + +namespace testing = open_spiel::testing; + +void BasicEinsteinWurfeltNitchTests() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + testing::RandomSimTest(*game, 100, true, true); + testing::RandomSimTestWithUndo(*game, 1); +} + +void BlackPlayerSimpleWinTest() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + EinsteinWurfeltNichtState* bstate = + static_cast(state.get()); + + int values[] = {-1, 2, -1, -1, -1, -1, -1, -1, 5, -1, 6, -1, -1, -1, -1, -1, + 3, -1, -1, 3, -1, -1, -1, -1, -1}; + Color colors[] = {Color::kEmpty, Color::kWhite, Color::kEmpty, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kBlack, Color::kEmpty, Color::kBlack, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kWhite, Color::kEmpty, Color::kEmpty, Color::kBlack, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty}; + std::array board; + for (int i = 0; i < k2dMaxBoardSize; i++) { + board[i] = {colors[i], values[i]}; + } + + bstate->SetState(kBlackPlayerId, 2, board, 3, 2); + + std::string expected_state = + "|__||w2||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state); + SPIEL_CHECK_EQ(bstate->CurrentPlayer(), kBlackPlayerId); + SPIEL_CHECK_FALSE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(bstate->LegalActions().size(), 1); + Action action = 230; // Move B3 down + SPIEL_CHECK_EQ(bstate->LegalActions()[0], 230); + SPIEL_CHECK_EQ(bstate->ActionToString(kBlackPlayerId, 230), "B3-down"); + + bstate->ApplyAction(230); + std::string expected_state_final = + "|__||w2||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||__|\n" + "|__||__||__||__||b3|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state_final); + std::vector returns = bstate->Returns(); + SPIEL_CHECK_TRUE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_EQ(returns[0], 1); + SPIEL_CHECK_EQ(returns[1], -1); +} + +void WhitePlayerSimpleWinTest() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + EinsteinWurfeltNichtState* bstate = + static_cast(state.get()); + + int values[] = {-1, 2, -1, -1, -1, -1, -1, -1, 5, -1, 6, -1, -1, -1, -1, -1, + 3, -1, -1, 3, -1, -1, -1, -1, -1}; + Color colors[] = {Color::kEmpty, Color::kWhite, Color::kEmpty, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kBlack, Color::kEmpty, Color::kBlack, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kWhite, Color::kEmpty, Color::kEmpty, Color::kBlack, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty}; + std::array board; + for (int i = 0; i < k2dMaxBoardSize; i++) { + board[i] = {colors[i], values[i]}; + } + bstate->SetState(kWhitePlayerId, 2, board, 3, 2); + + std::string expected_state = + "|__||w2||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state); + SPIEL_CHECK_EQ(bstate->CurrentPlayer(), kWhitePlayerId); + SPIEL_CHECK_FALSE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(bstate->LegalActions().size(), 1); + Action action = 22; // Move W2 to the left + SPIEL_CHECK_EQ(bstate->LegalActions()[0], action); + SPIEL_CHECK_EQ(bstate->ActionToString(kWhitePlayerId, action), "W2-left"); + + bstate->ApplyAction(action); + std::string expected_state_final = + "|w2||__||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state_final); + std::vector returns = bstate->Returns(); + SPIEL_CHECK_TRUE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_EQ(returns[0], -1); + SPIEL_CHECK_EQ(returns[1], 1); +} + +void WinByCapturingAllOpponentCubesTest() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + EinsteinWurfeltNichtState* bstate = + static_cast(state.get()); + + int values[] = {-1, -1, -1, -1, -1, -1, -1, -1, 5, -1, 6, -1, -1, -1, -1, -1, + 3, -1, -1, 3, -1, -1, -1, -1, -1}; + Color colors[] = {Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kBlack, Color::kEmpty, Color::kBlack, Color::kEmpty, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kWhite, Color::kEmpty, Color::kEmpty, Color::kBlack, + Color::kEmpty, Color::kEmpty, Color::kEmpty, Color::kEmpty, + Color::kEmpty}; + std::array board; + for (int i = 0; i < k2dMaxBoardSize; i++) { + board[i] = {colors[i], values[i]}; + } + bstate->SetState(kBlackPlayerId, 6, board, 3, 1); + + std::string expected_state = + "|__||__||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|b6||__||__||__||__|\n" + "|__||w3||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state); + SPIEL_CHECK_EQ(bstate->CurrentPlayer(), kBlackPlayerId); + SPIEL_CHECK_FALSE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(bstate->LegalActions().size(), 3); + Action action = 121; // Move B6 diagonally down-right + SPIEL_CHECK_EQ(bstate->LegalActions()[0], action); + SPIEL_CHECK_EQ(bstate->ActionToString(kBlackPlayerId, action), "B6-diag*"); + + bstate->ApplyAction(action); + std::string expected_state_final = + "|__||__||__||__||__|\n" + "|__||__||__||b5||__|\n" + "|__||__||__||__||__|\n" + "|__||b6||__||__||b3|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(bstate->ToString(), expected_state_final); + std::vector returns = bstate->Returns(); + SPIEL_CHECK_TRUE(bstate->IsTerminal()); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_EQ(returns[0], 1); + SPIEL_CHECK_EQ(returns[1], -1); +} + +void CheckAlternateChancePlayerAndNormalPlayerTest() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + + int previous_player = state->CurrentPlayer(); + + while (!state->IsTerminal()) { + if (state->CurrentPlayer() == open_spiel::kChancePlayerId) { + state->ApplyAction(state->LegalActions()[0]); + } else { + std::vector legal_actions = state->LegalActions(); + state->ApplyAction(legal_actions[0]); + } + int current_player = state->CurrentPlayer(); + if (current_player != open_spiel::kChancePlayerId) { + SPIEL_CHECK_NE(current_player, previous_player); + } + previous_player = current_player; + } +} + +void InitialStateTest() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + SPIEL_CHECK_EQ(state->CurrentPlayer(), open_spiel::kChancePlayerId); + SPIEL_CHECK_FALSE(state->IsTerminal()); +} + +void LegalActionsTest() { + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + + while (!state->IsTerminal()) { + std::vector legal_actions = state->LegalActions(); + SPIEL_CHECK_FALSE(legal_actions.empty()); + state->ApplyAction(legal_actions[0]); + } + + std::vector returns = state->Returns(); + SPIEL_CHECK_EQ(returns.size(), 2); + SPIEL_CHECK_TRUE(returns[0] == 1.0 || returns[1] == 1.0); +} + +void InitialBoardSetupTest() { + // Test the initial setup with empty board + std::string empty_board_state = + "|__||__||__||__||__|\n" + "|__||__||__||__||__|\n" + "|__||__||__||__||__|\n" + "|__||__||__||__||__|\n" + "|__||__||__||__||__|\n"; + std::shared_ptr game = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state = game->NewInitialState(); + SPIEL_CHECK_EQ(state->ToString(), empty_board_state); + SPIEL_CHECK_EQ(state->CurrentPlayer(), kChancePlayerId); + SPIEL_CHECK_EQ(state->ChanceOutcomes().size(), kNumCubesPermutations); + + // Test allocation of black cubes on the board + state->ApplyAction(0); + std::string black_board_state = + "|b1||b2||b3||__||__|\n" + "|b4||b5||__||__||__|\n" + "|b6||__||__||__||__|\n" + "|__||__||__||__||__|\n" + "|__||__||__||__||__|\n"; + SPIEL_CHECK_EQ(state->ToString(), black_board_state); + SPIEL_CHECK_EQ(state->CurrentPlayer(), kChancePlayerId); + SPIEL_CHECK_EQ(state->ChanceOutcomes().size(), kNumCubesPermutations); + + // Allocation of cubes on the board changes if a different action is applied + std::shared_ptr game2 = + open_spiel::LoadGame("einstein_wurfelt_nicht"); + std::unique_ptr state2 = game->NewInitialState(); + SPIEL_CHECK_EQ(state2->ToString(), empty_board_state); + state2->ApplyAction(1); + SPIEL_CHECK_NE(state2->ToString(), empty_board_state); + SPIEL_CHECK_NE(state->ToString(), state2->ToString()); + + // Test allocation of white cubes on the board + state->ApplyAction(0); + std::string white_board_state = + "|b1||b2||b3||__||__|\n" + "|b4||b5||__||__||__|\n" + "|b6||__||__||__||w1|\n" + "|__||__||__||w2||w3|\n" + "|__||__||w4||w5||w6|\n"; + SPIEL_CHECK_EQ(state->ToString(), white_board_state); + SPIEL_CHECK_EQ(state->CurrentPlayer(), kChancePlayerId); + SPIEL_CHECK_EQ(state->ChanceOutcomes().size(), kNumPlayerCubes); +} + +} // namespace +} // namespace einstein_wurfelt_nicht +} // namespace open_spiel + +int main(int argc, char** argv) { + open_spiel::testing::LoadGameTest("einstein_wurfelt_nicht"); + open_spiel::einstein_wurfelt_nicht::BasicEinsteinWurfeltNitchTests(); + open_spiel::einstein_wurfelt_nicht::WinByCapturingAllOpponentCubesTest(); + open_spiel::einstein_wurfelt_nicht:: + CheckAlternateChancePlayerAndNormalPlayerTest(); + open_spiel::einstein_wurfelt_nicht::InitialStateTest(); + open_spiel::einstein_wurfelt_nicht::LegalActionsTest(); + open_spiel::einstein_wurfelt_nicht::BlackPlayerSimpleWinTest(); + open_spiel::einstein_wurfelt_nicht::WhitePlayerSimpleWinTest(); + open_spiel::einstein_wurfelt_nicht::WinByCapturingAllOpponentCubesTest(); + open_spiel::einstein_wurfelt_nicht::InitialBoardSetupTest(); +} diff --git a/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt b/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt new file mode 100644 index 0000000000..b417120ea1 --- /dev/null +++ b/open_spiel/integration_tests/playthroughs/einstein_wurfelt_nicht.txt @@ -0,0 +1,376 @@ +game: einstein_wurfelt_nicht + +GameType.chance_mode = ChanceMode.EXPLICIT_STOCHASTIC +GameType.dynamics = Dynamics.SEQUENTIAL +GameType.information = Information.PERFECT_INFORMATION +GameType.long_name = "einstein_wurfelt_nicht" +GameType.max_num_players = 2 +GameType.min_num_players = 2 +GameType.parameter_specification = [] +GameType.provides_information_state_string = False +GameType.provides_information_state_tensor = False +GameType.provides_observation_string = True +GameType.provides_observation_tensor = True +GameType.provides_factored_observation_string = False +GameType.reward_model = RewardModel.TERMINAL +GameType.short_name = "einstein_wurfelt_nicht" +GameType.utility = Utility.ZERO_SUM + +NumDistinctActions() = 300 +PolicyTensorShape() = [300] +MaxChanceOutcomes() = 720 +GetParameters() = {} +NumPlayers() = 2 +MinUtility() = -1.0 +MaxUtility() = 1.0 +UtilitySum() = 0.0 +ObservationTensorShape() = [300] +ObservationTensorLayout() = TensorLayout.CHW +ObservationTensorSize() = 300 +MaxGameLength() = 112 +ToString() = "einstein_wurfelt_nicht()" + +# State 0 +# |__||__||__||__||__| +# |__||__||__||__||__| +# |__||__||__||__||__| +# |__||__||__||__||__| +# |__||__||__||__||__| +IsTerminal() = False +History() = [] +HistoryString() = "" +IsChanceNode() = True +IsSimultaneousNode() = False +CurrentPlayer() = -1 +ObservationString(0) = "|__||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n" +ObservationString(1) = "|__||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n" +ObservationTensor(0): zeros(300) +ObservationTensor(1): zeros(300) +ChanceOutcomes() = [(0,0.00138889), (1,0.00138889), (2,0.00138889), (3,0.00138889), (4,0.00138889), (5,0.00138889), (6,0.00138889), (7,0.00138889), (8,0.00138889), (9,0.00138889), (10,0.00138889), (11,0.00138889), (12,0.00138889), (13,0.00138889), (14,0.00138889), (15,0.00138889), (16,0.00138889), (17,0.00138889), (18,0.00138889), (19,0.00138889), (20,0.00138889), (21,0.00138889), (22,0.00138889), (23,0.00138889), (24,0.00138889), (25,0.00138889), (26,0.00138889), (27,0.00138889), (28,0.00138889), (29,0.00138889), (30,0.00138889), (31,0.00138889), (32,0.00138889), (33,0.00138889), (34,0.00138889), (35,0.00138889), (36,0.00138889), (37,0.00138889), (38,0.00138889), (39,0.00138889), (40,0.00138889), (41,0.00138889), (42,0.00138889), (43,0.00138889), (44,0.00138889), (45,0.00138889), (46,0.00138889), (47,0.00138889), (48,0.00138889), (49,0.00138889), (50,0.00138889), (51,0.00138889), (52,0.00138889), (53,0.00138889), (54,0.00138889), (55,0.00138889), (56,0.00138889), (57,0.00138889), (58,0.00138889), (59,0.00138889), (60,0.00138889), (61,0.00138889), (62,0.00138889), (63,0.00138889), (64,0.00138889), (65,0.00138889), (66,0.00138889), (67,0.00138889), (68,0.00138889), (69,0.00138889), (70,0.00138889), (71,0.00138889), (72,0.00138889), (73,0.00138889), (74,0.00138889), (75,0.00138889), (76,0.00138889), (77,0.00138889), (78,0.00138889), (79,0.00138889), (80,0.00138889), (81,0.00138889), (82,0.00138889), (83,0.00138889), (84,0.00138889), (85,0.00138889), (86,0.00138889), (87,0.00138889), (88,0.00138889), (89,0.00138889), (90,0.00138889), (91,0.00138889), (92,0.00138889), (93,0.00138889), (94,0.00138889), (95,0.00138889), (96,0.00138889), (97,0.00138889), (98,0.00138889), (99,0.00138889), (100,0.00138889), (101,0.00138889), (102,0.00138889), (103,0.00138889), (104,0.00138889), (105,0.00138889), (106,0.00138889), (107,0.00138889), (108,0.00138889), (109,0.00138889), (110,0.00138889), (111,0.00138889), (112,0.00138889), (113,0.00138889), (114,0.00138889), (115,0.00138889), (116,0.00138889), (117,0.00138889), (118,0.00138889), (119,0.00138889), (120,0.00138889), (121,0.00138889), (122,0.00138889), (123,0.00138889), (124,0.00138889), (125,0.00138889), (126,0.00138889), (127,0.00138889), (128,0.00138889), (129,0.00138889), (130,0.00138889), (131,0.00138889), (132,0.00138889), (133,0.00138889), (134,0.00138889), (135,0.00138889), (136,0.00138889), (137,0.00138889), (138,0.00138889), (139,0.00138889), (140,0.00138889), (141,0.00138889), (142,0.00138889), (143,0.00138889), (144,0.00138889), (145,0.00138889), (146,0.00138889), (147,0.00138889), (148,0.00138889), (149,0.00138889), (150,0.00138889), (151,0.00138889), (152,0.00138889), (153,0.00138889), (154,0.00138889), (155,0.00138889), (156,0.00138889), (157,0.00138889), (158,0.00138889), (159,0.00138889), (160,0.00138889), (161,0.00138889), (162,0.00138889), (163,0.00138889), (164,0.00138889), (165,0.00138889), (166,0.00138889), (167,0.00138889), (168,0.00138889), (169,0.00138889), (170,0.00138889), (171,0.00138889), (172,0.00138889), (173,0.00138889), (174,0.00138889), (175,0.00138889), (176,0.00138889), (177,0.00138889), (178,0.00138889), (179,0.00138889), (180,0.00138889), (181,0.00138889), (182,0.00138889), (183,0.00138889), (184,0.00138889), (185,0.00138889), (186,0.00138889), (187,0.00138889), (188,0.00138889), (189,0.00138889), (190,0.00138889), (191,0.00138889), (192,0.00138889), (193,0.00138889), (194,0.00138889), (195,0.00138889), (196,0.00138889), (197,0.00138889), (198,0.00138889), (199,0.00138889), (200,0.00138889), (201,0.00138889), (202,0.00138889), (203,0.00138889), (204,0.00138889), (205,0.00138889), (206,0.00138889), (207,0.00138889), (208,0.00138889), (209,0.00138889), (210,0.00138889), (211,0.00138889), (212,0.00138889), (213,0.00138889), (214,0.00138889), (215,0.00138889), (216,0.00138889), (217,0.00138889), (218,0.00138889), (219,0.00138889), (220,0.00138889), (221,0.00138889), (222,0.00138889), (223,0.00138889), (224,0.00138889), (225,0.00138889), (226,0.00138889), (227,0.00138889), (228,0.00138889), (229,0.00138889), (230,0.00138889), (231,0.00138889), (232,0.00138889), (233,0.00138889), (234,0.00138889), (235,0.00138889), (236,0.00138889), (237,0.00138889), (238,0.00138889), (239,0.00138889), (240,0.00138889), (241,0.00138889), (242,0.00138889), (243,0.00138889), (244,0.00138889), (245,0.00138889), (246,0.00138889), (247,0.00138889), (248,0.00138889), (249,0.00138889), (250,0.00138889), (251,0.00138889), (252,0.00138889), (253,0.00138889), (254,0.00138889), (255,0.00138889), (256,0.00138889), (257,0.00138889), (258,0.00138889), (259,0.00138889), (260,0.00138889), (261,0.00138889), (262,0.00138889), (263,0.00138889), (264,0.00138889), (265,0.00138889), (266,0.00138889), (267,0.00138889), (268,0.00138889), (269,0.00138889), (270,0.00138889), (271,0.00138889), (272,0.00138889), (273,0.00138889), (274,0.00138889), (275,0.00138889), (276,0.00138889), (277,0.00138889), (278,0.00138889), (279,0.00138889), (280,0.00138889), (281,0.00138889), (282,0.00138889), (283,0.00138889), (284,0.00138889), (285,0.00138889), (286,0.00138889), (287,0.00138889), (288,0.00138889), (289,0.00138889), (290,0.00138889), (291,0.00138889), (292,0.00138889), (293,0.00138889), (294,0.00138889), (295,0.00138889), (296,0.00138889), (297,0.00138889), (298,0.00138889), (299,0.00138889), (300,0.00138889), (301,0.00138889), (302,0.00138889), (303,0.00138889), (304,0.00138889), (305,0.00138889), (306,0.00138889), (307,0.00138889), (308,0.00138889), (309,0.00138889), (310,0.00138889), (311,0.00138889), (312,0.00138889), (313,0.00138889), (314,0.00138889), (315,0.00138889), (316,0.00138889), (317,0.00138889), (318,0.00138889), (319,0.00138889), (320,0.00138889), (321,0.00138889), (322,0.00138889), (323,0.00138889), (324,0.00138889), (325,0.00138889), (326,0.00138889), (327,0.00138889), (328,0.00138889), (329,0.00138889), (330,0.00138889), (331,0.00138889), (332,0.00138889), (333,0.00138889), (334,0.00138889), (335,0.00138889), (336,0.00138889), (337,0.00138889), (338,0.00138889), (339,0.00138889), (340,0.00138889), (341,0.00138889), (342,0.00138889), (343,0.00138889), (344,0.00138889), (345,0.00138889), (346,0.00138889), (347,0.00138889), (348,0.00138889), (349,0.00138889), (350,0.00138889), (351,0.00138889), (352,0.00138889), (353,0.00138889), (354,0.00138889), (355,0.00138889), (356,0.00138889), (357,0.00138889), (358,0.00138889), (359,0.00138889), (360,0.00138889), (361,0.00138889), (362,0.00138889), (363,0.00138889), (364,0.00138889), (365,0.00138889), (366,0.00138889), (367,0.00138889), (368,0.00138889), (369,0.00138889), (370,0.00138889), (371,0.00138889), (372,0.00138889), (373,0.00138889), (374,0.00138889), (375,0.00138889), (376,0.00138889), (377,0.00138889), (378,0.00138889), (379,0.00138889), (380,0.00138889), (381,0.00138889), (382,0.00138889), (383,0.00138889), (384,0.00138889), (385,0.00138889), (386,0.00138889), (387,0.00138889), (388,0.00138889), (389,0.00138889), (390,0.00138889), (391,0.00138889), (392,0.00138889), (393,0.00138889), (394,0.00138889), (395,0.00138889), (396,0.00138889), (397,0.00138889), (398,0.00138889), (399,0.00138889), (400,0.00138889), (401,0.00138889), (402,0.00138889), (403,0.00138889), (404,0.00138889), (405,0.00138889), (406,0.00138889), (407,0.00138889), (408,0.00138889), (409,0.00138889), (410,0.00138889), (411,0.00138889), (412,0.00138889), (413,0.00138889), (414,0.00138889), (415,0.00138889), (416,0.00138889), (417,0.00138889), (418,0.00138889), (419,0.00138889), (420,0.00138889), (421,0.00138889), (422,0.00138889), (423,0.00138889), (424,0.00138889), (425,0.00138889), (426,0.00138889), (427,0.00138889), (428,0.00138889), (429,0.00138889), (430,0.00138889), (431,0.00138889), (432,0.00138889), (433,0.00138889), (434,0.00138889), (435,0.00138889), (436,0.00138889), (437,0.00138889), (438,0.00138889), (439,0.00138889), (440,0.00138889), (441,0.00138889), (442,0.00138889), (443,0.00138889), (444,0.00138889), (445,0.00138889), (446,0.00138889), (447,0.00138889), (448,0.00138889), (449,0.00138889), (450,0.00138889), (451,0.00138889), (452,0.00138889), (453,0.00138889), (454,0.00138889), (455,0.00138889), (456,0.00138889), (457,0.00138889), (458,0.00138889), (459,0.00138889), (460,0.00138889), (461,0.00138889), (462,0.00138889), (463,0.00138889), (464,0.00138889), (465,0.00138889), (466,0.00138889), (467,0.00138889), (468,0.00138889), (469,0.00138889), (470,0.00138889), (471,0.00138889), (472,0.00138889), (473,0.00138889), (474,0.00138889), (475,0.00138889), (476,0.00138889), (477,0.00138889), (478,0.00138889), (479,0.00138889), (480,0.00138889), (481,0.00138889), (482,0.00138889), (483,0.00138889), (484,0.00138889), (485,0.00138889), (486,0.00138889), (487,0.00138889), (488,0.00138889), (489,0.00138889), (490,0.00138889), (491,0.00138889), (492,0.00138889), (493,0.00138889), (494,0.00138889), (495,0.00138889), (496,0.00138889), (497,0.00138889), (498,0.00138889), (499,0.00138889), (500,0.00138889), (501,0.00138889), (502,0.00138889), (503,0.00138889), (504,0.00138889), (505,0.00138889), (506,0.00138889), (507,0.00138889), (508,0.00138889), (509,0.00138889), (510,0.00138889), (511,0.00138889), (512,0.00138889), (513,0.00138889), (514,0.00138889), (515,0.00138889), (516,0.00138889), (517,0.00138889), (518,0.00138889), (519,0.00138889), (520,0.00138889), (521,0.00138889), (522,0.00138889), (523,0.00138889), (524,0.00138889), (525,0.00138889), (526,0.00138889), (527,0.00138889), (528,0.00138889), (529,0.00138889), (530,0.00138889), (531,0.00138889), (532,0.00138889), (533,0.00138889), (534,0.00138889), (535,0.00138889), (536,0.00138889), (537,0.00138889), (538,0.00138889), (539,0.00138889), (540,0.00138889), (541,0.00138889), (542,0.00138889), (543,0.00138889), (544,0.00138889), (545,0.00138889), (546,0.00138889), (547,0.00138889), (548,0.00138889), (549,0.00138889), (550,0.00138889), (551,0.00138889), (552,0.00138889), (553,0.00138889), (554,0.00138889), (555,0.00138889), (556,0.00138889), (557,0.00138889), (558,0.00138889), (559,0.00138889), (560,0.00138889), (561,0.00138889), (562,0.00138889), (563,0.00138889), (564,0.00138889), (565,0.00138889), (566,0.00138889), (567,0.00138889), (568,0.00138889), (569,0.00138889), (570,0.00138889), (571,0.00138889), (572,0.00138889), (573,0.00138889), (574,0.00138889), (575,0.00138889), (576,0.00138889), (577,0.00138889), (578,0.00138889), (579,0.00138889), (580,0.00138889), (581,0.00138889), (582,0.00138889), (583,0.00138889), (584,0.00138889), (585,0.00138889), (586,0.00138889), (587,0.00138889), (588,0.00138889), (589,0.00138889), (590,0.00138889), (591,0.00138889), (592,0.00138889), (593,0.00138889), (594,0.00138889), (595,0.00138889), (596,0.00138889), (597,0.00138889), (598,0.00138889), (599,0.00138889), (600,0.00138889), (601,0.00138889), (602,0.00138889), (603,0.00138889), (604,0.00138889), (605,0.00138889), (606,0.00138889), (607,0.00138889), (608,0.00138889), (609,0.00138889), (610,0.00138889), (611,0.00138889), (612,0.00138889), (613,0.00138889), (614,0.00138889), (615,0.00138889), (616,0.00138889), (617,0.00138889), (618,0.00138889), (619,0.00138889), (620,0.00138889), (621,0.00138889), (622,0.00138889), (623,0.00138889), (624,0.00138889), (625,0.00138889), (626,0.00138889), (627,0.00138889), (628,0.00138889), (629,0.00138889), (630,0.00138889), (631,0.00138889), (632,0.00138889), (633,0.00138889), (634,0.00138889), (635,0.00138889), (636,0.00138889), (637,0.00138889), (638,0.00138889), (639,0.00138889), (640,0.00138889), (641,0.00138889), (642,0.00138889), (643,0.00138889), (644,0.00138889), (645,0.00138889), (646,0.00138889), (647,0.00138889), (648,0.00138889), (649,0.00138889), (650,0.00138889), (651,0.00138889), (652,0.00138889), (653,0.00138889), (654,0.00138889), (655,0.00138889), (656,0.00138889), (657,0.00138889), (658,0.00138889), (659,0.00138889), (660,0.00138889), (661,0.00138889), (662,0.00138889), (663,0.00138889), (664,0.00138889), (665,0.00138889), (666,0.00138889), (667,0.00138889), (668,0.00138889), (669,0.00138889), (670,0.00138889), (671,0.00138889), (672,0.00138889), (673,0.00138889), (674,0.00138889), (675,0.00138889), (676,0.00138889), (677,0.00138889), (678,0.00138889), (679,0.00138889), (680,0.00138889), (681,0.00138889), (682,0.00138889), (683,0.00138889), (684,0.00138889), (685,0.00138889), (686,0.00138889), (687,0.00138889), (688,0.00138889), (689,0.00138889), (690,0.00138889), (691,0.00138889), (692,0.00138889), (693,0.00138889), (694,0.00138889), (695,0.00138889), (696,0.00138889), (697,0.00138889), (698,0.00138889), (699,0.00138889), (700,0.00138889), (701,0.00138889), (702,0.00138889), (703,0.00138889), (704,0.00138889), (705,0.00138889), (706,0.00138889), (707,0.00138889), (708,0.00138889), (709,0.00138889), (710,0.00138889), (711,0.00138889), (712,0.00138889), (713,0.00138889), (714,0.00138889), (715,0.00138889), (716,0.00138889), (717,0.00138889), (718,0.00138889), (719,0.00138889)] +LegalActions() = [0, 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, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719] +StringLegalActions() = ["Placing black cubes on the board - action 0", "Placing black cubes on the board - action 1", "Placing black cubes on the board - action 2", "Placing black cubes on the board - action 3", "Placing black cubes on the board - action 4", "Placing black cubes on the board - action 5", "Placing black cubes on the board - action 6", "Placing black cubes on the board - action 7", "Placing black cubes on the board - action 8", "Placing black cubes on the board - action 9", "Placing black cubes on the board - action 10", "Placing black cubes on the board - action 11", "Placing black cubes on the board - action 12", "Placing black cubes on the board - action 13", "Placing black cubes on the board - action 14", "Placing black cubes on the board - action 15", "Placing black cubes on the board - action 16", "Placing black cubes on the board - action 17", "Placing black cubes on the board - action 18", "Placing black cubes on the board - action 19", "Placing black cubes on the board - action 20", "Placing black cubes on the board - action 21", "Placing black cubes on the board - action 22", "Placing black cubes on the board - action 23", "Placing black cubes on the board - action 24", "Placing black cubes on the board - action 25", "Placing black cubes on the board - action 26", "Placing black cubes on the board - action 27", "Placing black cubes on the board - action 28", "Placing black cubes on the board - action 29", "Placing black cubes on the board - action 30", "Placing black cubes on the board - action 31", "Placing black cubes on the board - action 32", "Placing black cubes on the board - action 33", "Placing black cubes on the board - action 34", "Placing black cubes on the board - action 35", "Placing black cubes on the board - action 36", "Placing black cubes on the board - action 37", "Placing black cubes on the board - action 38", "Placing black cubes on the board - action 39", "Placing black cubes on the board - action 40", "Placing black cubes on the board - action 41", "Placing black cubes on the board - action 42", "Placing black cubes on the board - action 43", "Placing black cubes on the board - action 44", "Placing black cubes on the board - action 45", "Placing black cubes on the board - action 46", "Placing black cubes on the board - action 47", "Placing black cubes on the board - action 48", "Placing black cubes on the board - action 49", "Placing black cubes on the board - action 50", "Placing black cubes on the board - action 51", "Placing black cubes on the board - action 52", "Placing black cubes on the board - action 53", "Placing black cubes on the board - action 54", "Placing black cubes on the board - action 55", "Placing black cubes on the board - action 56", "Placing black cubes on the board - action 57", "Placing black cubes on the board - action 58", "Placing black cubes on the board - action 59", "Placing black cubes on the board - action 60", "Placing black cubes on the board - action 61", "Placing black cubes on the board - action 62", "Placing black cubes on the board - action 63", "Placing black cubes on the board - action 64", "Placing black cubes on the board - action 65", "Placing black cubes on the board - action 66", "Placing black cubes on the board - action 67", "Placing black cubes on the board - action 68", "Placing black cubes on the board - action 69", "Placing black cubes on the board - action 70", "Placing black cubes on the board - action 71", "Placing black cubes on the board - action 72", "Placing black cubes on the board - action 73", "Placing black cubes on the board - action 74", "Placing black cubes on the board - action 75", "Placing black cubes on the board - action 76", "Placing black cubes on the board - action 77", "Placing black cubes on the board - action 78", "Placing black cubes on the board - action 79", "Placing black cubes on the board - action 80", "Placing black cubes on the board - action 81", "Placing black cubes on the board - action 82", "Placing black cubes on the board - action 83", "Placing black cubes on the board - action 84", "Placing black cubes on the board - action 85", "Placing black cubes on the board - action 86", "Placing black cubes on the board - action 87", "Placing black cubes on the board - action 88", "Placing black cubes on the board - action 89", "Placing black cubes on the board - action 90", "Placing black cubes on the board - action 91", "Placing black cubes on the board - action 92", "Placing black cubes on the board - action 93", "Placing black cubes on the board - action 94", "Placing black cubes on the board - action 95", "Placing black cubes on the board - action 96", "Placing black cubes on the board - action 97", "Placing black cubes on the board - action 98", "Placing black cubes on the board - action 99", "Placing black cubes on the board - action 100", "Placing black cubes on the board - action 101", "Placing black cubes on the board - action 102", "Placing black cubes on the board - action 103", "Placing black cubes on the board - action 104", "Placing black cubes on the board - action 105", "Placing black cubes on the board - action 106", "Placing black cubes on the board - action 107", "Placing black cubes on the board - action 108", "Placing black cubes on the board - action 109", "Placing black cubes on the board - action 110", "Placing black cubes on the board - action 111", "Placing black cubes on the board - action 112", "Placing black cubes on the board - action 113", "Placing black cubes on the board - action 114", "Placing black cubes on the board - action 115", "Placing black cubes on the board - action 116", "Placing black cubes on the board - action 117", "Placing black cubes on the board - action 118", "Placing black cubes on the board - action 119", "Placing black cubes on the board - action 120", "Placing black cubes on the board - action 121", "Placing black cubes on the board - action 122", "Placing black cubes on the board - action 123", "Placing black cubes on the board - action 124", "Placing black cubes on the board - action 125", "Placing black cubes on the board - action 126", "Placing black cubes on the board - action 127", "Placing black cubes on the board - action 128", "Placing black cubes on the board - action 129", "Placing black cubes on the board - action 130", "Placing black cubes on the board - action 131", "Placing black cubes on the board - action 132", "Placing black cubes on the board - action 133", "Placing black cubes on the board - action 134", "Placing black cubes on the board - action 135", "Placing black cubes on the board - action 136", "Placing black cubes on the board - action 137", "Placing black cubes on the board - action 138", "Placing black cubes on the board - action 139", "Placing black cubes on the board - action 140", "Placing black cubes on the board - action 141", "Placing black cubes on the board - action 142", "Placing black cubes on the board - action 143", "Placing black cubes on the board - action 144", "Placing black cubes on the board - action 145", "Placing black cubes on the board - action 146", "Placing black cubes on the board - action 147", "Placing black cubes on the board - action 148", "Placing black cubes on the board - action 149", "Placing black cubes on the board - action 150", "Placing black cubes on the board - action 151", "Placing black cubes on the board - action 152", "Placing black cubes on the board - action 153", "Placing black cubes on the board - action 154", "Placing black cubes on the board - action 155", "Placing black cubes on the board - action 156", "Placing black cubes on the board - action 157", "Placing black cubes on the board - action 158", "Placing black cubes on the board - action 159", "Placing black cubes on the board - action 160", "Placing black cubes on the board - action 161", "Placing black cubes on the board - action 162", "Placing black cubes on the board - action 163", "Placing black cubes on the board - action 164", "Placing black cubes on the board - action 165", "Placing black cubes on the board - action 166", "Placing black cubes on the board - action 167", "Placing black cubes on the board - action 168", "Placing black cubes on the board - action 169", "Placing black cubes on the board - action 170", "Placing black cubes on the board - action 171", "Placing black cubes on the board - action 172", "Placing black cubes on the board - action 173", "Placing black cubes on the board - action 174", "Placing black cubes on the board - action 175", "Placing black cubes on the board - action 176", "Placing black cubes on the board - action 177", "Placing black cubes on the board - action 178", "Placing black cubes on the board - action 179", "Placing black cubes on the board - action 180", "Placing black cubes on the board - action 181", "Placing black cubes on the board - action 182", "Placing black cubes on the board - action 183", "Placing black cubes on the board - action 184", "Placing black cubes on the board - action 185", "Placing black cubes on the board - action 186", "Placing black cubes on the board - action 187", "Placing black cubes on the board - action 188", "Placing black cubes on the board - action 189", "Placing black cubes on the board - action 190", "Placing black cubes on the board - action 191", "Placing black cubes on the board - action 192", "Placing black cubes on the board - action 193", "Placing black cubes on the board - action 194", "Placing black cubes on the board - action 195", "Placing black cubes on the board - action 196", "Placing black cubes on the board - action 197", "Placing black cubes on the board - action 198", "Placing black cubes on the board - action 199", "Placing black cubes on the board - action 200", "Placing black cubes on the board - action 201", "Placing black cubes on the board - action 202", "Placing black cubes on the board - action 203", "Placing black cubes on the board - action 204", "Placing black cubes on the board - action 205", "Placing black cubes on the board - action 206", "Placing black cubes on the board - action 207", "Placing black cubes on the board - action 208", "Placing black cubes on the board - action 209", "Placing black cubes on the board - action 210", "Placing black cubes on the board - action 211", "Placing black cubes on the board - action 212", "Placing black cubes on the board - action 213", "Placing black cubes on the board - action 214", "Placing black cubes on the board - action 215", "Placing black cubes on the board - action 216", "Placing black cubes on the board - action 217", "Placing black cubes on the board - action 218", "Placing black cubes on the board - action 219", "Placing black cubes on the board - action 220", "Placing black cubes on the board - action 221", "Placing black cubes on the board - action 222", "Placing black cubes on the board - action 223", "Placing black cubes on the board - action 224", "Placing black cubes on the board - action 225", "Placing black cubes on the board - action 226", "Placing black cubes on the board - action 227", "Placing black cubes on the board - action 228", "Placing black cubes on the board - action 229", "Placing black cubes on the board - action 230", "Placing black cubes on the board - action 231", "Placing black cubes on the board - action 232", "Placing black cubes on the board - action 233", "Placing black cubes on the board - action 234", "Placing black cubes on the board - action 235", "Placing black cubes on the board - action 236", "Placing black cubes on the board - action 237", "Placing black cubes on the board - action 238", "Placing black cubes on the board - action 239", "Placing black cubes on the board - action 240", "Placing black cubes on the board - action 241", "Placing black cubes on the board - action 242", "Placing black cubes on the board - action 243", "Placing black cubes on the board - action 244", "Placing black cubes on the board - action 245", "Placing black cubes on the board - action 246", "Placing black cubes on the board - action 247", "Placing black cubes on the board - action 248", "Placing black cubes on the board - action 249", "Placing black cubes on the board - action 250", "Placing black cubes on the board - action 251", "Placing black cubes on the board - action 252", "Placing black cubes on the board - action 253", "Placing black cubes on the board - action 254", "Placing black cubes on the board - action 255", "Placing black cubes on the board - action 256", "Placing black cubes on the board - action 257", "Placing black cubes on the board - action 258", "Placing black cubes on the board - action 259", "Placing black cubes on the board - action 260", "Placing black cubes on the board - action 261", "Placing black cubes on the board - action 262", "Placing black cubes on the board - action 263", "Placing black cubes on the board - action 264", "Placing black cubes on the board - action 265", "Placing black cubes on the board - action 266", "Placing black cubes on the board - action 267", "Placing black cubes on the board - action 268", "Placing black cubes on the board - action 269", "Placing black cubes on the board - action 270", "Placing black cubes on the board - action 271", "Placing black cubes on the board - action 272", "Placing black cubes on the board - action 273", "Placing black cubes on the board - action 274", "Placing black cubes on the board - action 275", "Placing black cubes on the board - action 276", "Placing black cubes on the board - action 277", "Placing black cubes on the board - action 278", "Placing black cubes on the board - action 279", "Placing black cubes on the board - action 280", "Placing black cubes on the board - action 281", "Placing black cubes on the board - action 282", "Placing black cubes on the board - action 283", "Placing black cubes on the board - action 284", "Placing black cubes on the board - action 285", "Placing black cubes on the board - action 286", "Placing black cubes on the board - action 287", "Placing black cubes on the board - action 288", "Placing black cubes on the board - action 289", "Placing black cubes on the board - action 290", "Placing black cubes on the board - action 291", "Placing black cubes on the board - action 292", "Placing black cubes on the board - action 293", "Placing black cubes on the board - action 294", "Placing black cubes on the board - action 295", "Placing black cubes on the board - action 296", "Placing black cubes on the board - action 297", "Placing black cubes on the board - action 298", "Placing black cubes on the board - action 299", "Placing black cubes on the board - action 300", "Placing black cubes on the board - action 301", "Placing black cubes on the board - action 302", "Placing black cubes on the board - action 303", "Placing black cubes on the board - action 304", "Placing black cubes on the board - action 305", "Placing black cubes on the board - action 306", "Placing black cubes on the board - action 307", "Placing black cubes on the board - action 308", "Placing black cubes on the board - action 309", "Placing black cubes on the board - action 310", "Placing black cubes on the board - action 311", "Placing black cubes on the board - action 312", "Placing black cubes on the board - action 313", "Placing black cubes on the board - action 314", "Placing black cubes on the board - action 315", "Placing black cubes on the board - action 316", "Placing black cubes on the board - action 317", "Placing black cubes on the board - action 318", "Placing black cubes on the board - action 319", "Placing black cubes on the board - action 320", "Placing black cubes on the board - action 321", "Placing black cubes on the board - action 322", "Placing black cubes on the board - action 323", "Placing black cubes on the board - action 324", "Placing black cubes on the board - action 325", "Placing black cubes on the board - action 326", "Placing black cubes on the board - action 327", "Placing black cubes on the board - action 328", "Placing black cubes on the board - action 329", "Placing black cubes on the board - action 330", "Placing black cubes on the board - action 331", "Placing black cubes on the board - action 332", "Placing black cubes on the board - action 333", "Placing black cubes on the board - action 334", "Placing black cubes on the board - action 335", "Placing black cubes on the board - action 336", "Placing black cubes on the board - action 337", "Placing black cubes on the board - action 338", "Placing black cubes on the board - action 339", "Placing black cubes on the board - action 340", "Placing black cubes on the board - action 341", "Placing black cubes on the board - action 342", "Placing black cubes on the board - action 343", "Placing black cubes on the board - action 344", "Placing black cubes on the board - action 345", "Placing black cubes on the board - action 346", "Placing black cubes on the board - action 347", "Placing black cubes on the board - action 348", "Placing black cubes on the board - action 349", "Placing black cubes on the board - action 350", "Placing black cubes on the board - action 351", "Placing black cubes on the board - action 352", "Placing black cubes on the board - action 353", "Placing black cubes on the board - action 354", "Placing black cubes on the board - action 355", "Placing black cubes on the board - action 356", "Placing black cubes on the board - action 357", "Placing black cubes on the board - action 358", "Placing black cubes on the board - action 359", "Placing black cubes on the board - action 360", "Placing black cubes on the board - action 361", "Placing black cubes on the board - action 362", "Placing black cubes on the board - action 363", "Placing black cubes on the board - action 364", "Placing black cubes on the board - action 365", "Placing black cubes on the board - action 366", "Placing black cubes on the board - action 367", "Placing black cubes on the board - action 368", "Placing black cubes on the board - action 369", "Placing black cubes on the board - action 370", "Placing black cubes on the board - action 371", "Placing black cubes on the board - action 372", "Placing black cubes on the board - action 373", "Placing black cubes on the board - action 374", "Placing black cubes on the board - action 375", "Placing black cubes on the board - action 376", "Placing black cubes on the board - action 377", "Placing black cubes on the board - action 378", "Placing black cubes on the board - action 379", "Placing black cubes on the board - action 380", "Placing black cubes on the board - action 381", "Placing black cubes on the board - action 382", "Placing black cubes on the board - action 383", "Placing black cubes on the board - action 384", "Placing black cubes on the board - action 385", "Placing black cubes on the board - action 386", "Placing black cubes on the board - action 387", "Placing black cubes on the board - action 388", "Placing black cubes on the board - action 389", "Placing black cubes on the board - action 390", "Placing black cubes on the board - action 391", "Placing black cubes on the board - action 392", "Placing black cubes on the board - action 393", "Placing black cubes on the board - action 394", "Placing black cubes on the board - action 395", "Placing black cubes on the board - action 396", "Placing black cubes on the board - action 397", "Placing black cubes on the board - action 398", "Placing black cubes on the board - action 399", "Placing black cubes on the board - action 400", "Placing black cubes on the board - action 401", "Placing black cubes on the board - action 402", "Placing black cubes on the board - action 403", "Placing black cubes on the board - action 404", "Placing black cubes on the board - action 405", "Placing black cubes on the board - action 406", "Placing black cubes on the board - action 407", "Placing black cubes on the board - action 408", "Placing black cubes on the board - action 409", "Placing black cubes on the board - action 410", "Placing black cubes on the board - action 411", "Placing black cubes on the board - action 412", "Placing black cubes on the board - action 413", "Placing black cubes on the board - action 414", "Placing black cubes on the board - action 415", "Placing black cubes on the board - action 416", "Placing black cubes on the board - action 417", "Placing black cubes on the board - action 418", "Placing black cubes on the board - action 419", "Placing black cubes on the board - action 420", "Placing black cubes on the board - action 421", "Placing black cubes on the board - action 422", "Placing black cubes on the board - action 423", "Placing black cubes on the board - action 424", "Placing black cubes on the board - action 425", "Placing black cubes on the board - action 426", "Placing black cubes on the board - action 427", "Placing black cubes on the board - action 428", "Placing black cubes on the board - action 429", "Placing black cubes on the board - action 430", "Placing black cubes on the board - action 431", "Placing black cubes on the board - action 432", "Placing black cubes on the board - action 433", "Placing black cubes on the board - action 434", "Placing black cubes on the board - action 435", "Placing black cubes on the board - action 436", "Placing black cubes on the board - action 437", "Placing black cubes on the board - action 438", "Placing black cubes on the board - action 439", "Placing black cubes on the board - action 440", "Placing black cubes on the board - action 441", "Placing black cubes on the board - action 442", "Placing black cubes on the board - action 443", "Placing black cubes on the board - action 444", "Placing black cubes on the board - action 445", "Placing black cubes on the board - action 446", "Placing black cubes on the board - action 447", "Placing black cubes on the board - action 448", "Placing black cubes on the board - action 449", "Placing black cubes on the board - action 450", "Placing black cubes on the board - action 451", "Placing black cubes on the board - action 452", "Placing black cubes on the board - action 453", "Placing black cubes on the board - action 454", "Placing black cubes on the board - action 455", "Placing black cubes on the board - action 456", "Placing black cubes on the board - action 457", "Placing black cubes on the board - action 458", "Placing black cubes on the board - action 459", "Placing black cubes on the board - action 460", "Placing black cubes on the board - action 461", "Placing black cubes on the board - action 462", "Placing black cubes on the board - action 463", "Placing black cubes on the board - action 464", "Placing black cubes on the board - action 465", "Placing black cubes on the board - action 466", "Placing black cubes on the board - action 467", "Placing black cubes on the board - action 468", "Placing black cubes on the board - action 469", "Placing black cubes on the board - action 470", "Placing black cubes on the board - action 471", "Placing black cubes on the board - action 472", "Placing black cubes on the board - action 473", "Placing black cubes on the board - action 474", "Placing black cubes on the board - action 475", "Placing black cubes on the board - action 476", "Placing black cubes on the board - action 477", "Placing black cubes on the board - action 478", "Placing black cubes on the board - action 479", "Placing black cubes on the board - action 480", "Placing black cubes on the board - action 481", "Placing black cubes on the board - action 482", "Placing black cubes on the board - action 483", "Placing black cubes on the board - action 484", "Placing black cubes on the board - action 485", "Placing black cubes on the board - action 486", "Placing black cubes on the board - action 487", "Placing black cubes on the board - action 488", "Placing black cubes on the board - action 489", "Placing black cubes on the board - action 490", "Placing black cubes on the board - action 491", "Placing black cubes on the board - action 492", "Placing black cubes on the board - action 493", "Placing black cubes on the board - action 494", "Placing black cubes on the board - action 495", "Placing black cubes on the board - action 496", "Placing black cubes on the board - action 497", "Placing black cubes on the board - action 498", "Placing black cubes on the board - action 499", "Placing black cubes on the board - action 500", "Placing black cubes on the board - action 501", "Placing black cubes on the board - action 502", "Placing black cubes on the board - action 503", "Placing black cubes on the board - action 504", "Placing black cubes on the board - action 505", "Placing black cubes on the board - action 506", "Placing black cubes on the board - action 507", "Placing black cubes on the board - action 508", "Placing black cubes on the board - action 509", "Placing black cubes on the board - action 510", "Placing black cubes on the board - action 511", "Placing black cubes on the board - action 512", "Placing black cubes on the board - action 513", "Placing black cubes on the board - action 514", "Placing black cubes on the board - action 515", "Placing black cubes on the board - action 516", "Placing black cubes on the board - action 517", "Placing black cubes on the board - action 518", "Placing black cubes on the board - action 519", "Placing black cubes on the board - action 520", "Placing black cubes on the board - action 521", "Placing black cubes on the board - action 522", "Placing black cubes on the board - action 523", "Placing black cubes on the board - action 524", "Placing black cubes on the board - action 525", "Placing black cubes on the board - action 526", "Placing black cubes on the board - action 527", "Placing black cubes on the board - action 528", "Placing black cubes on the board - action 529", "Placing black cubes on the board - action 530", "Placing black cubes on the board - action 531", "Placing black cubes on the board - action 532", "Placing black cubes on the board - action 533", "Placing black cubes on the board - action 534", "Placing black cubes on the board - action 535", "Placing black cubes on the board - action 536", "Placing black cubes on the board - action 537", "Placing black cubes on the board - action 538", "Placing black cubes on the board - action 539", "Placing black cubes on the board - action 540", "Placing black cubes on the board - action 541", "Placing black cubes on the board - action 542", "Placing black cubes on the board - action 543", "Placing black cubes on the board - action 544", "Placing black cubes on the board - action 545", "Placing black cubes on the board - action 546", "Placing black cubes on the board - action 547", "Placing black cubes on the board - action 548", "Placing black cubes on the board - action 549", "Placing black cubes on the board - action 550", "Placing black cubes on the board - action 551", "Placing black cubes on the board - action 552", "Placing black cubes on the board - action 553", "Placing black cubes on the board - action 554", "Placing black cubes on the board - action 555", "Placing black cubes on the board - action 556", "Placing black cubes on the board - action 557", "Placing black cubes on the board - action 558", "Placing black cubes on the board - action 559", "Placing black cubes on the board - action 560", "Placing black cubes on the board - action 561", "Placing black cubes on the board - action 562", "Placing black cubes on the board - action 563", "Placing black cubes on the board - action 564", "Placing black cubes on the board - action 565", "Placing black cubes on the board - action 566", "Placing black cubes on the board - action 567", "Placing black cubes on the board - action 568", "Placing black cubes on the board - action 569", "Placing black cubes on the board - action 570", "Placing black cubes on the board - action 571", "Placing black cubes on the board - action 572", "Placing black cubes on the board - action 573", "Placing black cubes on the board - action 574", "Placing black cubes on the board - action 575", "Placing black cubes on the board - action 576", "Placing black cubes on the board - action 577", "Placing black cubes on the board - action 578", "Placing black cubes on the board - action 579", "Placing black cubes on the board - action 580", "Placing black cubes on the board - action 581", "Placing black cubes on the board - action 582", "Placing black cubes on the board - action 583", "Placing black cubes on the board - action 584", "Placing black cubes on the board - action 585", "Placing black cubes on the board - action 586", "Placing black cubes on the board - action 587", "Placing black cubes on the board - action 588", "Placing black cubes on the board - action 589", "Placing black cubes on the board - action 590", "Placing black cubes on the board - action 591", "Placing black cubes on the board - action 592", "Placing black cubes on the board - action 593", "Placing black cubes on the board - action 594", "Placing black cubes on the board - action 595", "Placing black cubes on the board - action 596", "Placing black cubes on the board - action 597", "Placing black cubes on the board - action 598", "Placing black cubes on the board - action 599", "Placing black cubes on the board - action 600", "Placing black cubes on the board - action 601", "Placing black cubes on the board - action 602", "Placing black cubes on the board - action 603", "Placing black cubes on the board - action 604", "Placing black cubes on the board - action 605", "Placing black cubes on the board - action 606", "Placing black cubes on the board - action 607", "Placing black cubes on the board - action 608", "Placing black cubes on the board - action 609", "Placing black cubes on the board - action 610", "Placing black cubes on the board - action 611", "Placing black cubes on the board - action 612", "Placing black cubes on the board - action 613", "Placing black cubes on the board - action 614", "Placing black cubes on the board - action 615", "Placing black cubes on the board - action 616", "Placing black cubes on the board - action 617", "Placing black cubes on the board - action 618", "Placing black cubes on the board - action 619", "Placing black cubes on the board - action 620", "Placing black cubes on the board - action 621", "Placing black cubes on the board - action 622", "Placing black cubes on the board - action 623", "Placing black cubes on the board - action 624", "Placing black cubes on the board - action 625", "Placing black cubes on the board - action 626", "Placing black cubes on the board - action 627", "Placing black cubes on the board - action 628", "Placing black cubes on the board - action 629", "Placing black cubes on the board - action 630", "Placing black cubes on the board - action 631", "Placing black cubes on the board - action 632", "Placing black cubes on the board - action 633", "Placing black cubes on the board - action 634", "Placing black cubes on the board - action 635", "Placing black cubes on the board - action 636", "Placing black cubes on the board - action 637", "Placing black cubes on the board - action 638", "Placing black cubes on the board - action 639", "Placing black cubes on the board - action 640", "Placing black cubes on the board - action 641", "Placing black cubes on the board - action 642", "Placing black cubes on the board - action 643", "Placing black cubes on the board - action 644", "Placing black cubes on the board - action 645", "Placing black cubes on the board - action 646", "Placing black cubes on the board - action 647", "Placing black cubes on the board - action 648", "Placing black cubes on the board - action 649", "Placing black cubes on the board - action 650", "Placing black cubes on the board - action 651", "Placing black cubes on the board - action 652", "Placing black cubes on the board - action 653", "Placing black cubes on the board - action 654", "Placing black cubes on the board - action 655", "Placing black cubes on the board - action 656", "Placing black cubes on the board - action 657", "Placing black cubes on the board - action 658", "Placing black cubes on the board - action 659", "Placing black cubes on the board - action 660", "Placing black cubes on the board - action 661", "Placing black cubes on the board - action 662", "Placing black cubes on the board - action 663", "Placing black cubes on the board - action 664", "Placing black cubes on the board - action 665", "Placing black cubes on the board - action 666", "Placing black cubes on the board - action 667", "Placing black cubes on the board - action 668", "Placing black cubes on the board - action 669", "Placing black cubes on the board - action 670", "Placing black cubes on the board - action 671", "Placing black cubes on the board - action 672", "Placing black cubes on the board - action 673", "Placing black cubes on the board - action 674", "Placing black cubes on the board - action 675", "Placing black cubes on the board - action 676", "Placing black cubes on the board - action 677", "Placing black cubes on the board - action 678", "Placing black cubes on the board - action 679", "Placing black cubes on the board - action 680", "Placing black cubes on the board - action 681", "Placing black cubes on the board - action 682", "Placing black cubes on the board - action 683", "Placing black cubes on the board - action 684", "Placing black cubes on the board - action 685", "Placing black cubes on the board - action 686", "Placing black cubes on the board - action 687", "Placing black cubes on the board - action 688", "Placing black cubes on the board - action 689", "Placing black cubes on the board - action 690", "Placing black cubes on the board - action 691", "Placing black cubes on the board - action 692", "Placing black cubes on the board - action 693", "Placing black cubes on the board - action 694", "Placing black cubes on the board - action 695", "Placing black cubes on the board - action 696", "Placing black cubes on the board - action 697", "Placing black cubes on the board - action 698", "Placing black cubes on the board - action 699", "Placing black cubes on the board - action 700", "Placing black cubes on the board - action 701", "Placing black cubes on the board - action 702", "Placing black cubes on the board - action 703", "Placing black cubes on the board - action 704", "Placing black cubes on the board - action 705", "Placing black cubes on the board - action 706", "Placing black cubes on the board - action 707", "Placing black cubes on the board - action 708", "Placing black cubes on the board - action 709", "Placing black cubes on the board - action 710", "Placing black cubes on the board - action 711", "Placing black cubes on the board - action 712", "Placing black cubes on the board - action 713", "Placing black cubes on the board - action 714", "Placing black cubes on the board - action 715", "Placing black cubes on the board - action 716", "Placing black cubes on the board - action 717", "Placing black cubes on the board - action 718", "Placing black cubes on the board - action 719"] + +# Apply action "Placing black cubes on the board - action 120" +action: 120 + +# State 1 +# |b2||b1||b3||__||__| +# |b4||b5||__||__||__| +# |b6||__||__||__||__| +# |__||__||__||__||__| +# |__||__||__||__||__| +IsTerminal() = False +History() = [120] +HistoryString() = "120" +IsChanceNode() = True +IsSimultaneousNode() = False +CurrentPlayer() = -1 +ObservationString(0) = "|b2||b1||b3||__||__|\n|b4||b5||__||__||__|\n|b6||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n" +ObservationString(1) = "|b2||b1||b3||__||__|\n|b4||b5||__||__||__|\n|b6||__||__||__||__|\n|__||__||__||__||__|\n|__||__||__||__||__|\n" +ObservationTensor(0): binvec(300, 0x40000000000200000000000000200000000010000000000000200000000000800000000000) +ObservationTensor(1): binvec(300, 0x40000000000200000000000000200000000010000000000000200000000000800000000000) +ChanceOutcomes() = [(0,0.00138889), (1,0.00138889), (2,0.00138889), (3,0.00138889), (4,0.00138889), (5,0.00138889), (6,0.00138889), (7,0.00138889), (8,0.00138889), (9,0.00138889), (10,0.00138889), (11,0.00138889), (12,0.00138889), (13,0.00138889), (14,0.00138889), (15,0.00138889), (16,0.00138889), (17,0.00138889), (18,0.00138889), (19,0.00138889), (20,0.00138889), (21,0.00138889), (22,0.00138889), (23,0.00138889), (24,0.00138889), (25,0.00138889), (26,0.00138889), (27,0.00138889), (28,0.00138889), (29,0.00138889), (30,0.00138889), (31,0.00138889), (32,0.00138889), (33,0.00138889), (34,0.00138889), (35,0.00138889), (36,0.00138889), (37,0.00138889), (38,0.00138889), (39,0.00138889), (40,0.00138889), (41,0.00138889), (42,0.00138889), (43,0.00138889), (44,0.00138889), (45,0.00138889), (46,0.00138889), (47,0.00138889), (48,0.00138889), (49,0.00138889), (50,0.00138889), (51,0.00138889), (52,0.00138889), (53,0.00138889), (54,0.00138889), (55,0.00138889), (56,0.00138889), (57,0.00138889), (58,0.00138889), (59,0.00138889), (60,0.00138889), (61,0.00138889), (62,0.00138889), (63,0.00138889), (64,0.00138889), (65,0.00138889), (66,0.00138889), (67,0.00138889), (68,0.00138889), (69,0.00138889), (70,0.00138889), (71,0.00138889), (72,0.00138889), (73,0.00138889), (74,0.00138889), (75,0.00138889), (76,0.00138889), (77,0.00138889), (78,0.00138889), (79,0.00138889), (80,0.00138889), (81,0.00138889), (82,0.00138889), (83,0.00138889), (84,0.00138889), (85,0.00138889), (86,0.00138889), (87,0.00138889), (88,0.00138889), (89,0.00138889), (90,0.00138889), (91,0.00138889), (92,0.00138889), (93,0.00138889), (94,0.00138889), (95,0.00138889), (96,0.00138889), (97,0.00138889), (98,0.00138889), (99,0.00138889), (100,0.00138889), (101,0.00138889), (102,0.00138889), (103,0.00138889), (104,0.00138889), (105,0.00138889), (106,0.00138889), (107,0.00138889), (108,0.00138889), (109,0.00138889), (110,0.00138889), (111,0.00138889), (112,0.00138889), (113,0.00138889), (114,0.00138889), (115,0.00138889), (116,0.00138889), (117,0.00138889), (118,0.00138889), (119,0.00138889), (120,0.00138889), (121,0.00138889), (122,0.00138889), (123,0.00138889), (124,0.00138889), (125,0.00138889), (126,0.00138889), (127,0.00138889), (128,0.00138889), (129,0.00138889), (130,0.00138889), (131,0.00138889), (132,0.00138889), (133,0.00138889), (134,0.00138889), (135,0.00138889), (136,0.00138889), (137,0.00138889), (138,0.00138889), (139,0.00138889), (140,0.00138889), (141,0.00138889), (142,0.00138889), (143,0.00138889), (144,0.00138889), (145,0.00138889), (146,0.00138889), (147,0.00138889), (148,0.00138889), (149,0.00138889), (150,0.00138889), (151,0.00138889), (152,0.00138889), (153,0.00138889), (154,0.00138889), (155,0.00138889), (156,0.00138889), (157,0.00138889), (158,0.00138889), (159,0.00138889), (160,0.00138889), (161,0.00138889), (162,0.00138889), (163,0.00138889), (164,0.00138889), (165,0.00138889), (166,0.00138889), (167,0.00138889), (168,0.00138889), (169,0.00138889), (170,0.00138889), (171,0.00138889), (172,0.00138889), (173,0.00138889), (174,0.00138889), (175,0.00138889), (176,0.00138889), (177,0.00138889), (178,0.00138889), (179,0.00138889), (180,0.00138889), (181,0.00138889), (182,0.00138889), (183,0.00138889), (184,0.00138889), (185,0.00138889), (186,0.00138889), (187,0.00138889), (188,0.00138889), (189,0.00138889), (190,0.00138889), (191,0.00138889), (192,0.00138889), (193,0.00138889), (194,0.00138889), (195,0.00138889), (196,0.00138889), (197,0.00138889), (198,0.00138889), (199,0.00138889), (200,0.00138889), (201,0.00138889), (202,0.00138889), (203,0.00138889), (204,0.00138889), (205,0.00138889), (206,0.00138889), (207,0.00138889), (208,0.00138889), (209,0.00138889), (210,0.00138889), (211,0.00138889), (212,0.00138889), (213,0.00138889), (214,0.00138889), (215,0.00138889), (216,0.00138889), (217,0.00138889), (218,0.00138889), (219,0.00138889), (220,0.00138889), (221,0.00138889), (222,0.00138889), (223,0.00138889), (224,0.00138889), (225,0.00138889), (226,0.00138889), (227,0.00138889), (228,0.00138889), (229,0.00138889), (230,0.00138889), (231,0.00138889), (232,0.00138889), (233,0.00138889), (234,0.00138889), (235,0.00138889), (236,0.00138889), (237,0.00138889), (238,0.00138889), (239,0.00138889), (240,0.00138889), (241,0.00138889), (242,0.00138889), (243,0.00138889), (244,0.00138889), (245,0.00138889), (246,0.00138889), (247,0.00138889), (248,0.00138889), (249,0.00138889), (250,0.00138889), (251,0.00138889), (252,0.00138889), (253,0.00138889), (254,0.00138889), (255,0.00138889), (256,0.00138889), (257,0.00138889), (258,0.00138889), (259,0.00138889), (260,0.00138889), (261,0.00138889), (262,0.00138889), (263,0.00138889), (264,0.00138889), (265,0.00138889), (266,0.00138889), (267,0.00138889), (268,0.00138889), (269,0.00138889), (270,0.00138889), (271,0.00138889), (272,0.00138889), (273,0.00138889), (274,0.00138889), (275,0.00138889), (276,0.00138889), (277,0.00138889), (278,0.00138889), (279,0.00138889), (280,0.00138889), (281,0.00138889), (282,0.00138889), (283,0.00138889), (284,0.00138889), (285,0.00138889), (286,0.00138889), (287,0.00138889), (288,0.00138889), (289,0.00138889), (290,0.00138889), (291,0.00138889), (292,0.00138889), (293,0.00138889), (294,0.00138889), (295,0.00138889), (296,0.00138889), (297,0.00138889), (298,0.00138889), (299,0.00138889), (300,0.00138889), (301,0.00138889), (302,0.00138889), (303,0.00138889), (304,0.00138889), (305,0.00138889), (306,0.00138889), (307,0.00138889), (308,0.00138889), (309,0.00138889), (310,0.00138889), (311,0.00138889), (312,0.00138889), (313,0.00138889), (314,0.00138889), (315,0.00138889), (316,0.00138889), (317,0.00138889), (318,0.00138889), (319,0.00138889), (320,0.00138889), (321,0.00138889), (322,0.00138889), (323,0.00138889), (324,0.00138889), (325,0.00138889), (326,0.00138889), (327,0.00138889), (328,0.00138889), (329,0.00138889), (330,0.00138889), (331,0.00138889), (332,0.00138889), (333,0.00138889), (334,0.00138889), (335,0.00138889), (336,0.00138889), (337,0.00138889), (338,0.00138889), (339,0.00138889), (340,0.00138889), (341,0.00138889), (342,0.00138889), (343,0.00138889), (344,0.00138889), (345,0.00138889), (346,0.00138889), (347,0.00138889), (348,0.00138889), (349,0.00138889), (350,0.00138889), (351,0.00138889), (352,0.00138889), (353,0.00138889), (354,0.00138889), (355,0.00138889), (356,0.00138889), (357,0.00138889), (358,0.00138889), (359,0.00138889), (360,0.00138889), (361,0.00138889), (362,0.00138889), (363,0.00138889), (364,0.00138889), (365,0.00138889), (366,0.00138889), (367,0.00138889), (368,0.00138889), (369,0.00138889), (370,0.00138889), (371,0.00138889), (372,0.00138889), (373,0.00138889), (374,0.00138889), (375,0.00138889), (376,0.00138889), (377,0.00138889), (378,0.00138889), (379,0.00138889), (380,0.00138889), (381,0.00138889), (382,0.00138889), (383,0.00138889), (384,0.00138889), (385,0.00138889), (386,0.00138889), (387,0.00138889), (388,0.00138889), (389,0.00138889), (390,0.00138889), (391,0.00138889), (392,0.00138889), (393,0.00138889), (394,0.00138889), (395,0.00138889), (396,0.00138889), (397,0.00138889), (398,0.00138889), (399,0.00138889), (400,0.00138889), (401,0.00138889), (402,0.00138889), (403,0.00138889), (404,0.00138889), (405,0.00138889), (406,0.00138889), (407,0.00138889), (408,0.00138889), (409,0.00138889), (410,0.00138889), (411,0.00138889), (412,0.00138889), (413,0.00138889), (414,0.00138889), (415,0.00138889), (416,0.00138889), (417,0.00138889), (418,0.00138889), (419,0.00138889), (420,0.00138889), (421,0.00138889), (422,0.00138889), (423,0.00138889), (424,0.00138889), (425,0.00138889), (426,0.00138889), (427,0.00138889), (428,0.00138889), (429,0.00138889), (430,0.00138889), (431,0.00138889), (432,0.00138889), (433,0.00138889), (434,0.00138889), (435,0.00138889), (436,0.00138889), (437,0.00138889), (438,0.00138889), (439,0.00138889), (440,0.00138889), (441,0.00138889), (442,0.00138889), (443,0.00138889), (444,0.00138889), (445,0.00138889), (446,0.00138889), (447,0.00138889), (448,0.00138889), (449,0.00138889), (450,0.00138889), (451,0.00138889), (452,0.00138889), (453,0.00138889), (454,0.00138889), (455,0.00138889), (456,0.00138889), (457,0.00138889), (458,0.00138889), (459,0.00138889), (460,0.00138889), (461,0.00138889), (462,0.00138889), (463,0.00138889), (464,0.00138889), (465,0.00138889), (466,0.00138889), (467,0.00138889), (468,0.00138889), (469,0.00138889), (470,0.00138889), (471,0.00138889), (472,0.00138889), (473,0.00138889), (474,0.00138889), (475,0.00138889), (476,0.00138889), (477,0.00138889), (478,0.00138889), (479,0.00138889), (480,0.00138889), (481,0.00138889), (482,0.00138889), (483,0.00138889), (484,0.00138889), (485,0.00138889), (486,0.00138889), (487,0.00138889), (488,0.00138889), (489,0.00138889), (490,0.00138889), (491,0.00138889), (492,0.00138889), (493,0.00138889), (494,0.00138889), (495,0.00138889), (496,0.00138889), (497,0.00138889), (498,0.00138889), (499,0.00138889), (500,0.00138889), (501,0.00138889), (502,0.00138889), (503,0.00138889), (504,0.00138889), (505,0.00138889), (506,0.00138889), (507,0.00138889), (508,0.00138889), (509,0.00138889), (510,0.00138889), (511,0.00138889), (512,0.00138889), (513,0.00138889), (514,0.00138889), (515,0.00138889), (516,0.00138889), (517,0.00138889), (518,0.00138889), (519,0.00138889), (520,0.00138889), (521,0.00138889), (522,0.00138889), (523,0.00138889), (524,0.00138889), (525,0.00138889), (526,0.00138889), (527,0.00138889), (528,0.00138889), (529,0.00138889), (530,0.00138889), (531,0.00138889), (532,0.00138889), (533,0.00138889), (534,0.00138889), (535,0.00138889), (536,0.00138889), (537,0.00138889), (538,0.00138889), (539,0.00138889), (540,0.00138889), (541,0.00138889), (542,0.00138889), (543,0.00138889), (544,0.00138889), (545,0.00138889), (546,0.00138889), (547,0.00138889), (548,0.00138889), (549,0.00138889), (550,0.00138889), (551,0.00138889), (552,0.00138889), (553,0.00138889), (554,0.00138889), (555,0.00138889), (556,0.00138889), (557,0.00138889), (558,0.00138889), (559,0.00138889), (560,0.00138889), (561,0.00138889), (562,0.00138889), (563,0.00138889), (564,0.00138889), (565,0.00138889), (566,0.00138889), (567,0.00138889), (568,0.00138889), (569,0.00138889), (570,0.00138889), (571,0.00138889), (572,0.00138889), (573,0.00138889), (574,0.00138889), (575,0.00138889), (576,0.00138889), (577,0.00138889), (578,0.00138889), (579,0.00138889), (580,0.00138889), (581,0.00138889), (582,0.00138889), (583,0.00138889), (584,0.00138889), (585,0.00138889), (586,0.00138889), (587,0.00138889), (588,0.00138889), (589,0.00138889), (590,0.00138889), (591,0.00138889), (592,0.00138889), (593,0.00138889), (594,0.00138889), (595,0.00138889), (596,0.00138889), (597,0.00138889), (598,0.00138889), (599,0.00138889), (600,0.00138889), (601,0.00138889), (602,0.00138889), (603,0.00138889), (604,0.00138889), (605,0.00138889), (606,0.00138889), (607,0.00138889), (608,0.00138889), (609,0.00138889), (610,0.00138889), (611,0.00138889), (612,0.00138889), (613,0.00138889), (614,0.00138889), (615,0.00138889), (616,0.00138889), (617,0.00138889), (618,0.00138889), (619,0.00138889), (620,0.00138889), (621,0.00138889), (622,0.00138889), (623,0.00138889), (624,0.00138889), (625,0.00138889), (626,0.00138889), (627,0.00138889), (628,0.00138889), (629,0.00138889), (630,0.00138889), (631,0.00138889), (632,0.00138889), (633,0.00138889), (634,0.00138889), (635,0.00138889), (636,0.00138889), (637,0.00138889), (638,0.00138889), (639,0.00138889), (640,0.00138889), (641,0.00138889), (642,0.00138889), (643,0.00138889), (644,0.00138889), (645,0.00138889), (646,0.00138889), (647,0.00138889), (648,0.00138889), (649,0.00138889), (650,0.00138889), (651,0.00138889), (652,0.00138889), (653,0.00138889), (654,0.00138889), (655,0.00138889), (656,0.00138889), (657,0.00138889), (658,0.00138889), (659,0.00138889), (660,0.00138889), (661,0.00138889), (662,0.00138889), (663,0.00138889), (664,0.00138889), (665,0.00138889), (666,0.00138889), (667,0.00138889), (668,0.00138889), (669,0.00138889), (670,0.00138889), (671,0.00138889), (672,0.00138889), (673,0.00138889), (674,0.00138889), (675,0.00138889), (676,0.00138889), (677,0.00138889), (678,0.00138889), (679,0.00138889), (680,0.00138889), (681,0.00138889), (682,0.00138889), (683,0.00138889), (684,0.00138889), (685,0.00138889), (686,0.00138889), (687,0.00138889), (688,0.00138889), (689,0.00138889), (690,0.00138889), (691,0.00138889), (692,0.00138889), (693,0.00138889), (694,0.00138889), (695,0.00138889), (696,0.00138889), (697,0.00138889), (698,0.00138889), (699,0.00138889), (700,0.00138889), (701,0.00138889), (702,0.00138889), (703,0.00138889), (704,0.00138889), (705,0.00138889), (706,0.00138889), (707,0.00138889), (708,0.00138889), (709,0.00138889), (710,0.00138889), (711,0.00138889), (712,0.00138889), (713,0.00138889), (714,0.00138889), (715,0.00138889), (716,0.00138889), (717,0.00138889), (718,0.00138889), (719,0.00138889)] +LegalActions() = [0, 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, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719] +StringLegalActions() = ["Placing white cubes on the board - action 0", "Placing white cubes on the board - action 1", "Placing white cubes on the board - action 2", "Placing white cubes on the board - action 3", "Placing white cubes on the board - action 4", "Placing white cubes on the board - action 5", "Placing white cubes on the board - action 6", "Placing white cubes on the board - action 7", "Placing white cubes on the board - action 8", "Placing white cubes on the board - action 9", "Placing white cubes on the board - action 10", "Placing white cubes on the board - action 11", "Placing white cubes on the board - action 12", "Placing white cubes on the board - action 13", "Placing white cubes on the board - action 14", "Placing white cubes on the board - action 15", "Placing white cubes on the board - action 16", "Placing white cubes on the board - action 17", "Placing white cubes on the board - action 18", "Placing white cubes on the board - action 19", "Placing white cubes on the board - action 20", "Placing white cubes on the board - action 21", "Placing white cubes on the board - action 22", "Placing white cubes on the board - action 23", "Placing white cubes on the board - action 24", "Placing white cubes on the board - action 25", "Placing white cubes on the board - action 26", "Placing white cubes on the board - action 27", "Placing white cubes on the board - action 28", "Placing white cubes on the board - action 29", "Placing white cubes on the board - action 30", "Placing white cubes on the board - action 31", "Placing white cubes on the board - action 32", "Placing white cubes on the board - action 33", "Placing white cubes on the board - action 34", "Placing white cubes on the board - action 35", "Placing white cubes on the board - action 36", "Placing white cubes on the board - action 37", "Placing white cubes on the board - action 38", "Placing white cubes on the board - action 39", "Placing white cubes on the board - action 40", "Placing white cubes on the board - action 41", "Placing white cubes on the board - action 42", "Placing white cubes on the board - action 43", "Placing white cubes on the board - action 44", "Placing white cubes on the board - action 45", "Placing white cubes on the board - action 46", "Placing white cubes on the board - action 47", "Placing white cubes on the board - action 48", "Placing white cubes on the board - action 49", "Placing white cubes on the board - action 50", "Placing white cubes on the board - action 51", "Placing white cubes on the board - action 52", "Placing white cubes on the board - action 53", "Placing white cubes on the board - action 54", "Placing white cubes on the board - action 55", "Placing white cubes on the board - action 56", "Placing white cubes on the board - action 57", "Placing white cubes on the board - action 58", "Placing white cubes on the board - action 59", "Placing white cubes on the board - action 60", "Placing white cubes on the board - action 61", "Placing white cubes on the board - action 62", "Placing white cubes on the board - action 63", "Placing white cubes on the board - action 64", "Placing white cubes on the board - action 65", "Placing white cubes on the board - action 66", "Placing white cubes on the board - action 67", "Placing white cubes on the board - action 68", "Placing white cubes on the board - action 69", "Placing white cubes on the board - action 70", "Placing white cubes on the board - action 71", "Placing white cubes on the board - action 72", "Placing white cubes on the board - action 73", "Placing white cubes on the board - action 74", "Placing white cubes on the board - action 75", "Placing white cubes on the board - action 76", "Placing white cubes on the board - action 77", "Placing white cubes on the board - action 78", "Placing white cubes on the board - action 79", "Placing white cubes on the board - action 80", "Placing white cubes on the board - action 81", "Placing white cubes on the board - action 82", "Placing white cubes on the board - action 83", "Placing white cubes on the board - action 84", "Placing white cubes on the board - action 85", "Placing white cubes on the board - action 86", "Placing white cubes on the board - action 87", "Placing white cubes on the board - action 88", "Placing white cubes on the board - action 89", "Placing white cubes on the board - action 90", "Placing white cubes on the board - action 91", "Placing white cubes on the board - action 92", "Placing white cubes on the board - action 93", "Placing white cubes on the board - action 94", "Placing white cubes on the board - action 95", "Placing white cubes on the board - action 96", "Placing white cubes on the board - action 97", "Placing white cubes on the board - action 98", "Placing white cubes on the board - action 99", "Placing white cubes on the board - action 100", "Placing white cubes on the board - action 101", "Placing white cubes on the board - action 102", "Placing white cubes on the board - action 103", "Placing white cubes on the board - action 104", "Placing white cubes on the board - action 105", "Placing white cubes on the board - action 106", "Placing white cubes on the board - action 107", "Placing white cubes on the board - action 108", "Placing white cubes on the board - action 109", "Placing white cubes on the board - action 110", "Placing white cubes on the board - action 111", "Placing white cubes on the board - action 112", "Placing white cubes on the board - action 113", "Placing white cubes on the board - action 114", "Placing white cubes on the board - action 115", "Placing white cubes on the board - action 116", "Placing white cubes on the board - action 117", "Placing white cubes on the board - action 118", "Placing white cubes on the board - action 119", "Placing white cubes on the board - action 120", "Placing white cubes on the board - action 121", "Placing white cubes on the board - action 122", "Placing white cubes on the board - action 123", "Placing white cubes on the board - action 124", "Placing white cubes on the board - action 125", "Placing white cubes on the board - action 126", "Placing white cubes on the board - action 127", "Placing white cubes on the board - action 128", "Placing white cubes on the board - action 129", "Placing white cubes on the board - action 130", "Placing white cubes on the board - action 131", "Placing white cubes on the board - action 132", "Placing white cubes on the board - action 133", "Placing white cubes on the board - action 134", "Placing white cubes on the board - action 135", "Placing white cubes on the board - action 136", "Placing white cubes on the board - action 137", "Placing white cubes on the board - action 138", "Placing white cubes on the board - action 139", "Placing white cubes on the board - action 140", "Placing white cubes on the board - action 141", "Placing white cubes on the board - action 142", "Placing white cubes on the board - action 143", "Placing white cubes on the board - action 144", "Placing white cubes on the board - action 145", "Placing white cubes on the board - action 146", "Placing white cubes on the board - action 147", "Placing white cubes on the board - action 148", "Placing white cubes on the board - action 149", "Placing white cubes on the board - action 150", "Placing white cubes on the board - action 151", "Placing white cubes on the board - action 152", "Placing white cubes on the board - action 153", "Placing white cubes on the board - action 154", "Placing white cubes on the board - action 155", "Placing white cubes on the board - action 156", "Placing white cubes on the board - action 157", "Placing white cubes on the board - action 158", "Placing white cubes on the board - action 159", "Placing white cubes on the board - action 160", "Placing white cubes on the board - action 161", "Placing white cubes on the board - action 162", "Placing white cubes on the board - action 163", "Placing white cubes on the board - action 164", "Placing white cubes on the board - action 165", "Placing white cubes on the board - action 166", "Placing white cubes on the board - action 167", "Placing white cubes on the board - action 168", "Placing white cubes on the board - action 169", "Placing white cubes on the board - action 170", "Placing white cubes on the board - action 171", "Placing white cubes on the board - action 172", "Placing white cubes on the board - action 173", "Placing white cubes on the board - action 174", "Placing white cubes on the board - action 175", "Placing white cubes on the board - action 176", "Placing white cubes on the board - action 177", "Placing white cubes on the board - action 178", "Placing white cubes on the board - action 179", "Placing white cubes on the board - action 180", "Placing white cubes on the board - action 181", "Placing white cubes on the board - action 182", "Placing white cubes on the board - action 183", "Placing white cubes on the board - action 184", "Placing white cubes on the board - action 185", "Placing white cubes on the board - action 186", "Placing white cubes on the board - action 187", "Placing white cubes on the board - action 188", "Placing white cubes on the board - action 189", "Placing white cubes on the board - action 190", "Placing white cubes on the board - action 191", "Placing white cubes on the board - action 192", "Placing white cubes on the board - action 193", "Placing white cubes on the board - action 194", "Placing white cubes on the board - action 195", "Placing white cubes on the board - action 196", "Placing white cubes on the board - action 197", "Placing white cubes on the board - action 198", "Placing white cubes on the board - action 199", "Placing white cubes on the board - action 200", "Placing white cubes on the board - action 201", "Placing white cubes on the board - action 202", "Placing white cubes on the board - action 203", "Placing white cubes on the board - action 204", "Placing white cubes on the board - action 205", "Placing white cubes on the board - action 206", "Placing white cubes on the board - action 207", "Placing white cubes on the board - action 208", "Placing white cubes on the board - action 209", "Placing white cubes on the board - action 210", "Placing white cubes on the board - action 211", "Placing white cubes on the board - action 212", "Placing white cubes on the board - action 213", "Placing white cubes on the board - action 214", "Placing white cubes on the board - action 215", "Placing white cubes on the board - action 216", "Placing white cubes on the board - action 217", "Placing white cubes on the board - action 218", "Placing white cubes on the board - action 219", "Placing white cubes on the board - action 220", "Placing white cubes on the board - action 221", "Placing white cubes on the board - action 222", "Placing white cubes on the board - action 223", "Placing white cubes on the board - action 224", "Placing white cubes on the board - action 225", "Placing white cubes on the board - action 226", "Placing white cubes on the board - action 227", "Placing white cubes on the board - action 228", "Placing white cubes on the board - action 229", "Placing white cubes on the board - action 230", "Placing white cubes on the board - action 231", "Placing white cubes on the board - action 232", "Placing white cubes on the board - action 233", "Placing white cubes on the board - action 234", "Placing white cubes on the board - action 235", "Placing white cubes on the board - action 236", "Placing white cubes on the board - action 237", "Placing white cubes on the board - action 238", "Placing white cubes on the board - action 239", "Placing white cubes on the board - action 240", "Placing white cubes on the board - action 241", "Placing white cubes on the board - action 242", "Placing white cubes on the board - action 243", "Placing white cubes on the board - action 244", "Placing white cubes on the board - action 245", "Placing white cubes on the board - action 246", "Placing white cubes on the board - action 247", "Placing white cubes on the board - action 248", "Placing white cubes on the board - action 249", "Placing white cubes on the board - action 250", "Placing white cubes on the board - action 251", "Placing white cubes on the board - action 252", "Placing white cubes on the board - action 253", "Placing white cubes on the board - action 254", "Placing white cubes on the board - action 255", "Placing white cubes on the board - action 256", "Placing white cubes on the board - action 257", "Placing white cubes on the board - action 258", "Placing white cubes on the board - action 259", "Placing white cubes on the board - action 260", "Placing white cubes on the board - action 261", "Placing white cubes on the board - action 262", "Placing white cubes on the board - action 263", "Placing white cubes on the board - action 264", "Placing white cubes on the board - action 265", "Placing white cubes on the board - action 266", "Placing white cubes on the board - action 267", "Placing white cubes on the board - action 268", "Placing white cubes on the board - action 269", "Placing white cubes on the board - action 270", "Placing white cubes on the board - action 271", "Placing white cubes on the board - action 272", "Placing white cubes on the board - action 273", "Placing white cubes on the board - action 274", "Placing white cubes on the board - action 275", "Placing white cubes on the board - action 276", "Placing white cubes on the board - action 277", "Placing white cubes on the board - action 278", "Placing white cubes on the board - action 279", "Placing white cubes on the board - action 280", "Placing white cubes on the board - action 281", "Placing white cubes on the board - action 282", "Placing white cubes on the board - action 283", "Placing white cubes on the board - action 284", "Placing white cubes on the board - action 285", "Placing white cubes on the board - action 286", "Placing white cubes on the board - action 287", "Placing white cubes on the board - action 288", "Placing white cubes on the board - action 289", "Placing white cubes on the board - action 290", "Placing white cubes on the board - action 291", "Placing white cubes on the board - action 292", "Placing white cubes on the board - action 293", "Placing white cubes on the board - action 294", "Placing white cubes on the board - action 295", "Placing white cubes on the board - action 296", "Placing white cubes on the board - action 297", "Placing white cubes on the board - action 298", "Placing white cubes on the board - action 299", "Placing white cubes on the board - action 300", "Placing white cubes on the board - action 301", "Placing white cubes on the board - action 302", "Placing white cubes on the board - action 303", "Placing white cubes on the board - action 304", "Placing white cubes on the board - action 305", "Placing white cubes on the board - action 306", "Placing white cubes on the board - action 307", "Placing white cubes on the board - action 308", "Placing white cubes on the board - action 309", "Placing white cubes on the board - action 310", "Placing white cubes on the board - action 311", "Placing white cubes on the board - action 312", "Placing white cubes on the board - action 313", "Placing white cubes on the board - action 314", "Placing white cubes on the board - action 315", "Placing white cubes on the board - action 316", "Placing white cubes on the board - action 317", "Placing white cubes on the board - action 318", "Placing white cubes on the board - action 319", "Placing white cubes on the board - action 320", "Placing white cubes on the board - action 321", "Placing white cubes on the board - action 322", "Placing white cubes on the board - action 323", "Placing white cubes on the board - action 324", "Placing white cubes on the board - action 325", "Placing white cubes on the board - action 326", "Placing white cubes on the board - action 327", "Placing white cubes on the board - action 328", "Placing white cubes on the board - action 329", "Placing white cubes on the board - action 330", "Placing white cubes on the board - action 331", "Placing white cubes on the board - action 332", "Placing white cubes on the board - action 333", "Placing white cubes on the board - action 334", "Placing white cubes on the board - action 335", "Placing white cubes on the board - action 336", "Placing white cubes on the board - action 337", "Placing white cubes on the board - action 338", "Placing white cubes on the board - action 339", "Placing white cubes on the board - action 340", "Placing white cubes on the board - action 341", "Placing white cubes on the board - action 342", "Placing white cubes on the board - action 343", "Placing white cubes on the board - action 344", "Placing white cubes on the board - action 345", "Placing white cubes on the board - action 346", "Placing white cubes on the board - action 347", "Placing white cubes on the board - action 348", "Placing white cubes on the board - action 349", "Placing white cubes on the board - action 350", "Placing white cubes on the board - action 351", "Placing white cubes on the board - action 352", "Placing white cubes on the board - action 353", "Placing white cubes on the board - action 354", "Placing white cubes on the board - action 355", "Placing white cubes on the board - action 356", "Placing white cubes on the board - action 357", "Placing white cubes on the board - action 358", "Placing white cubes on the board - action 359", "Placing white cubes on the board - action 360", "Placing white cubes on the board - action 361", "Placing white cubes on the board - action 362", "Placing white cubes on the board - action 363", "Placing white cubes on the board - action 364", "Placing white cubes on the board - action 365", "Placing white cubes on the board - action 366", "Placing white cubes on the board - action 367", "Placing white cubes on the board - action 368", "Placing white cubes on the board - action 369", "Placing white cubes on the board - action 370", "Placing white cubes on the board - action 371", "Placing white cubes on the board - action 372", "Placing white cubes on the board - action 373", "Placing white cubes on the board - action 374", "Placing white cubes on the board - action 375", "Placing white cubes on the board - action 376", "Placing white cubes on the board - action 377", "Placing white cubes on the board - action 378", "Placing white cubes on the board - action 379", "Placing white cubes on the board - action 380", "Placing white cubes on the board - action 381", "Placing white cubes on the board - action 382", "Placing white cubes on the board - action 383", "Placing white cubes on the board - action 384", "Placing white cubes on the board - action 385", "Placing white cubes on the board - action 386", "Placing white cubes on the board - action 387", "Placing white cubes on the board - action 388", "Placing white cubes on the board - action 389", "Placing white cubes on the board - action 390", "Placing white cubes on the board - action 391", "Placing white cubes on the board - action 392", "Placing white cubes on the board - action 393", "Placing white cubes on the board - action 394", "Placing white cubes on the board - action 395", "Placing white cubes on the board - action 396", "Placing white cubes on the board - action 397", "Placing white cubes on the board - action 398", "Placing white cubes on the board - action 399", "Placing white cubes on the board - action 400", "Placing white cubes on the board - action 401", "Placing white cubes on the board - action 402", "Placing white cubes on the board - action 403", "Placing white cubes on the board - action 404", "Placing white cubes on the board - action 405", "Placing white cubes on the board - action 406", "Placing white cubes on the board - action 407", "Placing white cubes on the board - action 408", "Placing white cubes on the board - action 409", "Placing white cubes on the board - action 410", "Placing white cubes on the board - action 411", "Placing white cubes on the board - action 412", "Placing white cubes on the board - action 413", "Placing white cubes on the board - action 414", "Placing white cubes on the board - action 415", "Placing white cubes on the board - action 416", "Placing white cubes on the board - action 417", "Placing white cubes on the board - action 418", "Placing white cubes on the board - action 419", "Placing white cubes on the board - action 420", "Placing white cubes on the board - action 421", "Placing white cubes on the board - action 422", "Placing white cubes on the board - action 423", "Placing white cubes on the board - action 424", "Placing white cubes on the board - action 425", "Placing white cubes on the board - action 426", "Placing white cubes on the board - action 427", "Placing white cubes on the board - action 428", "Placing white cubes on the board - action 429", "Placing white cubes on the board - action 430", "Placing white cubes on the board - action 431", "Placing white cubes on the board - action 432", "Placing white cubes on the board - action 433", "Placing white cubes on the board - action 434", "Placing white cubes on the board - action 435", "Placing white cubes on the board - action 436", "Placing white cubes on the board - action 437", "Placing white cubes on the board - action 438", "Placing white cubes on the board - action 439", "Placing white cubes on the board - action 440", "Placing white cubes on the board - action 441", "Placing white cubes on the board - action 442", "Placing white cubes on the board - action 443", "Placing white cubes on the board - action 444", "Placing white cubes on the board - action 445", "Placing white cubes on the board - action 446", "Placing white cubes on the board - action 447", "Placing white cubes on the board - action 448", "Placing white cubes on the board - action 449", "Placing white cubes on the board - action 450", "Placing white cubes on the board - action 451", "Placing white cubes on the board - action 452", "Placing white cubes on the board - action 453", "Placing white cubes on the board - action 454", "Placing white cubes on the board - action 455", "Placing white cubes on the board - action 456", "Placing white cubes on the board - action 457", "Placing white cubes on the board - action 458", "Placing white cubes on the board - action 459", "Placing white cubes on the board - action 460", "Placing white cubes on the board - action 461", "Placing white cubes on the board - action 462", "Placing white cubes on the board - action 463", "Placing white cubes on the board - action 464", "Placing white cubes on the board - action 465", "Placing white cubes on the board - action 466", "Placing white cubes on the board - action 467", "Placing white cubes on the board - action 468", "Placing white cubes on the board - action 469", "Placing white cubes on the board - action 470", "Placing white cubes on the board - action 471", "Placing white cubes on the board - action 472", "Placing white cubes on the board - action 473", "Placing white cubes on the board - action 474", "Placing white cubes on the board - action 475", "Placing white cubes on the board - action 476", "Placing white cubes on the board - action 477", "Placing white cubes on the board - action 478", "Placing white cubes on the board - action 479", "Placing white cubes on the board - action 480", "Placing white cubes on the board - action 481", "Placing white cubes on the board - action 482", "Placing white cubes on the board - action 483", "Placing white cubes on the board - action 484", "Placing white cubes on the board - action 485", "Placing white cubes on the board - action 486", "Placing white cubes on the board - action 487", "Placing white cubes on the board - action 488", "Placing white cubes on the board - action 489", "Placing white cubes on the board - action 490", "Placing white cubes on the board - action 491", "Placing white cubes on the board - action 492", "Placing white cubes on the board - action 493", "Placing white cubes on the board - action 494", "Placing white cubes on the board - action 495", "Placing white cubes on the board - action 496", "Placing white cubes on the board - action 497", "Placing white cubes on the board - action 498", "Placing white cubes on the board - action 499", "Placing white cubes on the board - action 500", "Placing white cubes on the board - action 501", "Placing white cubes on the board - action 502", "Placing white cubes on the board - action 503", "Placing white cubes on the board - action 504", "Placing white cubes on the board - action 505", "Placing white cubes on the board - action 506", "Placing white cubes on the board - action 507", "Placing white cubes on the board - action 508", "Placing white cubes on the board - action 509", "Placing white cubes on the board - action 510", "Placing white cubes on the board - action 511", "Placing white cubes on the board - action 512", "Placing white cubes on the board - action 513", "Placing white cubes on the board - action 514", "Placing white cubes on the board - action 515", "Placing white cubes on the board - action 516", "Placing white cubes on the board - action 517", "Placing white cubes on the board - action 518", "Placing white cubes on the board - action 519", "Placing white cubes on the board - action 520", "Placing white cubes on the board - action 521", "Placing white cubes on the board - action 522", "Placing white cubes on the board - action 523", "Placing white cubes on the board - action 524", "Placing white cubes on the board - action 525", "Placing white cubes on the board - action 526", "Placing white cubes on the board - action 527", "Placing white cubes on the board - action 528", "Placing white cubes on the board - action 529", "Placing white cubes on the board - action 530", "Placing white cubes on the board - action 531", "Placing white cubes on the board - action 532", "Placing white cubes on the board - action 533", "Placing white cubes on the board - action 534", "Placing white cubes on the board - action 535", "Placing white cubes on the board - action 536", "Placing white cubes on the board - action 537", "Placing white cubes on the board - action 538", "Placing white cubes on the board - action 539", "Placing white cubes on the board - action 540", "Placing white cubes on the board - action 541", "Placing white cubes on the board - action 542", "Placing white cubes on the board - action 543", "Placing white cubes on the board - action 544", "Placing white cubes on the board - action 545", "Placing white cubes on the board - action 546", "Placing white cubes on the board - action 547", "Placing white cubes on the board - action 548", "Placing white cubes on the board - action 549", "Placing white cubes on the board - action 550", "Placing white cubes on the board - action 551", "Placing white cubes on the board - action 552", "Placing white cubes on the board - action 553", "Placing white cubes on the board - action 554", "Placing white cubes on the board - action 555", "Placing white cubes on the board - action 556", "Placing white cubes on the board - action 557", "Placing white cubes on the board - action 558", "Placing white cubes on the board - action 559", "Placing white cubes on the board - action 560", "Placing white cubes on the board - action 561", "Placing white cubes on the board - action 562", "Placing white cubes on the board - action 563", "Placing white cubes on the board - action 564", "Placing white cubes on the board - action 565", "Placing white cubes on the board - action 566", "Placing white cubes on the board - action 567", "Placing white cubes on the board - action 568", "Placing white cubes on the board - action 569", "Placing white cubes on the board - action 570", "Placing white cubes on the board - action 571", "Placing white cubes on the board - action 572", "Placing white cubes on the board - action 573", "Placing white cubes on the board - action 574", "Placing white cubes on the board - action 575", "Placing white cubes on the board - action 576", "Placing white cubes on the board - action 577", "Placing white cubes on the board - action 578", "Placing white cubes on the board - action 579", "Placing white cubes on the board - action 580", "Placing white cubes on the board - action 581", "Placing white cubes on the board - action 582", "Placing white cubes on the board - action 583", "Placing white cubes on the board - action 584", "Placing white cubes on the board - action 585", "Placing white cubes on the board - action 586", "Placing white cubes on the board - action 587", "Placing white cubes on the board - action 588", "Placing white cubes on the board - action 589", "Placing white cubes on the board - action 590", "Placing white cubes on the board - action 591", "Placing white cubes on the board - action 592", "Placing white cubes on the board - action 593", "Placing white cubes on the board - action 594", "Placing white cubes on the board - action 595", "Placing white cubes on the board - action 596", "Placing white cubes on the board - action 597", "Placing white cubes on the board - action 598", "Placing white cubes on the board - action 599", "Placing white cubes on the board - action 600", "Placing white cubes on the board - action 601", "Placing white cubes on the board - action 602", "Placing white cubes on the board - action 603", "Placing white cubes on the board - action 604", "Placing white cubes on the board - action 605", "Placing white cubes on the board - action 606", "Placing white cubes on the board - action 607", "Placing white cubes on the board - action 608", "Placing white cubes on the board - action 609", "Placing white cubes on the board - action 610", "Placing white cubes on the board - action 611", "Placing white cubes on the board - action 612", "Placing white cubes on the board - action 613", "Placing white cubes on the board - action 614", "Placing white cubes on the board - action 615", "Placing white cubes on the board - action 616", "Placing white cubes on the board - action 617", "Placing white cubes on the board - action 618", "Placing white cubes on the board - action 619", "Placing white cubes on the board - action 620", "Placing white cubes on the board - action 621", "Placing white cubes on the board - action 622", "Placing white cubes on the board - action 623", "Placing white cubes on the board - action 624", "Placing white cubes on the board - action 625", "Placing white cubes on the board - action 626", "Placing white cubes on the board - action 627", "Placing white cubes on the board - action 628", "Placing white cubes on the board - action 629", "Placing white cubes on the board - action 630", "Placing white cubes on the board - action 631", "Placing white cubes on the board - action 632", "Placing white cubes on the board - action 633", "Placing white cubes on the board - action 634", "Placing white cubes on the board - action 635", "Placing white cubes on the board - action 636", "Placing white cubes on the board - action 637", "Placing white cubes on the board - action 638", "Placing white cubes on the board - action 639", "Placing white cubes on the board - action 640", "Placing white cubes on the board - action 641", "Placing white cubes on the board - action 642", "Placing white cubes on the board - action 643", "Placing white cubes on the board - action 644", "Placing white cubes on the board - action 645", "Placing white cubes on the board - action 646", "Placing white cubes on the board - action 647", "Placing white cubes on the board - action 648", "Placing white cubes on the board - action 649", "Placing white cubes on the board - action 650", "Placing white cubes on the board - action 651", "Placing white cubes on the board - action 652", "Placing white cubes on the board - action 653", "Placing white cubes on the board - action 654", "Placing white cubes on the board - action 655", "Placing white cubes on the board - action 656", "Placing white cubes on the board - action 657", "Placing white cubes on the board - action 658", "Placing white cubes on the board - action 659", "Placing white cubes on the board - action 660", "Placing white cubes on the board - action 661", "Placing white cubes on the board - action 662", "Placing white cubes on the board - action 663", "Placing white cubes on the board - action 664", "Placing white cubes on the board - action 665", "Placing white cubes on the board - action 666", "Placing white cubes on the board - action 667", "Placing white cubes on the board - action 668", "Placing white cubes on the board - action 669", "Placing white cubes on the board - action 670", "Placing white cubes on the board - action 671", "Placing white cubes on the board - action 672", "Placing white cubes on the board - action 673", "Placing white cubes on the board - action 674", "Placing white cubes on the board - action 675", "Placing white cubes on the board - action 676", "Placing white cubes on the board - action 677", "Placing white cubes on the board - action 678", "Placing white cubes on the board - action 679", "Placing white cubes on the board - action 680", "Placing white cubes on the board - action 681", "Placing white cubes on the board - action 682", "Placing white cubes on the board - action 683", "Placing white cubes on the board - action 684", "Placing white cubes on the board - action 685", "Placing white cubes on the board - action 686", "Placing white cubes on the board - action 687", "Placing white cubes on the board - action 688", "Placing white cubes on the board - action 689", "Placing white cubes on the board - action 690", "Placing white cubes on the board - action 691", "Placing white cubes on the board - action 692", "Placing white cubes on the board - action 693", "Placing white cubes on the board - action 694", "Placing white cubes on the board - action 695", "Placing white cubes on the board - action 696", "Placing white cubes on the board - action 697", "Placing white cubes on the board - action 698", "Placing white cubes on the board - action 699", "Placing white cubes on the board - action 700", "Placing white cubes on the board - action 701", "Placing white cubes on the board - action 702", "Placing white cubes on the board - action 703", "Placing white cubes on the board - action 704", "Placing white cubes on the board - action 705", "Placing white cubes on the board - action 706", "Placing white cubes on the board - action 707", "Placing white cubes on the board - action 708", "Placing white cubes on the board - action 709", "Placing white cubes on the board - action 710", "Placing white cubes on the board - action 711", "Placing white cubes on the board - action 712", "Placing white cubes on the board - action 713", "Placing white cubes on the board - action 714", "Placing white cubes on the board - action 715", "Placing white cubes on the board - action 716", "Placing white cubes on the board - action 717", "Placing white cubes on the board - action 718", "Placing white cubes on the board - action 719"] + +# Apply action "Placing white cubes on the board - action 638" +action: 638 + +# State 2 +# Apply action "roll 5" +action: 4 + +# State 3 +# |b2||b1||b3||__||__| +# |b4||b5||__||__||__| +# |b6||__||__||__||w6| +# |__||__||__||w2||w4| +# |__||__||w3||w1||w5| +IsTerminal() = False +History() = [120, 638, 4] +HistoryString() = "120, 638, 4" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|b2||b1||b3||__||__|\n|b4||b5||__||__||__|\n|b6||__||__||__||w6|\n|__||__||__||w2||w4|\n|__||__||w3||w1||w5|\n" +ObservationString(1) = "|b2||b1||b3||__||__|\n|b4||b5||__||__||__|\n|b6||__||__||__||w6|\n|__||__||__||w2||w4|\n|__||__||w3||w1||w5|\n" +ObservationTensor(0): binvec(300, 0x40000000008200000000004000200000010010000000000020200000000004800000000004) +ObservationTensor(1): binvec(300, 0x40000000008200000000004000200000010010000000000020200000000004800000000004) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [295, 297, 299] +StringLegalActions() = ["W5-up*", "W5-diag*", "W5-left*"] + +# Apply action "W5-diag*" +action: 297 + +# State 4 +# Apply action "roll 3" +action: 2 + +# State 5 +# |b2||b1||b3||__||__| +# |b4||b5||__||__||__| +# |b6||__||__||__||w6| +# |__||__||__||w5||w4| +# |__||__||w3||w1||__| +IsTerminal() = False +History() = [120, 638, 4, 297, 2] +HistoryString() = "120, 638, 4, 297, 2" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|b2||b1||b3||__||__|\n|b4||b5||__||__||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||__||w3||w1||__|\n" +ObservationString(1) = "|b2||b1||b3||__||__|\n|b4||b5||__||__||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||__||w3||w1||__|\n" +ObservationTensor(0): binvec(300, 0x40000000008200000000000000200000010010000000000020200000000100800000000004) +ObservationTensor(1): binvec(300, 0x40000000008200000000000000200000010010000000000020200000000100800000000004) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [24, 26, 28] +StringLegalActions() = ["B3-diag", "B3-down", "B3-right"] + +# Apply action "B3-diag" +action: 24 + +# State 6 +# Apply action "roll 3" +action: 2 + +# State 7 +# |b2||b1||__||__||__| +# |b4||b5||__||b3||__| +# |b6||__||__||__||w6| +# |__||__||__||w5||w4| +# |__||__||w3||w1||__| +IsTerminal() = False +History() = [120, 638, 4, 297, 2, 24, 2] +HistoryString() = "120, 638, 4, 297, 2, 24, 2" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|b2||b1||__||__||__|\n|b4||b5||__||b3||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||__||w3||w1||__|\n" +ObservationString(1) = "|b2||b1||__||__||__|\n|b4||b5||__||b3||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||__||w3||w1||__|\n" +ObservationTensor(0): binvec(300, 0x40000000008200000000000000008000010010000000000020200000000100800000000004) +ObservationTensor(1): binvec(300, 0x40000000008200000000000000008000010010000000000020200000000100800000000004) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [270, 272, 274] +StringLegalActions() = ["W3-up", "W3-diag", "W3-left"] + +# Apply action "W3-left" +action: 274 + +# State 8 +# Apply action "roll 1" +action: 0 + +# State 9 +# |b2||b1||__||__||__| +# |b4||b5||__||b3||__| +# |b6||__||__||__||w6| +# |__||__||__||w5||w4| +# |__||w3||__||w1||__| +IsTerminal() = False +History() = [120, 638, 4, 297, 2, 24, 2, 274, 0] +HistoryString() = "120, 638, 4, 297, 2, 24, 2, 274, 0" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|b2||b1||__||__||__|\n|b4||b5||__||b3||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||w3||__||w1||__|\n" +ObservationString(1) = "|b2||b1||__||__||__|\n|b4||b5||__||b3||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||w3||__||w1||__|\n" +ObservationTensor(0): binvec(300, 0x40000000008200000000000000008000200010000000000020200000000100800000000004) +ObservationTensor(1): binvec(300, 0x40000000008200000000000000008000200010000000000020200000000100800000000004) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [12, 15, 16] +StringLegalActions() = ["B1-diag", "B1-down*", "B1-right"] + +# Apply action "B1-down*" +action: 15 + +# State 10 +# Apply action "roll 4" +action: 3 + +# State 11 +# |b2||__||__||__||__| +# |b4||b1||__||b3||__| +# |b6||__||__||__||w6| +# |__||__||__||w5||w4| +# |__||w3||__||w1||__| +IsTerminal() = False +History() = [120, 638, 4, 297, 2, 24, 2, 274, 0, 15, 3] +HistoryString() = "120, 638, 4, 297, 2, 24, 2, 274, 0, 15, 3" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 1 +ObservationString(0) = "|b2||__||__||__||__|\n|b4||b1||__||b3||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||w3||__||w1||__|\n" +ObservationString(1) = "|b2||__||__||__||__|\n|b4||b1||__||b3||__|\n|b6||__||__||__||w6|\n|__||__||__||w5||w4|\n|__||w3||__||w1||__|\n" +ObservationTensor(0): binvec(300, 0x20000000008200000000000000008000200010000000000020000000000100800000000004) +ObservationTensor(1): binvec(300, 0x20000000008200000000000000008000200010000000000020000000000100800000000004) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [235, 236, 239] +StringLegalActions() = ["W4-up*", "W4-diag", "W4-left*"] + +# Apply action "W4-up*" +action: 235 + +# State 12 +# Apply action "roll 2" +action: 1 + +# State 13 +# |b2||__||__||__||__| +# |b4||b1||__||b3||__| +# |b6||__||__||__||w4| +# |__||__||__||w5||__| +# |__||w3||__||w1||__| +IsTerminal() = False +History() = [120, 638, 4, 297, 2, 24, 2, 274, 0, 15, 3, 235, 1] +HistoryString() = "120, 638, 4, 297, 2, 24, 2, 274, 0, 15, 3, 235, 1" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = 0 +ObservationString(0) = "|b2||__||__||__||__|\n|b4||b1||__||b3||__|\n|b6||__||__||__||w4|\n|__||__||__||w5||__|\n|__||w3||__||w1||__|\n" +ObservationString(1) = "|b2||__||__||__||__|\n|b4||b1||__||b3||__|\n|b6||__||__||__||w4|\n|__||__||__||w5||__|\n|__||w3||__||w1||__|\n" +ObservationTensor(0): binvec(300, 0x20000000008200000000000000008000200010000000000040000000000100800000000000) +ObservationTensor(1): binvec(300, 0x20000000008200000000000000008000200010000000000040000000000100800000000000) +Rewards() = [0, 0] +Returns() = [0, 0] +LegalActions() = [1, 3, 4] +StringLegalActions() = ["B2-diag*", "B2-down*", "B2-right"] + +# Apply action "B2-down*" +action: 3 + +# State 14 +# Apply action "roll 5" +action: 4 + +# State 15 +# Apply action "W5-up" +action: 222 + +# State 16 +# Apply action "roll 3" +action: 2 + +# State 17 +# Apply action "B3-down*" +action: 99 + +# State 18 +# Apply action "roll 3" +action: 2 + +# State 19 +# Apply action "W3-left" +action: 262 + +# State 20 +# Apply action "roll 6" +action: 5 + +# State 21 +# Apply action "B6-diag" +action: 120 + +# State 22 +# Apply action "roll 1" +action: 0 + +# State 23 +# Apply action "W1-diag" +action: 284 + +# State 24 +# Apply action "roll 4" +action: 3 + +# State 25 +# Apply action "B6-diag" +action: 192 + +# State 26 +# Apply action "roll 5" +action: 4 + +# State 27 +# Apply action "W4-up" +action: 174 + +# State 28 +# Apply action "roll 6" +action: 5 + +# State 29 +# Apply action "B6-right" +action: 268 + +# State 30 +# Apply action "roll 6" +action: 5 + +# State 31 +# Apply action "W4-up" +action: 114 + +# State 32 +# Apply action "roll 1" +action: 0 + +# State 33 +# Apply action "B1-right" +action: 76 + +# State 34 +# Apply action "roll 6" +action: 5 + +# State 35 +# Apply action "W4-left" +action: 58 + +# State 36 +# Apply action "roll 5" +action: 4 + +# State 37 +# Apply action "B3-right" +action: 160 + +# State 38 +# Apply action "roll 3" +action: 2 + +# State 39 +# Apply action "W3-up" +action: 246 + +# State 40 +# Apply action "roll 5" +action: 4 + +# State 41 +# Apply action "B6-right" +action: 280 + +# State 42 +# |__||__||__||w4||__| +# |b2||__||b1||__||__| +# |__||__||__||__||b3| +# |w3||__||w1||__||__| +# |__||__||__||__||b6| +IsTerminal() = True +History() = [120, 638, 4, 297, 2, 24, 2, 274, 0, 15, 3, 235, 1, 3, 4, 222, 2, 99, 2, 262, 5, 120, 0, 284, 3, 192, 4, 174, 5, 268, 5, 114, 0, 76, 5, 58, 4, 160, 2, 246, 4, 280] +HistoryString() = "120, 638, 4, 297, 2, 24, 2, 274, 0, 15, 3, 235, 1, 3, 4, 222, 2, 99, 2, 262, 5, 120, 0, 284, 3, 192, 4, 174, 5, 268, 5, 114, 0, 76, 5, 58, 4, 160, 2, 246, 4, 280" +IsChanceNode() = False +IsSimultaneousNode() = False +CurrentPlayer() = -4 +ObservationString(0) = "|__||__||__||w4||__|\n|b2||__||b1||__||__|\n|__||__||__||__||b3|\n|w3||__||w1||__||__|\n|__||__||__||__||b6|\n" +ObservationString(1) = "|__||__||__||w4||__|\n|b2||__||b1||__||__|\n|__||__||__||__||b3|\n|w3||__||w1||__||__|\n|__||__||__||__||b6|\n" +ObservationTensor(0): binvec(300, 0x1000000200100000000000000000208000000000000002000000000000000000002000000) +ObservationTensor(1): binvec(300, 0x1000000200100000000000000000208000000000000002000000000000000000002000000) +Rewards() = [1, -1] +Returns() = [1, -1] diff --git a/open_spiel/python/tests/pyspiel_test.py b/open_spiel/python/tests/pyspiel_test.py index f34ad4f153..7b7f7a0f18 100644 --- a/open_spiel/python/tests/pyspiel_test.py +++ b/open_spiel/python/tests/pyspiel_test.py @@ -56,6 +56,7 @@ "dots_and_boxes", "dou_dizhu", "efg_game", + "einstein_wurfelt_nicht", "euchre", "first_sealed_auction", "gin_rummy", From 43f43e772d8ba481d9081477755d0ab6b890c8a9 Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Sat, 30 Nov 2024 13:07:52 +0000 Subject: [PATCH 5/6] Fix conflicts. --- .../einstein_wurfelt_nicht.cc | 97 ------------------- .../einstein_wurfelt_nicht.h | 37 ------- 2 files changed, 134 deletions(-) diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc index ecaf6c53ea..98ab16e359 100644 --- a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc @@ -59,13 +59,8 @@ const GameType kGameType{/*short_name=*/"einstein_wurfelt_nicht", /*provides_information_state_tensor=*/false, /*provides_observation_string=*/true, /*provides_observation_tensor=*/true, -<<<<<<< HEAD - /*parameter_specification=*/ - {{"seed", GameParameter(42)}}}; -======= /*parameter_specification=*/{} // no parameters }; ->>>>>>> einstein_wurfelt_nicht_without_randomicity std::shared_ptr Factory(const GameParameters& params) { return std::shared_ptr(new EinsteinWurfeltNichtGame(params)); @@ -102,8 +97,6 @@ Color OpponentColor(Player player) { } } -<<<<<<< HEAD -======= std::vector> GetAllPermutations() { std::vector> all_permutations; std::vector nums = {1, 2, 3, 4, 5, 6}; @@ -115,7 +108,6 @@ std::vector> GetAllPermutations() { return all_permutations; } ->>>>>>> einstein_wurfelt_nicht_without_randomicity std::string CoordinatesToDirection(int row, int col) { std::string direction; if (row == col) { @@ -138,66 +130,21 @@ std::string CoordinatesToDirection(int row, int col) { } // namespace EinsteinWurfeltNichtState::EinsteinWurfeltNichtState( -<<<<<<< HEAD - std::shared_ptr game, int rows, int cols, int seed) - : State(game), - rows_(rows), - cols_(cols), - seed_(seed), -======= std::shared_ptr game, int rows, int cols) : State(game), rows_(rows), cols_(cols), turns_(-1), ->>>>>>> einstein_wurfelt_nicht_without_randomicity cur_player_(kChancePlayerId), prev_player_(kBlackPlayerId) { SPIEL_CHECK_GT(rows_, 1); SPIEL_CHECK_GT(cols_, 1); -<<<<<<< HEAD - - std::vector> players_cubes{{1, 2, 3, 4, 5, 6}, - {1, 2, 3, 4, 5, 6}}; - int player_cube_seed = seed_; - for (int i = 0; i < 2; ++i) { - if (seed_ == -1) { - player_cube_seed = - std::chrono::system_clock::now().time_since_epoch().count(); - } - player_cube_seed += 1; // make sure to have different seeds for each player - std::default_random_engine rng(player_cube_seed); - std::shuffle(players_cubes[i].begin(), players_cubes[i].end(), rng); - } - - // Values in the upper-left corner (black cubes) have a postion identified - // as rows+cols <= 2. Values in the lower-right corner (white cubes) have a - // position identified as rows+cols >= 6. The rest of the board is empty. - for (int r = 0; r < kDefaultRows; r++) { - for (int c = 0; c < kDefaultColumns; c++) { - if (r+c <= 2) { - board_[r*kDefaultColumns+c] = - Cube{Color::kBlack, players_cubes[0].back()}; - players_cubes[0].pop_back(); - } else if (r+c >= 6) { - board_[r*kDefaultColumns+c] = - Cube{Color::kWhite, players_cubes[1].back()}; - players_cubes[1].pop_back(); - } else { - board_[r*kDefaultColumns+c] = Cube{Color::kEmpty, -1}; - } - } - } -======= board_.fill(Cube{Color::kEmpty, -1}); ->>>>>>> einstein_wurfelt_nicht_without_randomicity winner_ = kInvalidPlayer; cubes_[0] = cubes_[1] = kNumPlayerCubes; } -<<<<<<< HEAD -======= void EinsteinWurfeltNichtState::SetupInitialBoard( Player player, Action action) { auto perms = GetAllPermutations(); @@ -221,7 +168,6 @@ void EinsteinWurfeltNichtState::SetupInitialBoard( } } ->>>>>>> einstein_wurfelt_nicht_without_randomicity int EinsteinWurfeltNichtState::CurrentPlayer() const { if (IsTerminal()) { return kTerminalPlayerId; @@ -290,22 +236,12 @@ EinsteinWurfeltNichtState::AvailableCubesPosition(Color player_color) const { void EinsteinWurfeltNichtState::DoApplyAction(Action action) { if (IsChanceNode()) { SPIEL_CHECK_GE(action, 0); -<<<<<<< HEAD - SPIEL_CHECK_LE(action, 5); -======= SPIEL_CHECK_LE(action, kNumCubesPermutations -1); ->>>>>>> einstein_wurfelt_nicht_without_randomicity turn_history_info_.push_back(TurnHistoryInfo(kChancePlayerId, prev_player_, die_roll_, action, Cube{Color::kEmpty, -1})); -<<<<<<< HEAD - cur_player_ = Opponent(prev_player_); - prev_player_ = cur_player_; - die_roll_ = action + 1; - return; -======= if (turns_ == -1) { SetupInitialBoard(kBlackPlayerId, action); turns_ = 0; @@ -321,7 +257,6 @@ void EinsteinWurfeltNichtState::DoApplyAction(Action action) { turns_++; return; } ->>>>>>> einstein_wurfelt_nicht_without_randomicity } // The die should have been rolled at least once at this point @@ -369,16 +304,11 @@ void EinsteinWurfeltNichtState::DoApplyAction(Action action) { cur_player_ = NextPlayerRoundRobin(cur_player_, kNumPlayers); cur_player_ = kChancePlayerId; -<<<<<<< HEAD -======= turns_++; ->>>>>>> einstein_wurfelt_nicht_without_randomicity } std::string EinsteinWurfeltNichtState::ActionToString(Player player, Action action) const { -<<<<<<< HEAD -======= std::string action_string = ""; if (IsChanceNode()) { @@ -396,7 +326,6 @@ std::string EinsteinWurfeltNichtState::ActionToString(Player player, } } ->>>>>>> einstein_wurfelt_nicht_without_randomicity std::vector values = UnrankActionMixedBase(action, {rows_, cols_, kNumDirections, 2}); int r1 = values[0]; @@ -406,16 +335,6 @@ std::string EinsteinWurfeltNichtState::ActionToString(Player player, int r2 = kDirRowOffsets[dir]; int c2 = kDirColOffsets[dir]; -<<<<<<< HEAD - std::string action_string = ""; - - if (IsChanceNode()) { - absl::StrAppend(&action_string, "roll ", action+1); - return action_string; - } - -======= ->>>>>>> einstein_wurfelt_nicht_without_randomicity Cube cube = board(r1, c1); std::string color = (cube.color == Color::kBlack) ? "B" : "W"; @@ -473,9 +392,6 @@ std::vector EinsteinWurfeltNichtState::LegalActions() const { std::vector> EinsteinWurfeltNichtState::ChanceOutcomes() const { SPIEL_CHECK_TRUE(IsChanceNode()); -<<<<<<< HEAD - return kChanceOutcomes; -======= if (turns_ <= 0) { // First 2 moves corresponds to the initial board setup. // There are 6! = 720 possible permutations of the cubes. @@ -490,7 +406,6 @@ EinsteinWurfeltNichtState::ChanceOutcomes() const { } else { return kChanceOutcomes; } ->>>>>>> einstein_wurfelt_nicht_without_randomicity } bool EinsteinWurfeltNichtState::InBounds(int r, int c) const { @@ -588,9 +503,6 @@ void EinsteinWurfeltNichtState::UndoAction(Player player, Action action) { } else { SetBoard(r2, c2, Cube{Color::kEmpty, -1}); } -<<<<<<< HEAD - } -======= } else { for (int r = 0; r < kDefaultRows; r++) { for (int c = 0; c < kDefaultColumns; c++) { @@ -603,16 +515,12 @@ void EinsteinWurfeltNichtState::UndoAction(Player player, Action action) { } } ->>>>>>> einstein_wurfelt_nicht_without_randomicity // Undo win status. winner_ = kInvalidPlayer; turn_history_info_.pop_back(); history_.pop_back(); -<<<<<<< HEAD -======= --turns_; ->>>>>>> einstein_wurfelt_nicht_without_randomicity --move_number_; } @@ -639,12 +547,7 @@ void EinsteinWurfeltNichtState::SetState(int cur_player, EinsteinWurfeltNichtGame::EinsteinWurfeltNichtGame(const GameParameters& params) : Game(kGameType, params), rows_(kDefaultRows), -<<<<<<< HEAD - cols_(kDefaultColumns), - seed_(ParameterValue("seed")) {} -======= cols_(kDefaultColumns) {} ->>>>>>> einstein_wurfelt_nicht_without_randomicity int EinsteinWurfeltNichtGame::NumDistinctActions() const { return rows_ * cols_ * kNumDirections * 2; diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h index 543380a95b..ead2daf9f7 100644 --- a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.h @@ -29,15 +29,6 @@ // This is the implementation of the basic game with a 5x5 board and 6 cubes // per player. // https://en.wikipedia.org/wiki/EinStein_w%C3%BCrfelt_nicht! -<<<<<<< HEAD -// -// Parameters: -// "seed" int random seed for placement of cubes on the board [1] (default=42) -// -// [1] When the seed is -1, the current time is used as the seed, so that the -// assignment of cubes is random each time the game is played. -======= ->>>>>>> einstein_wurfelt_nicht_without_randomicity namespace open_spiel { namespace einstein_wurfelt_nicht { @@ -53,11 +44,8 @@ inline constexpr int kNumPlayers = 2; inline constexpr int kBlackPlayerId = 0; inline constexpr int kWhitePlayerId = 1; inline constexpr int kNumPlayerCubes = 6; -<<<<<<< HEAD -======= // 720 possible permutations of 6 cubes on the board inline constexpr int kNumCubesPermutations = 720; ->>>>>>> einstein_wurfelt_nicht_without_randomicity inline constexpr int kDefaultRows = 5; inline constexpr int kDefaultColumns = 5; inline constexpr int k2dMaxBoardSize = kDefaultRows * kDefaultColumns; @@ -84,11 +72,7 @@ struct TurnHistoryInfo { class EinsteinWurfeltNichtState : public State { public: explicit EinsteinWurfeltNichtState(std::shared_ptr game, int rows, -<<<<<<< HEAD - int cols, int seed); -======= int cols); ->>>>>>> einstein_wurfelt_nicht_without_randomicity Player CurrentPlayer() const override; // Returns the opponent of the specified player. int Opponent(int player) const; @@ -116,26 +100,16 @@ class EinsteinWurfeltNichtState : public State { void DoApplyAction(Action action) override; private: -<<<<<<< HEAD -======= void SetupInitialBoard(Player player, Action action); ->>>>>>> einstein_wurfelt_nicht_without_randomicity Player cur_player_ = kInvalidPlayer; Player prev_player_ = kInvalidPlayer; int winner_ = kInvalidPlayer; int total_moves_ = -1; -<<<<<<< HEAD - std::array cubes_; - int rows_ = -1; - int cols_ = -1; - int seed_ = -1; -======= int turns_ = -1; std::array cubes_; int rows_ = -1; int cols_ = -1; ->>>>>>> einstein_wurfelt_nicht_without_randomicity int die_roll_ = 0; std::array board_; // for (row,col) we use row*cols_+col @@ -148,17 +122,10 @@ class EinsteinWurfeltNichtGame : public Game { int NumDistinctActions() const override; std::unique_ptr NewInitialState() const override { return std::unique_ptr( -<<<<<<< HEAD - new EinsteinWurfeltNichtState(shared_from_this(), rows_, cols_, seed_)); - } - - int MaxChanceOutcomes() const override { return 6; } -======= new EinsteinWurfeltNichtState(shared_from_this(), rows_, cols_)); } int MaxChanceOutcomes() const override { return kNumCubesPermutations; } ->>>>>>> einstein_wurfelt_nicht_without_randomicity int NumPlayers() const override { return kNumPlayers; } double MinUtility() const override { return -1; } @@ -182,10 +149,6 @@ class EinsteinWurfeltNichtGame : public Game { private: int rows_ = -1; int cols_ = -1; -<<<<<<< HEAD - int seed_ = -1; -======= ->>>>>>> einstein_wurfelt_nicht_without_randomicity }; } // namespace einstein_wurfelt_nicht From eec844a0db384acd941bb074f03b38baba4134de Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Fri, 13 Dec 2024 23:08:07 +0000 Subject: [PATCH 6/6] Use UnrankPermutation for cubes positions. --- .../einstein_wurfelt_nicht.cc | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc index 98ab16e359..c179ebe111 100644 --- a/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc +++ b/open_spiel/games/einstein_wurfelt_nicht/einstein_wurfelt_nicht.cc @@ -20,6 +20,7 @@ #include #include "open_spiel/game_parameters.h" +#include "open_spiel/utils/combinatorics.h" #include "open_spiel/utils/tensor_view.h" namespace open_spiel { @@ -97,17 +98,6 @@ Color OpponentColor(Player player) { } } -std::vector> GetAllPermutations() { - std::vector> all_permutations; - std::vector nums = {1, 2, 3, 4, 5, 6}; - - do { - all_permutations.push_back(nums); - } while (std::next_permutation(nums.begin(), nums.end())); - - return all_permutations; -} - std::string CoordinatesToDirection(int row, int col) { std::string direction; if (row == col) { @@ -147,7 +137,9 @@ EinsteinWurfeltNichtState::EinsteinWurfeltNichtState( void EinsteinWurfeltNichtState::SetupInitialBoard( Player player, Action action) { - auto perms = GetAllPermutations(); + std::vector indices(kNumPlayerCubes); + std::iota(indices.begin(), indices.end(), 1); + std::vector cubes_position_order = UnrankPermutation(indices, action); int perm_idx = 0; // Values in the upper-left corner (black cubes) have a postion identified @@ -157,11 +149,11 @@ void EinsteinWurfeltNichtState::SetupInitialBoard( for (int c = 0; c < kDefaultColumns; c++) { if (r+c <= 2 && player == kBlackPlayerId) { board_[r*kDefaultColumns+c] = - Cube{Color::kBlack, perms[action][perm_idx]}; + Cube{Color::kBlack, cubes_position_order[perm_idx]}; perm_idx++; } else if (r+c >= 6 && player == kWhitePlayerId) { board_[r*kDefaultColumns+c] = - Cube{Color::kWhite, perms[action][perm_idx]}; + Cube{Color::kWhite, cubes_position_order[perm_idx]}; perm_idx++; } }