From b23f1b0676002861ef41724a27d11c3148d1807c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Ant=C3=B4nio?= <114777087+Max-Antonio@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:21:02 -0300 Subject: [PATCH 1/7] Update contributing.md --- docs/contributing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/contributing.md b/docs/contributing.md index 5d880154b2..a48e48d972 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -55,6 +55,10 @@ every two weeks (for bug fixes, it will likely be faster to be integrated). So you may need to wait a little after it has been approved to actually see it merged. +# OpenSpiel visual Graph + +To help you understand better the framework as a whole you can go to [openspielgraph](https://openspielgraph.netlify.app) and use an interactive graph that shows the OpenSpiel repository in a wide and easy to undestand way. + # Roadmap and Call for Contributions Contributions to this project must be accompanied by a Contributor License From 9f5fcbe3708f2ef3a8862d633ba28cb6e66dac3f Mon Sep 17 00:00:00 2001 From: Lucas Celestino <98926627+LucasCelestinoSE@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:27:44 -0300 Subject: [PATCH 2/7] Update contributing.md: Wasm add --- docs/contributing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/contributing.md b/docs/contributing.md index a48e48d972..9a83ed2572 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -1,4 +1,4 @@ -# Guidelines +![image](https://github.com/user-attachments/assets/58bf7efa-4dcd-45d2-9ffa-a38c486b3037)# Guidelines Above all, OpenSpiel is designed to be easy to install and use, easy to understand, easy to extend (“hackable”), and general/broad. OpenSpiel is built @@ -59,6 +59,8 @@ merged. To help you understand better the framework as a whole you can go to [openspielgraph](https://openspielgraph.netlify.app) and use an interactive graph that shows the OpenSpiel repository in a wide and easy to undestand way. +For a practical example, see one of the reasons OpenSpielGraph was thought of and also how to use OpenSpiel and WebAssembly... + # Roadmap and Call for Contributions Contributions to this project must be accompanied by a Contributor License From 67d57a8e9d4348e5d8f861462d2ebbca62738737 Mon Sep 17 00:00:00 2001 From: Lucas Celestino <98926627+LucasCelestinoSE@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:28:07 -0300 Subject: [PATCH 3/7] Update contributing.md --- docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributing.md b/docs/contributing.md index 9a83ed2572..ce056e361f 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -1,4 +1,4 @@ -![image](https://github.com/user-attachments/assets/58bf7efa-4dcd-45d2-9ffa-a38c486b3037)# Guidelines +# Guidelines Above all, OpenSpiel is designed to be easy to install and use, easy to understand, easy to extend (“hackable”), and general/broad. OpenSpiel is built From 891f29799625e2360099f1008eb7a0febc1e639a Mon Sep 17 00:00:00 2001 From: ant2077 <138495090+antoniodcomp@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:52:58 -0300 Subject: [PATCH 4/7] Update contributing.md --- docs/contributing.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/contributing.md b/docs/contributing.md index ce056e361f..fcca6c1e22 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -59,6 +59,8 @@ merged. To help you understand better the framework as a whole you can go to [openspielgraph](https://openspielgraph.netlify.app) and use an interactive graph that shows the OpenSpiel repository in a wide and easy to undestand way. +By providing intuitive visual representations, it simplifies the debugging process, aids in the optimization of algorithms, and fosters a more efficient workflow. + For a practical example, see one of the reasons OpenSpielGraph was thought of and also how to use OpenSpiel and WebAssembly... # Roadmap and Call for Contributions From b6a5dc56a04094a82a13c53960e4c800fea87f65 Mon Sep 17 00:00:00 2001 From: James Flynn Date: Mon, 19 Aug 2024 17:42:21 +0100 Subject: [PATCH 5/7] Fix for issue #1266, removed array initialization with None --- open_spiel/python/algorithms/efr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/open_spiel/python/algorithms/efr.py b/open_spiel/python/algorithms/efr.py index 8880c564b0..1976d33ed3 100644 --- a/open_spiel/python/algorithms/efr.py +++ b/open_spiel/python/algorithms/efr.py @@ -808,7 +808,7 @@ def return_cs_partial_sequence(num_actions, history, prior_legal_actions): information set. """ prior_actions_in_memory = history - external_memory_weights = [None] + external_memory_weights = [] for i in range(len(history)): possible_memory_weight = np.zeros(len(history)) @@ -851,7 +851,7 @@ def return_cs_partial_sequence_orginal( information set. """ prior_actions_in_memory = history - external_memory_weights = [None] + external_memory_weights = [] for i in range(len(history)): possible_memory_weight = np.zeros(len(history)) @@ -891,7 +891,7 @@ def return_twice_informed_partial_sequence( all TIPS deviations that are realizable at theinformation set. """ prior_actions_in_memory = history - memory_weights = [None] + memory_weights = [] for i in range(len(history)): possible_memory_weight = np.zeros(len(history)) From 4786b88ab43204d79c6fd1eadd1b2bd9110bf07b Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Thu, 8 Aug 2024 15:49:50 +0000 Subject: [PATCH 6/7] Expose State::NewInitialState(const std::string& str) to Python games PiperOrigin-RevId: 660854019 Change-Id: Ic8ea60ea4dcf4bc80c5191d2a5e29a361b79bf22 --- open_spiel/python/pybind11/python_games.cc | 15 +++++++++++++++ open_spiel/python/pybind11/python_games.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/open_spiel/python/pybind11/python_games.cc b/open_spiel/python/pybind11/python_games.cc index 4af2384c4a..5ab8dcc4d3 100644 --- a/open_spiel/python/pybind11/python_games.cc +++ b/open_spiel/python/pybind11/python_games.cc @@ -14,20 +14,30 @@ #include "open_spiel/python/pybind11/python_games.h" +#include +#include #include +#include // Interface code for using Python Games and States from C++. +#include "open_spiel/abseil-cpp/absl/container/inlined_vector.h" #include "open_spiel/abseil-cpp/absl/strings/escaping.h" #include "open_spiel/abseil-cpp/absl/strings/numbers.h" +#include "open_spiel/abseil-cpp/absl/strings/str_cat.h" +#include "open_spiel/abseil-cpp/absl/strings/str_join.h" #include "open_spiel/abseil-cpp/absl/strings/string_view.h" #include "open_spiel/abseil-cpp/absl/strings/str_split.h" +#include "open_spiel/abseil-cpp/absl/types/optional.h" +#include "open_spiel/abseil-cpp/absl/types/span.h" #include "open_spiel/game_parameters.h" #include "open_spiel/python/pybind11/pybind11.h" +#include "open_spiel/observer.h" #include "open_spiel/spiel.h" #include "open_spiel/spiel_globals.h" #include "open_spiel/spiel_utils.h" + namespace open_spiel { namespace py = ::pybind11; @@ -41,6 +51,11 @@ std::unique_ptr PyGame::NewInitialState() const { NewInitialState); } +std::unique_ptr PyGame::NewInitialState(const std::string& str) const { + PYBIND11_OVERLOAD_PURE_NAME(std::unique_ptr, Game, "new_initial_state", + NewInitialState, str); +} + std::unique_ptr PyGame::NewInitialStateForPopulation( int population) const { PYBIND11_OVERLOAD_PURE_NAME(std::unique_ptr, Game, diff --git a/open_spiel/python/pybind11/python_games.h b/open_spiel/python/pybind11/python_games.h index 7aaa7646f7..1650004ca9 100644 --- a/open_spiel/python/pybind11/python_games.h +++ b/open_spiel/python/pybind11/python_games.h @@ -18,8 +18,16 @@ // Interface and supporting functions for defining games in Python and using // them from C++. +#include +#include +#include + #include "open_spiel/python/pybind11/pybind11.h" +#include "open_spiel/abseil-cpp/absl/types/optional.h" +#include "open_spiel/game_parameters.h" +#include "open_spiel/observer.h" #include "open_spiel/spiel.h" +#include "open_spiel/spiel_utils.h" namespace open_spiel { @@ -33,6 +41,7 @@ class PyGame : public Game { // Implementation of the Game API. std::unique_ptr NewInitialState() const override; + std::unique_ptr NewInitialState(const std::string& str) const override; std::unique_ptr NewInitialStateForPopulation( int population) const override; int MaxChanceNodesInHistory() const override; From 37016c10f0708451b09ad086ba57b1963e9383fd Mon Sep 17 00:00:00 2001 From: John Schultz Date: Mon, 12 Aug 2024 15:47:04 +0000 Subject: [PATCH 7/7] Fix bug in chess960 move to action parsing. PiperOrigin-RevId: 662101103 Change-Id: I7485bba9273083822c8b28661489333d9d7a9a12 --- open_spiel/games/chess/chess.cc | 3 ++- open_spiel/games/chess/chess_board.cc | 5 +++-- open_spiel/games/chess/chess_board.h | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/open_spiel/games/chess/chess.cc b/open_spiel/games/chess/chess.cc index f683ecaef3..c1ee03880d 100644 --- a/open_spiel/games/chess/chess.cc +++ b/open_spiel/games/chess/chess.cc @@ -137,7 +137,8 @@ ActionsAndProbs ChessState::ChanceOutcomes() const { } Action ChessState::ParseMoveToAction(const std::string& move_str) const { - absl::optional move = Board().ParseMove(move_str); + bool chess960 = ParentGame()->IsChess960(); + absl::optional move = Board().ParseMove(move_str, chess960); if (!move.has_value()) { return kInvalidAction; } diff --git a/open_spiel/games/chess/chess_board.cc b/open_spiel/games/chess/chess_board.cc index 51103b098f..b2042f7cef 100644 --- a/open_spiel/games/chess/chess_board.cc +++ b/open_spiel/games/chess/chess_board.cc @@ -877,13 +877,14 @@ bool ChessBoard::HasSufficientMaterial() const { return dark_bishop_exists && light_bishop_exists; } -absl::optional ChessBoard::ParseMove(const std::string &move) const { +absl::optional ChessBoard::ParseMove(const std::string &move, + bool chess960) const { // First see if they are in the long form - // "anan" (eg. "e2e4") or "anana" (eg. "f7f8q") // SAN moves will never have this form because an SAN move that starts with // a lowercase letter must be a pawn move, and pawn moves will never require // rank disambiguation (meaning the second character will never be a number). - auto lan_move = ParseLANMove(move); + auto lan_move = ParseLANMove(move, chess960); if (lan_move) { return lan_move; } diff --git a/open_spiel/games/chess/chess_board.h b/open_spiel/games/chess/chess_board.h index ab5107b26c..a3dc2333e4 100644 --- a/open_spiel/games/chess/chess_board.h +++ b/open_spiel/games/chess/chess_board.h @@ -359,7 +359,8 @@ class ChessBoard { // Parses a move in standard algebraic notation or long algebraic notation // (see below). Returns absl::nullopt on failure. - absl::optional ParseMove(const std::string& move) const; + absl::optional ParseMove(const std::string& move, + bool chess960 = false) const; // Parses a move in standard algebraic notation as defined by FIDE. // https://en.wikipedia.org/wiki/Algebraic_notation_(chess).