test failing
unhandyandy opened this issue · 8 comments
I'm trying a simple test of using a custom AI: I copied AlphaBetaSearch.java from LudiiAI in a new folder
LudiiExampleAI/src/minimax.
Then I compiled it into a jar file. The top level looks like
META-INF
AlphaBetaSearch.class
But when I try to use it in the Ludii player, by selecting the jar file, I get the message in console:
Could not find any AI classes.
Any idea what I'm probably doing wrong?
How did you build the JAR? The way you describe the top level, the .class
file is directly there, it's not sorted into any deeper directories. This is only correct if the source file also doesn't have any package declarations. Is that correct, did you not put it in any packages?
For example, the Example Random AI has package random;
at the top. This one can then also only get loaded correctly from a JAR file if the JAR looks like:
META-INF
random/RandomAI.class
If you're willing to share your JAR file, that might make debugging easier. You can also email a download link for it to me privately if you prefer not to share it publicly.
OK, I tried putting the AlphaBetaSearch.class in the minimax directory in the jar file, but I get the same error.
I'd be perfectly happy to attach the jar file, but you "don't support that file type." :)
I sent it by email.
I sent it by email.
@unhandyandy I don't see it anywhere (not sure if you sent it to my personal email, or university email, or to the Ludii email account, or... something else :D). But most email providers don't allow sending/receiving JAR files as attachment either. Do you have some place where you could upload the file, and then send the download link? Like, a personal website, or Dropbox, something like that?
I'm not getting the message about not finding any AI classes that you mentioned with that JAR, but I am getting exceptions thrown due to Java version mismatched. Your class file was compiled for Java 11, but we always compile Ludii to work with Java 8. Can you try compiling for 8 as well, as discussed in Issue #2 ?
OK, using v.8 uniformly fixed the "Could not find any AI classes" problem, thanks for your help.
One glitch in the Ludii app: it doesn't seem to reload a jar AI file. If I update a jar file, then select it for AI via "From JAR", it Ludii does not seem to reread it.
Yes you'll have to close and re-open the Ludii app for any changes to your third-party AI to become visible. See this note from this repo's readme:
Note: while the Ludii application is running, it will only load all the .class files of any selected JAR file once. If you have already selected a JAR file once, and then re-build your custom JAR file without changing its filepath, you will have to close and re-open the Ludii application if you wish to try loading agents from the modified JAR file.
If we want to change this, we'll first have to write our own custom classloader to facilitate unloading and re-loading previously-loaded classes, which seemed to be non-trivial when I looked into it.