From 43f43e772d8ba481d9081477755d0ab6b890c8a9 Mon Sep 17 00:00:00 2001 From: Giovanni Ortolani Date: Sat, 30 Nov 2024 13:07:52 +0000 Subject: [PATCH] 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