Closed Kesanov closed 3 years ago
@findmyway can you take a look?
Hi @Josef-Vonasek ,
Thanks for trying out the Julia API.
Is it possible to fix this error?
Yes, but it requires a little knowledge of CxxWrap
. (I'll skip the details here for now)
So why the test cases are passed but the same code throws an error here? Because the evaluate_bots
function is not the original one in the c++ backend. I added a customized one here 😞 :
Note that this method is not added in the OpenSpiel.jl
package. It is for tests only.
I am also getting a little bit lost in the types. Is there some way to get more helpful type signatures? For example by truncating the prefixes CxxWrap.CxxWrapCore.
Hmm... I agree it might be difficult to understand the type signatures without knowing CxxWrap.jl
. But since the whole APIs are built on CxxWrap.jl
, there's nothing more we can do here.
Finally, how can I pass custom child_selection_fn in MCTSBot? I assume using ordinary Julia function won't work.
Correct! In theory, it's possible to pass in an ordinary Julia function. But that needs some extra work and I'm afraid it doesn't worth the efforts.
Btw I am trying to rewrite my Python project in Julia to improve performance.
That's great! Welcome to the Julia community.
But the Julia API is much more rough than the Python one (complex types, no comments, harder to discover methods for given type). Are there some tricks / tooling to list methods, simplify types or inspect comments / jump to C++ source definition? I would be very thankful for any advice on this.
OpenSpiel.jl
. I'll give it a try later. Currently the only choice is to manually search in the source code. Note that all the names are transformed from CamelCase
into camel_case
in OpenSpiel.jl
.I'm not sure how you would like to use the Julia APIs of OpenSpiel. If you focus on the games only. I'd suggest you give ReinforcementLearningEnvironments.jl a try. It provides a set of APIs similar to OpenAI/gym and is more user-friendly.
Example usage:
] add ReinforcementLearningBase, ReinforcementLearningEnvironments, OpenSpiel
using ReinforcementLearningBase, ReinforcementLearningEnvironments, OpenSpiel
env = OpenSpielEnv("tic_tac_toe")
while !is_terminated(env)
env(rand(legal_action_space(env)))
end
And then you can use most algorithms provided in ReinforcementLearningZoo.jl written in pure Julia, which covers many algorithms in OpenSpiel. (MCTS related are not added yet but it's on my todo list to integrate AlphaZero.jl .)
Let me know if anything is still unclear to you.
Thank you for quick response.
I installed openspiel with
] add OpenSpiel
on julia 1.5.3 and copy pasted code from one of your test:If I run this code I get:
CxxWrap.CxxWrapCore
.child_selection_fn
in MCTSBot? I assume using ordinary Julia function won't work.Btw I am trying to rewrite my Python project in Julia to improve performance. But the Julia API is much more rough than the Python one (complex types, no comments, harder to discover methods for given type). Are there some tricks / tooling to list methods, simplify types or inspect comments / jump to C++ source definition? I would be very thankful for any advice on this.