diff --git a/open_spiel/julia/src/OpenSpiel.jl b/open_spiel/julia/src/OpenSpiel.jl index d5b367cbb0..379ebe8446 100644 --- a/open_spiel/julia/src/OpenSpiel.jl +++ b/open_spiel/julia/src/OpenSpiel.jl @@ -6,6 +6,11 @@ using CxxWrap import CxxWrap:argument_overloads import Base: step, first, last +struct PlayerAction + player::Int32 + action::Int64 +end + @wrapmodule(LIB_OPEN_SPIEL) include("patch.jl") diff --git a/open_spiel/julia/test/games_api.jl b/open_spiel/julia/test/games_api.jl index 0721aae0f9..93b53d1aa0 100644 --- a/open_spiel/julia/test/games_api.jl +++ b/open_spiel/julia/test/games_api.jl @@ -20,15 +20,20 @@ end game = load_game("kuhn_poker") state = new_initial_state(game) @test is_chance_node(state) == true + @test is_initial_state(state) == true @test chance_outcomes(state) == [0 => 1/3, 1 => 1/3, 2 => 1/3] apply_action(state, 1) @test is_chance_node(state) == true + @test is_initial_state(state) == false @test chance_outcomes(state) == [0 => 1/2, 2 => 1/2] apply_action(state, 2) @test is_chance_node(state) == false + @test is_initial_state(state) == false @test legal_actions(state) == [0, 1] + + @test length(full_history(state)) == 2 end @testset "tic_tac_toe" begin @@ -36,6 +41,7 @@ end state = new_initial_state(game) @test is_chance_node(state) == false @test is_terminal(state) == false + @test is_initial_state(state) == true @test legal_actions(state) == 0:8 end diff --git a/open_spiel/julia/wrapper/spieljl.cc b/open_spiel/julia/wrapper/spieljl.cc index ffbd091291..66b28b658c 100644 --- a/open_spiel/julia/wrapper/spieljl.cc +++ b/open_spiel/julia/wrapper/spieljl.cc @@ -123,6 +123,9 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& mod) { jlcxx::stl::apply_stl>(mod); jlcxx::stl::apply_stl>>(mod); jlcxx::stl::apply_stl>(mod); + + mod.map_type("PlayerAction"); + jlcxx::stl::apply_stl>(mod); mod.add_bits("GameParameterStateType", jlcxx::julia_type("CppEnum")); @@ -306,6 +309,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& mod) { }) .method("to_string", &open_spiel::State::ToString) .method("is_terminal", &open_spiel::State::IsTerminal) + .method("is_initial_state", &open_spiel::State::IsInitialState) .method("rewards", &open_spiel::State::Rewards) .method("returns", &open_spiel::State::Returns) .method("player_reward", &open_spiel::State::PlayerReward) @@ -316,6 +320,7 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& mod) { .method("is_player_node", &open_spiel::State::IsPlayerNode) .method("history", &open_spiel::State::History) .method("history_str", &open_spiel::State::HistoryString) + .method("full_history", &open_spiel::State::FullHistory) .method("information_state_string", [](open_spiel::State& s, open_spiel::Player p) { return s.InformationStateString(p);