diff --git a/docs/contributing.md b/docs/contributing.md index 5d880154b2..1c865b962a 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -55,6 +55,19 @@ 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. + +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 Contributions to this project must be accompanied by a Contributor License 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). 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)) 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;