Stan` Posted yesterday at 14:25 Report Share Posted yesterday at 14:25 1 hour ago, CulturedCait said: That explains a lot. Hmm.. Weird idea, but is it possible that in nonvisual mode "OnInitGame" is not invoked?? This is my entry point: { let learnTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); learnTrigger.RegisterTrigger("OnDeserialized", "TestLearningLoad", { "enabled": true }); learnTrigger.RegisterTrigger("OnInitGame", "TestLearningStart", { "enabled": true }); learnTrigger.RegisterTrigger("OnPlayerCommand", "TestLearningCommand", { "enabled": true }); ////learnTrigger.DoAfterDelay(1000, "TestLearningSpeed", { "enabled": true }); } In single run my script ends in about 20 minutes,then Engine.Exit is issued to close the game. If it works much faster in -nonvisual mode, then we should expect it to finish in less than 20 minutes. What I did was to test it again with -autostart-nonvisual and just waited. Although it didn't produce save games and JSON files, we could explain this is somehow forbidden in this mode. But considering it has still not finished after 30 minutes, maybe the whole thing is just that the script is not triggering in -nonvisual mode?? To check this on Linux just add debug prints to your handlers like warn("something") or error("something") Quote Link to comment Share on other sites More sharing options...
CulturedCait Posted yesterday at 16:16 Author Report Share Posted yesterday at 16:16 Well, as I mentioned earlier my output is not appearing at all. I have plenty of warns. Script also reads/writes JSON files and does save game. None of this is executed if -autostart-nonvisual is on. Just "Turn (...)..." appears instead. Looks like it is impossible to use headless mode just to run map with scripts. Probably -autostart-nonvisual is not just turning off graphics and sound, but rather special mode designated to work with -rl-interface only. Quote Link to comment Share on other sites More sharing options...
Stan` Posted 23 hours ago Report Share Posted 23 hours ago 6 hours ago, CulturedCait said: Looks like it is impossible to use headless mode just to run map with scripts. Probably -autostart-nonvisual is not just turning off graphics and sound, but rather special mode designated to work with -rl-interface only. Yeah something is off. Is it writing to interestinglog.html /mainlog.html ? Whether it's visual or non visual it should do the same thing because it needs to be reproductible. It was there long time before the RL interface. Cc @phosit @hyperion @Itms Quote Link to comment Share on other sites More sharing options...
CulturedCait Posted 13 hours ago Author Report Share Posted 13 hours ago With -autostart-nonvisual: Without: Quote Link to comment Share on other sites More sharing options...
hyperion Posted 11 hours ago Report Share Posted 11 hours ago There are a few bug reports by @Langbart wrt autostart / nonvisual / rlinterface, I'd check if one of them applies here and if not file a new one with clear steps to reproduce. I probably will spend some time during the r29 release cycle on this topic, tho for the next few weeks I intend to focus on xmpp/lobby stuff open for years. Quote Link to comment Share on other sites More sharing options...
Stan` Posted 11 hours ago Report Share Posted 11 hours ago Is there anything in the main log that says that something was skipped ? Quote Link to comment Share on other sites More sharing options...
CulturedCait Posted 10 hours ago Author Report Share Posted 10 hours ago 42 minutes ago, Stan` said: Is there anything in the main log that says that something was skipped ? Nope. I'm not sure if I can attach full logs here in public. They include sensitive data like API keys. I can send you both logs in PM if needed. In -autostart-nonvisual "NonVisualTrigger.js" is loaded additionally as opposed to regular run. I don't think its the culprit, but who knows. Quote Link to comment Share on other sites More sharing options...
Stan` Posted 9 hours ago Report Share Posted 9 hours ago It seems it shouldn't have any weird side effects. https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/maps/scripts/NonVisualTrigger.js It does load your genetic_async.js too bad we don't have https://gitea.wildfiregames.com/0ad/0ad/pulls/7245 yet in your version. Can you figure the furthest it goes in your script before it starts warning. BTW thanks for helping us debug this. Quote Link to comment Share on other sites More sharing options...
CulturedCait Posted 6 hours ago Author Report Share Posted 6 hours ago That was good suggestion. I placed as much "warns" as possible and discovered that in my OnInitGame trigger: Trigger.prototype.TestLearningStart = function() { warn("Init"); //zapytajmy czy jest plik startowy inicjalizujacy nasz algorytm wstepnymi entities itp let cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); cmpGuiInterface.PushNotification({ "type": "load-json", "players": [0], "name": "testlearning-last", "param": "init" }); warn("Init finish"); //this.TestLearningStartFromScratch(); } PushNotification sends the request without errors, but OnCommand never receives it. It is was clear that my custom message "load-json", which loads JSON file, is simply not being push further. This is my load-json msg: "load-json": function(notification, player) { warn("Received load-json"); let name = notification.name || "testlearning"; let data = null; if (Engine.FileExists("simulation/" + name + ".json")) data = Engine.ReadJSONFile("simulation/" + name + ".json"); Engine.PostNetworkCommand({ "type": "dialog-answer", "dialog": "json", "answer": { "param": notification.param, "data": data, }, }); warn("finished load-json"); }, And this is how I run the game with loading mod with customized "messages.js": $ pyrogenesis -mod="public" -mod="train" -autostart-victory="endless" -autostart="skirmishes/test_sparta" -autostart-disable-replay -quickstart -autostart-nonvisual Mod "train" contains just one single file with modified "messages.js". Since warning "Received load-json" never appears, we can be sure this message never hits in headless mode. So the only explanation is that under -autostart-nonvisual, custom "messages.js" coming from my mod is either ignored or, which is more likely, overlapped with different set of "messages.js" designated for -autostart-nonvisual. Since I need custom messages to communicate with some GUI APIs, I can't get rid of this pattern... I think it is not worth investigating further. I'm satisfied with my current solution as it is and although headless mode certainly could be nice improvement it is not that important for these type of calculations. Thank you again for your help. Quote Link to comment Share on other sites More sharing options...
Stan` Posted 4 hours ago Report Share Posted 4 hours ago Ah right, that makes some kind of sense since there is no GUI in non visual ... So probably nothing gets initialized and nothing listen to the messages 1 hour ago, CulturedCait said: I think it is not worth investigating further. I'm satisfied with my current solution as it is and although headless mode certainly could be nice improvement it is not that important for these type of calculations. Thank you again for your help. No problem, sorry we couldn't figure out a solution. I do believe that using the RL interface might be better in this case, since it should have a lot more access to the engine functions because you can send arbitrary js to the engine. The tickets hyperion mentioned above. https://gitea.wildfiregames.com/0ad/0ad/issues?q=autostart&type=all&state=all&labels=43 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.