Prolog: An AI program that plays Eternagame

What library/repo is this for?

Iā€™m not sure. Iā€™m just getting started with your instructions earlier in this discussion thread. I clicked on the github link you suggested and github said to install Python 2.7.12.
Iā€™ve done a fair amount of programming, but, these shared web resources are totally new to me.

Iā€™m not sure my reply went specifically to you, so I am quoting it to you. Iā€™m not used to forum threads either.

Iā€™m not sure. Iā€™m just getting started with your instructions earlier in this discussion thread. I clicked on the github link you suggested and github said to install Python 2.7.12.
Iā€™ve done a fair amount of programming, but, these shared web resources are totally new to me.

Iā€™m not sure which GitHub link you mean. EternaJS or Arnie? I donā€™t see any information about Python 2 in either README

Oh, I assume youā€™re referring to Emscripten. Did a bit of digging and it looks like Python >= 3.5 also works. For what its worth though, if youā€™re just running the models locally, you may not want to use Emscripten, but instead just compile them ā€œnormallyā€ - or use Arnie. Eternaā€™s implementations of the libraries arenā€™t really built well for external usage. You can certainly try though if you want.

I see that GitHub has some tutorials. Iā€™m going to run through some of those, so I at least get some vocabulary. I think this will be more efficient for both of us than if I just start sending you questions at every sentence I read.

In the SDD I placed on my google drive (if you havenā€™t read it, itā€™s a very short (!!) SDD at this point), I called for a new program called ā€œEternagame_mod_oneā€. I now think that it is entirely unnecessary. Somewhere in your source code, you must associate each puzzle with the locked bases for that puzzle. Similarly (but, perhaps more complicatedly), there must be information showing which pairs of bases are bound in the target structure. If I could just get access to those two pieces of information, I could place them directly into my Prolog program. I could then run rnafold.pl on any specific puzzle, just by entering its identifier. This would be a huge help. I clicked on your link to ā€˜here are the sourcesā€™. It took me to a discussions thread on ā€œbuilding the folding engines.ā€ Since Iā€™m still trying to figure out GitHub, I didnā€™t know where to go from there, to find individual files and look for the information that I need. Can you help me find the information?

If youā€™re just looking for puzzle definitions, you can use our web API. Specifically, youā€™re looking for https://eternagame.org/home/swagger/index.html#/puzzle/get_get__type_puzzle

I still need some clarification on what you want as far as validating your designs in order to point you in the right direction there.

  • If youā€™re looking to verify that it passes all constraints within Eterna, Iā€™ll point you in the direction of writing a booster where you can paste in your potential solutions and verify them in-game.
  • If you want to be able to do it outside of the Eterna interface within your prolog program directly, Iā€™d probably recommend Arnie as a relatively clean interface to the different folding engines.
  • To be honest, working with the EternaJS codebase directly is probably not what you want - unless you want BOTH full game validation and usage directly from your prolog script - but thatā€™d potentially require more work, essentially loading up an instance of the game you can run headless. This is something I would like to eventually improve on (creating some core libraries that could be used somewhat similar to Arnie), but weā€™re not there yet.

I tried the link you supplied, but the responses I get look like this:
ā€œdataā€: {
ā€œpuzzlesā€: [
{
ā€œidā€: ā€œ6502963ā€,
ā€œtitleā€: ā€œ[Thermocycler] Level 1 of 11ā€,
ā€œcreatedā€: ā€œ1360881926ā€,
ā€œusernameā€: ā€œcalebgeniesseā€,
ā€œuserpictureā€: ā€œsites/default/files/pictures/picture-130245.jpgā€,
ā€œmade-by-playerā€: ā€œ0ā€,
ā€œnum-clearedā€: ā€œ9198ā€,
ā€œtypeā€: ā€œProgressionā€,
ā€œsolved-by-botā€: null,
ā€œrewardā€: ā€œ500ā€,
ā€œmade-for-labā€: null,
ā€œfolderā€: ā€œViennaā€,
ā€œnumber_of_statesā€: 1
},
There is a lot of information there about the puzzle, but nothing that I need. Again, I need to know what bases are locked (and what they are locked to) in the puzzle. I also need to know what bases are bound together in the target solution.

Of course, I could bring up the puzzle within the game, using the puzzle ID and then hand copy the values into my program. Thatā€™s what I have done so far. I was hoping to be able to get a list of the data I need for all of the puzzles in a text version.

Iā€™m deferring the validation portion for now. But consider this. My program will present hundreds to thousands of potential solutions. Iā€™ll be trying to add more rules to cut this down, but too many will limit the ability to find all of the valid solutions. Entering all these solutions by hand, or even pasting them into a field for each solution is not really practical.

I see you are working on some things at that end. Perhaps by the time I need them they will exist.

Again, thanks for your help.

You donā€™t want type=puzzles, but type=puzzle. EG: https://eternagame.org/get/?type=puzzle&nid=6502963 The plural version is the listing (used for Eterna) and the other is for an individual puzzle (used for /puzzles/ and /game/puzzle//)

Entering all these solutions by hand, or even pasting them into a field for each solution is not really practical.

By pasting, I meant to suggest pasting many solutions at once, EG pasting a CSV into a textarea. You could imagine using a browser API to load a CSV or such from the filesystem too. Of course, the more streamlined approach would be to have it completely automated

I think weā€™re getting closer. Now, I get responses like this:
{
ā€œidā€: ā€œ782913ā€,
ā€œtitleā€: ā€œProject : Turtle project Ml 6-6-6-6, 3 legs (3 NT), neck (3 NT) + tetraloopsā€,
ā€œcreatedā€: ā€œ1328186035ā€,
ā€œusernameā€: ā€œEli Fiskerā€,
ā€œuserpictureā€: ā€œsites/default/files/pictures/picture-8627.jpgā€,
ā€œmade-by-playerā€: ā€œ1ā€,
ā€œnum-clearedā€: null,
ā€œtypeā€: ā€œExperimentalā€,
ā€œsolved-by-botā€: "ViennaRNA_CCACUAGAUGAUGAGAGUCCCAAAGGUCCCGCGACAAAUAUGCACUACUGCCAACGAUGG_426, RNASSD_GGGAGAGCCGCGUAGACGCUAAUGAGGGGACACCCAGAAAAGGCUGAUGCCAAAAUACCC_70, InfoRNA_GCCAACUUCGGGGAAACCCACGAUAGGGGAAACCCACGAUCGGGGAAACCCACCACCGGC_3, ",
ā€œrewardā€: null,
ā€œmade-for-labā€: null,
ā€œfolderā€: ā€œViennaā€,
ā€œnumber_of_statesā€: 1
}

Which do include some sequence listings. But they are solutions, not the lock sequence for the original puzzle.

And, yes being able to paste many solutions at once would be a big help, although I donā€™t know what ā€œCSVā€ means. Looks like a lot of vocabulary has changed on me.

In the case where data.puzzle.locks is null, there are no locks. If you load up a puzzle that has locks, theyā€™ll be there (experimental puzzles with ā€œtailsā€ at the start and end are special cases as those entire regions of the puzzle are added in the game itself when the puzzle is loaded, but you probably donā€™t care about those).

CSV is comma separated value - common plain text/flat file interchange format. Itā€™s what you might export a spreadsheet to to be easy to interoperate between programs.

Possibly, I was not completely clear. At this stage, I am not looking for solutions to puzzles. I am looking for puzzle definitions.

Itā€™s been a while since I checked in. I am still working . Right now Iā€™m implementing multi-threading in the program. This is taking a while and Iā€™m having lots of back and forth with the helpful forum at Swi-Prolog. It seems that the method they are recommending was just added to the language at the end of June.

Iā€™m also doing some structural cleanup, before I totally lose track of what Iā€™m doing.

Hereā€™s a link to our API reference that you might find useful
Also, you might want to join our Discord

Best of luck with the cleanup!

Yes, I understand - the ?type=puzzle API endpoint is exactly what the game pulls from for its puzzle definitions (with some minor transformations done in the code to handle things like defaults)

I was mired in the morass of multithreading for some weeks, but have now broken free. There is a new version of rnafold on the google drive. It is rnafold20200824.pl. I have also made a .docx of it so it can be viewed without having to download the compiler, but you wonā€™t see the pretty colors the IDE uses to delineate the structure.
It now uses 98% of the CPU(s) . I had to rework the check_bond section, but, as a result it is much cleaner now.
I hope I can move on to more complex computations without having to wait too long for results. However, I may spend some more time on architecture first.

rnafold is now running in multithreaded mode. This has resulted in a 40% reduction in run time for the medium focus version of puzzle 11. I had hoped for a larger saving, however, it seems that the chip in my laptop is much stronger than the fan. When I run in multithread, the CPU is used at 100%, with 98% of that going to rnafold, and all 8 LPUs are also running constantly at 100% (it would be hard to be otherwise). However, the CPU speed decreases from 3.3 GHz to 2.2. This accounts for most of the missing speed. The rest is, presumably, due to the overhead imposed by the multithreading process itself.
I have been using puzzle 11 because it only takes about 4 minutes to run even in sequential mode.

I will be moving ahead into more complex puzzles, but at least now I know that I could make good use of more processor power if I had it.

I have placed a new document on my Google Drive (see top of thread). I hope that some of you will find time to read it (it is only 3 pages). It provides a better idea of what I am trying to do, and what the possibilities and limitations are. The document is ā€œPuzzle 11, an exampleā€ and is in both docx and pdf formats.
I am hoping to get some feedback.

That code cleanup I mentioned turned into a complete teardown and rebuild. I think it was worth it. It was tempting to charge ahead into more puzzles, but the new approach will make things easier in the long run.
The google drive now has a directory called ā€œsourcesā€, and a sub-directory with todayā€™s date, which has the new sources. The program is now modularized and has four source files. More importantly, the file ā€œsetup.plā€ contains the a database of puzzle definitions. Now, I can just make entries there instead of writing new code for each puzzle. Of course, when I add a new rule, I will need to write code for that.
This version is fully multithreaded and runs all 4 cores (8 threads) at 100% loading.
Iā€™m sure that for some of the developers, this looks like a pitifully small amount of code, but I think Prolog is a compact language.