ramtzok1 Posted April 17, 2019 Report Share Posted April 17, 2019 Hello, You may remember me from past threads related to implementing ML on 0 A.D. We made huge progress since last thread. I'm now trying to compare old PETRA and our new PETRA to see if there are any improvements and I can't figure out how to make it right. What I tried: 1. I created a new folder called PetraML and copy and pasted all the files of PETRA. 2. I edited the file data.json where the name of PETRA is: PetraML. The description is different from the old PETRA. The moduleName is now "PETRAML" and the constructor is now "PetraBotML" 3. I changed on every file in PetraML where: var PETRA = function(m) is now: var PETRAML = function(m) 4. I changed on every file in PetraML where: }(PETRA); is now: }(PETRAML); 5. I changed on _petrabot.js from: m.PetraBot = function PetraBot(settings) to: m.PetraBotML = function PetraBotML(settings) I don't know what to look for more than that. I'm getting errors from the game when I trying to make a game (Picture attached). Can anyone help me solve this? thank you! Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 17, 2019 Report Share Posted April 17, 2019 The first step would be to look the interestinglog.html file in %localappdata%/0ad/logs and see whats the root cause Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted April 17, 2019 Report Share Posted April 17, 2019 Likely InterestingLog would output exactly what is in that screenshot Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 17, 2019 Author Report Share Posted April 17, 2019 29 minutes ago, stanislas69 said: The first step would be to look the interestinglog.html file in %localappdata%/0ad/logs and see whats the root cause 9 minutes ago, wowgetoffyourcellphone said: Likely InterestingLog would output exactly what is in that screenshot Good to know this file exists :), however, I already looked up the errors it seems like it can't load the data from data.json, I can't figure out what is going on. Here's data.json { "name": "PetraML", "description": "PetraML is our work for a project about machine learning.", "moduleName" : "PETRAML", "constructor": "PetraBotML", "useShared": true } I tried to go deep into the cpp where GetAIs is called in the file "settings.js" line 101 but I can't understand what is wrong, the code seems to have no problem getting the file. I don't know what else to attach or say in order to help you understand the cause. Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 17, 2019 Report Share Posted April 17, 2019 Can you attach you mod to this topic ? I might have an idea when looking at the code. Maybe it's just a folder name mismatch Quote Link to comment Share on other sites More sharing options...
elexis Posted April 17, 2019 Report Share Posted April 17, 2019 13 minutes ago, ramtzok1 said: I tried to go deep into the cpp where GetAIs is called in the file "settings.js" line 101 but I can't understand what is wrong, the code seems to have no problem getting the file. It says b.data.name is undefined, which sounds like the json is broken, but your JSON looks fine. Perhaps that sort function has always been broken and noone noticed because noone tried two AIs? Try warn(uneval(Engine.GetAIs())); then you can see the return value and perhaps deduce more. Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 17, 2019 Author Report Share Posted April 17, 2019 10 minutes ago, elexis said: It says b.data.name is undefined, which sounds like the json is broken, but your JSON looks fine. Perhaps that sort function has always been broken and noone noticed because noone tried two AIs? Try warn(uneval(Engine.GetAIs())); then you can see the return value and perhaps deduce more. Already tried that :/, the second I run the game it crashes. I debugged where the crash is and it is inside of stdio.h. function loadAIDescriptions() { warn(uneval(Engine.GetAIs())); var ais = Engine.GetAIs(); translateObjectKeys(ais, ["name", "description"]); return ais.sort((a, b) => a.data.name.localeCompare(b.data.name)); } This compare is very important to our project because this what we have worked for this whole year. We have to know if we did improve PETRA with machine learning... Quote Link to comment Share on other sites More sharing options...
elexis Posted April 17, 2019 Report Share Posted April 17, 2019 Then investigate only parts of the object. Test if it's an array. If it is, test the first element, etc. warn(typeof Engine.GetAIs()); warn(Engine.GetAIs()[0].data); warn(Object.keys(Engine.GetAIs()[0])); etc. Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 17, 2019 Author Report Share Posted April 17, 2019 18 minutes ago, elexis said: Then investigate only parts of the object. Test if it's an array. If it is, test the first element, etc. warn(typeof Engine.GetAIs()); warn(Engine.GetAIs()[0].data); warn(Object.keys(Engine.GetAIs()[0])); etc. warn(Engine.GetAIs()[0].data.toSource()); // BadBot - Our first ever bot warn(Engine.GetAIs()[1].data.toSource()); // Petra warn(Engine.GetAIs()[2].data.toSource()); // Crashes warn(uneval(Engine.GetAIs()[2].data)); // Crashes warn(Engine.GetAIs([2]).id); // Undefined warn(Object.keys(Engine.GetAIs()[0])); // data, id warn(Object.keys(Engine.GetAIs()[1])); // data, id warn(Object.keys(Engine.GetAIs()[2])); // Doesn't crash - data, id This is what I have found. I think I will head back to the GetAIs CPP function. I can't determine what causes it to be undefined. Quote Link to comment Share on other sites More sharing options...
elexis Posted April 17, 2019 Report Share Posted April 17, 2019 warn(Engine.GetAIs().length); Does [2] actually exist? It sounds like there is some broken directory, or some "unassigned" placeholder item or something. If the ReadJSONFile call in C++ fails, it should handle that in a somehow sane way, probably report it with a readable error. Edit: What's the result of warn(Object.keys(Engine.GetAIs()[2])); // Doesn't crash - data, id 1 Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 18, 2019 Author Report Share Posted April 18, 2019 14 hours ago, elexis said: warn(Engine.GetAIs().length); Does [2] actually exist? It sounds like there is some broken directory, or some "unassigned" placeholder item or something. If the ReadJSONFile call in C++ fails, it should handle that in a somehow sane way, probably report it with a readable error. Edit: What's the result of warn(Object.keys(Engine.GetAIs()[2])); // Doesn't crash - data, id I managed to solve the problem! After a deep understanding, what does GetAIs it's looking for every json file in the directory simulation/ai and part of my communication between the game and the machine learning module I'm using a json file to send units to the ML (It is loaded with all the possible fighting units. Huge file). The game picks it as part of AI and tries to load it, that's why it fails. Thank you so much for your help! I really appreciate that! 1 Quote Link to comment Share on other sites More sharing options...
coworotel Posted April 18, 2019 Report Share Posted April 18, 2019 15 hours ago, elexis said: noone noticed because noone tried two AIs? I've tried, this works fine. 1 Quote Link to comment Share on other sites More sharing options...
elexis Posted April 18, 2019 Report Share Posted April 18, 2019 10 minutes ago, ramtzok1 said: GetAIs it's looking for every json file in the directory Shet, I've come across this problem before too! It should only look for data.json! This vfs::ForEachFile(g_VFS, L"simulation/ai/", Callback, (uintptr_t)this, L"*.json", vfs::DIR_RECURSIVE); should be Quote vfs::ForEachFile(g_VFS, L"simulation/ai/", Callback, (uintptr_t)this, L"data.json", vfs::DIR_RECURSIVE <- NOT); or similar. Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 18, 2019 Report Share Posted April 18, 2019 @ramtzok1 Btw how did it go with the Fork AD developers did you get answer for all your questions ? Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 18, 2019 Author Report Share Posted April 18, 2019 46 minutes ago, stanislas69 said: @ramtzok1 Btw how did it go with the Fork AD developers did you get answer for all your questions ? I tried to contact them via the IRC but they never answered back. 1 Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 18, 2019 Report Share Posted April 18, 2019 4 minutes ago, ramtzok1 said: I tried to contact them via the IRC but they never answered back. Oh okay, sorry about that. You can still ask questions here then we'll do our best to answer them. 1 Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 18, 2019 Author Report Share Posted April 18, 2019 17 hours ago, stanislas69 said: Can you attach you mod to this topic ? I might have an idea when looking at the code. Maybe it's just a folder name mismatch I now noticed I missed your comment, sorry for that... Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 18, 2019 Report Share Posted April 18, 2019 6 minutes ago, ramtzok1 said: I now noticed I missed your comment, sorry for that... Its okay Glad you solved it ! Quote Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2019 Report Share Posted April 18, 2019 34 minutes ago, ramtzok1 said: I tried to contact them via the IRC but they never answered back. When exactly was this? Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 18, 2019 Author Report Share Posted April 18, 2019 1 minute ago, (-_-) said: When exactly was this? Before two months when we just started reading PETRA and leaving the idea to develop our own bot. Quote Link to comment Share on other sites More sharing options...
Guest Posted April 18, 2019 Report Share Posted April 18, 2019 Nothing in the logs, that's why I asked. The only mention of your name was a in a "join" message and a "leave" one. Anyway, I guess you got your answers. Quote Link to comment Share on other sites More sharing options...
fatherbushido Posted April 18, 2019 Report Share Posted April 18, 2019 (edited) 53 minutes ago, ramtzok1 said: I tried to contact them via the IRC but they never answered back. Can you please revert this statement. I provide you answers in PM. You and/or your mate connect to irc. We answered the questions you asked us. I am very disappointed. Edited April 18, 2019 by fatherbushido answer -> answered Quote Link to comment Share on other sites More sharing options...
ramtzok1 Posted April 18, 2019 Author Report Share Posted April 18, 2019 (edited) 1 hour ago, fatherbushido said: Can you please revert this statement. I provide you answers in PM. You and/or your mate connect to irc. We answered the questions you asked us. I am very disappointed. Excuse me for not mentioning you, you did help via PM. I didn't mean to hurt anybody, you did help me, every one of you did. I can't remember exactly and also my partner about the irc, what happened there if any, a lot has changed since I appeared on your forums for the first time and really, thank you for everything. @(-_-) @fatherbushido @stanislas69 @elexis @Imarok I don't take any credit of solving my problems by myself. You did a lot of the job pointing me to the right direction. Edited April 18, 2019 by ramtzok1 For some reason I wrote "did not" O_o Quote Link to comment Share on other sites More sharing options...
fatherbushido Posted April 18, 2019 Report Share Posted April 18, 2019 no problem ;-) 2 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.