Jump to content

ramtzok1

Community Members
  • Content Count

    35
  • Joined

  • Last visited

Community Reputation

9 Neutral

About ramtzok1

  • Rank
    Discens

Recent Profile Visitors

134 profile views
  1. Hi again!, I'm ram's partner and I was sitting on this now a bit more now. I had 2 questions in mind: 1.Wouldn't the second condition be always true? what is the first inital value of lastReadTime anyway? 2.When does the army.update func runs? How can we be sure it coincides with our editings to the Defense Manager itself? Thanks a lot!
  2. You got my attention, I want to know more about this function. Can you please give me more details on where it is located? I couldn't find it in the code. I will try what you said and come back if I still get stuck, I also looked for the second function and couldn't find something with that name or references like: looking for "Last" or "Time" I also tried to look into any "scripting" folder, perhaps I missed it?
  3. That's right. So if I understand correctly, I need to move my sendDataToML and getMLData functions to defenseArmy, there, inside m.DefenseArmy.prototype.update after the for-loop I guess I send the army and getting the probability from the ML? If so, I still run into the problem, the game stuck waiting for an answer. I don't fully understand what do you mean.
  4. For your request here's some more information: We are overriding the functions AssignDefenders and NeedsDefenders so if you compare between our PetraML and the regular Petra m.DefenseManager.prototype.assignDefenders = function(gameState) { if (!this.armies.length) return; let armiesNeeding = []; // let's add defenders for (let army of this.armies) { this.sendDataToML(gameState, army); let needsDef = this.getMLData(); if (needsDef > 0.8) continue; let armyAccess; for (let entId of army.foeEntities) { let ent = gameState.getEntityById(entId); if (!ent || !ent.position()) continue; armyAccess = m.getLandAccess(gameState, ent); break; } if (!armyAccess) API3.warn(" PETRAML error: attacking army " + army.ID + " without access"); army.recalculatePosition(gameState); armiesNeeding.push({ "army": army, "access": armyAccess, "need": needsDef }); } if (!armiesNeeding.length) return; // Ram: DON'T DELETE THAT. // It helps us to gather our fighting units. // let's get our potential units let potentialDefenders = []; gameState.getOwnUnits().forEach(function(ent) { if (!ent.position()) return; if (ent.getMetadata(PlayerID, "plan") == -2 || ent.getMetadata(PlayerID, "plan") == -3) return; if (ent.hasClass("Support") || ent.attackTypes() === undefined) return; if (ent.hasClass("Catapult")) return; if (ent.hasClass("FishingBoat") || ent.hasClass("Trader")) return; if (ent.getMetadata(PlayerID, "transport") !== undefined || ent.getMetadata(PlayerID, "transporter") !== undefined) return; if (gameState.ai.HQ.victoryManager.criticalEnts.has(ent.id())) return; if (ent.getMetadata(PlayerID, "plan") !== undefined && ent.getMetadata(PlayerID, "plan") != -1) { let subrole = ent.getMetadata(PlayerID, "subrole"); if (subrole && (subrole == "completing" || subrole == "walking" || subrole == "attacking")) return; } potentialDefenders.push(ent.id()); }); let i = 0; for (let aMin = 0; aMin < armiesNeeding.length; aMin++) { let potentialEntity; i = 0; this.sendDataToML(gameState, armiesNeeding[aMin]); let winningPetential = this.getMLData(); if(winningPetential >= 0.8) { armiesNeeding.splice(aMin, 1); continue; } let potentialID = 0; while(winningPetential < 0.8 && potentialDefenders.length >= potentialID) { if(potentialDefenders[potentialID] === undefined) continue; potentialEntity = gameState.getEntityById(potentialDefenders[i]); let currDist = API3.SquareVectorDistance(potentialEntity.position(), armiesNeeding[a].army.foePosition); // Gets the current distance between the potential dif and army if(currDist > 40000) continue; armiesNeeding[aMin].addOwn(potentialDefenders[potentialID]); armiesNeeding[aMin].army.assignUnit(gameState, potentialDefenders[potentialID]); this.sendDataToML(gameState, armiesNeeding[aMin].army); potentialDefenders[potentialID] = undefined; potentialID++; winningPetential = this.getMLData(); } if(winningPetential >= 0.8) armiesNeeding.splice(aMin, 1); if(!armiesNeeding.length) { API3.warn("Everything is assigned!"); return; } if(potentialID >= potentialDefenders.length) { API3.warn("Out of defenders!"); break; } } // If shortage of defenders, produce infantry garrisoned in nearest civil centre let armiesPos = []; for (let a = 0; a < armiesNeeding.length; ++a) armiesPos.push(armiesNeeding[a].army.foePosition); gameState.ai.HQ.trainEmergencyUnits(gameState, armiesPos); }; now the variable needsDef has to be assigned to the probability because then we can't decide what to do with enemy's attack. Do you still believe checking every 5 turns is still a good idea (I can't remember how much is a turn maybe 20ms?)? I'm not sure if making property is the best because we are talking about the chance of each army.
  5. Hello again! As part of my ML project, I'm trying to read a txt file which contains a chance of PetraML to win the fight, now on the machine learning which is written in Python it calculates the possibility and returns it as a txt file as I mentioned and I'm trying the following code: m.DefenseManager.prototype.getMLData = function() { warn("asdasdasdasdasdasd"); while (true) { if(Engine.FileExists("simulation/ai/petraML/mlData/answer.txt")) break; } warn("asdasdasdasdasdasd546545645665"); let chance = parseFloat(Engine.ReadFile("simulation/ai/petraML/mlData/answer.txt")); Engine.AppendToBuffer("a"); Engine.WriteToFile("simulation/si/petraML/mlData/gameState.txt"); return chance; }; The problem is the function is getting stuck inside the while true look, I looked inside Engine.FileExists function and found out it returns true the whole time but the game is still calling it for some reason. Why do you need that?: The ML receives a file loaded with the units and calculates the possibility to win and return it as an answer.txt file and in the meantime, this function is waiting for the file to arrive but as I said it's getting stuck there. Is there a way to make this kind of loop? I need a way to transfer the data between the module and the game while the AI is waiting for an answer to come. Thanks in advance!
  6. 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.
  7. Before two months when we just started reading PETRA and leaving the idea to develop our own bot.
  8. I now noticed I missed your comment, sorry for that...
  9. I tried to contact them via the IRC but they never answered back.
  10. 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!
  11. 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.
  12. 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...
  13. 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.
  14. 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!
×
×
  • Create New...