Jump to content

agentx

Community Members
  • Posts

    276
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by agentx

  1. There is no problem loading a game, there is a problem continuing a loaded game. Does that distinction makes any sense? Anybody interested to repair the "Load Game" button?
  2. This is getting funny, how can an AI serialize events which are going to happen AFTER the game was loaded from file? Do you guys have a wormhole somewhere hidden? Or is the purpose of saved games not to continue playing after loading?
  3. Look, I said deserialization is not the problem. Even if an AI has properly deserialized past data, the API is not telling the AI what is happening, because there are no events. I can assure you simulation and UnitAI do properly work, each unit picks up the task it had before saving, that can be easily seen. But as said, there are no events, so if an enemy attacks, there are no attack and no destroy events and an AI loses all units without even knowing. AIs are blind and lost at this point. So again, what can be done to fill this huge API hole?
  4. That's not true and also not the issue. The problem with saved games is when OnUpdate() is called, all above mentioned essential objects are literally undefined rendering any AI meaningless. What is the fastest plan to make the API complete and functional?
  5. It seems the new API doesn't support saved games, there is no gamestate, no events, no passabilityMap and no territoryMap. At least to me this a complete show-stopper. What was the latest Alpha with an API featuring saved games?
  6. I'm testing asm.js with F30, here is a module it compiles, featuring 0 A.D. cos() implementation:HANNIBAL = (function(H){ H.ASM = (function(stdlib, foreign, heap) { "use asm"; var PI = 3.141592653589793, arr = new stdlib.Int8Array(heap), sqrt = stdlib.Math.sqrt, abs = stdlib.Math.abs; function cos (a){ a = +a; var b = 0.0, c = 0.0; a = (a + PI) % (2.0*PI); a = +abs((2.0*PI + a) % (2.0*PI) - PI); b = (a-PI/2.0) + +abs(a-PI/2.0); b = b / (b + +(1e-30)); // normalize b to one while avoiding divide by zero errors. a = b * PI - a; c = 1.0 - 2.0 * b; // sign of the output return +(c * (1.0 - a*a*(0.5000000025619951 - a*a*(1.0/24.0 - a*a*(1.0/720.0 - a*a*(1.0/40320.0 - a*a*(1.0/3628800.0 - a*a/479001600.0))))))); } function sin (a){ a = +a; return +(cos(a - PI/2.0)); } function distance (a0, a1, b0, b1){ a0 = +a0; a1 = +a1; b0 = +b0; b1 = +b1; var dx = 0.0, dy = 0.0; dx = +a0 - +b0; dy = +a1 - +b1; return +sqrt(dx * dx + dy * dy); } return { cos: cos, sin: sin, distance: distance }; }(window));return H; }(HANNIBAL));From there one might call H.ASM.cos(1.234). I'll report back, when I got a speed test running in 0AD and get map data into this module.
  7. > farm position. The groups keep track of their position. So far I use Aegis' findGoodPosition() feeded with that position. Keeping track depends on what's known, if there is a dropsite that pos has priority, otherwise the center of the units is taken. Missing is a logic which chooses a new position, if the foundation is destroyed immediately and repeatedly. But that's part of a more general problem. I want groups making claims on the map without actually building something. Think of a place for the army to exercise, where healers do their job, jobless units demonstrate , etc. Ontop that allows to structure the village a bit by claiming upfront good places for later defense towers or like I've seen recently in a MP with 4 fortresses close to a CC.
  8. That's right, just wanted to get rid of the black borders, at least here.
  9. First try: Team blue, game starts with 2 building and 2 units. At tick 1 and 2 a grain-picker group is launched requesting a dropsite first. Economy picks existing CC and assigns it. Having that the groups request 5 units. For the first group the economy picks the two idle, as they match the request, and trains 3 other. The second group gets 5 freshly trained units. With the first unit assigned, the groups request a field and start repairing once it was assigned. Gathering happens automatically by the units' AI. The video shows also how the groups auto-request new resources, when destroyed. I want the groups as self-sustaining as possible, what ever happens their mission is to gather. Next step is make them shelter from violence. How can I adjust width and height of video in the post's code?
  10. The 'Little Query Language' now has a web interface at http://noiv.pythonanywhere.com/agentx/0ad/explorer/hannibal.html To start click HCQ in the menu, choose an interesting node from the list and click 'analyse'. From there you can browse the triple store via the blue links. Also the planner makes progress: I've ported the python sources to JavaScript. Two tests are ready to try out. It seems a blocks world is the Hello World in terms of planning, so the examples define 3 blocks (a,b,c) and a table. The planner tries to find a list of actions moving the blocks from state to goal, see test2. The new JS module system has the advantage sources run in the web AND in 0 A.D. Very useful, this way I can use the browser to debug!!!! However, above site is only tested with FF30, don't tell me it doesn't run with IE , even Chrome doesn't support all ES6 features. I've started to document more of Hannibal in the wiki: http://trac.wildfiregames.com/wiki/HannibalBot check it out! Comments are welcome. Hannibal is making first baby steps, it can launch groups maintaining a field. Groups are coded with a high level bot language: I hope the semantics are self explaining. It really took some effort to make things that simple, well, now I understand why it takes a village to raise a child In case you're wondering, the idea is all other features are much faster and easier implemented using this (sigh) language. I have plenty of time this WE and hope I can finalize it with a video showing above code in action. Edit: this is a very interesting Google search: https://encrypted.google.com/search?num=100&q=site%3Ajsperf.com+%27use+asm%27 lots of asm.js code to checkout, some are very clever and fast.Edit2: links
  11. Sorry, was netbook only couple of days, so tested again, with this at the very beginning: var m = {};var o = {};m.num = num || 5;m.str = str || "abc";m.obj = obj || {};m.arr = arr || [];m.prp = o.prp || "xyz"; Only the last line produces no warning.
  12. It might be helpful to see an example, before jumping into conclusions. Although JS has no namespaces they can be implemented easily. 0 A.D loads AI files alphabetacally, but it is better to assume no order, otherwise renaming files leads to rewiring the boilerplate code, very annoying. A common pattern looks like this (taken from Hannibal): HANNIBAL = (function(H){ H.HTN = H.HTN || {}; // line L1 H.HTN.Blocks = H.HTN.Blocks || {}; // line L2 // code continuesLet's say this code sits in file b.js, H.HTN in file a.js and H.HTN.Blocks in c.js. So in line 1 the left part is taken and in line 2 the right part. Sweet, convenient and failsafe. However, now this produces a warning. To avoid that one might write: HANNIBAL = (function(H){ H.HTN = (H.HTN !== undefined) ? H.HTN : {}; // line L1 H.HTN.Blocks = (H.HTN.Blocks !== undefined) ? H.HTN.Blocks || {}; // line L2 // code continuesComing from browser hosted JS, I also had in in mind undefined might be anything, but apparently "use strict" makes undefined read-only, and that IS a good thing. All discussed here: http://www.kenneth-truyers.net/2013/04/27/javascript-namespaces-and-modules/ Another example are user facing functions with a variable length of arguments. economy = { request: function(/* arguments: [amount,] resource [,locResource] */){ // ....locResource is given in case a building is requested and not in case of a unit. So the next function world be happy if called with locResource === undefined, but that doesn't work either. Edit: words
  13. You seem to have a lot time if you wait for these kind of errors popping up at compile time.
  14. Ok, then all the warnings I get will be removed soon?
  15. Impressive job! JavaScript now with Set, Map, WeakMap, fat arrows and more. SM 31 will probably bring array comprehensions. Only nitpick are the new warnings with "reference to undefined property". It is a common pattern to exit loops by testing against undefined, no warnings needed.
  16. Actually it might be even Japanese what I've seen in Google's result list around the hit. I'm not an expert in Asian languages. I wish I had the time to learn one. It would be Burmese, I love the symbols. Yeah, more bots please. I'll check Petra this weekend, seems like Aegis sources have some potential. Don't fear JS! It is such a little dirty language. Once you learned not to use the, ummh, bad parts it is fun. >asynchronous affairs: Have you found the entrance to callback hell? Btw, I've solved the resource flow math, it is just a ringbuffer and a simple linear regression, very cute.
  17. Improve your Chinese http://casperise.com:81/casper/cocosino/raw/8532c58fddd659e2dc4f757dd656ee704cd3fb67/cocos2dx/scripting/javascript/bindings/ScriptingCore.cpp
  18. Yes: https://github.com/cocos2d/cocos-docs/blob/master/manual/framework/native/scripting/javascript/js-remote-debugger/en.md
  19. I've tried to understand the SciptInterface C++ code in 0AD, but I'm far away from understanding what's going on. Let aside the changes you've mentioned. Apparently it is now possible to connect a gdb? Not sure whether this provides JS variable inspection. What I understand very well is your proposal to connect the firefox debugger to 0AD and start JS remote debugging, like with an Android device. That's the no questions left solution. Is it more than a dream? I'm not especially fond of every feature introduced in upcoming EcmaScripts. The modules rationales are rather unspecific, the performance impact unknown and whether IonMonkey can deal with a cloudy issue. So far it looks like the only gain are a few bytes per file. It may take a long time until third party AI modules are ready to plugin in via this extension. However, there is a notable exception: fat arrows. (() => "Hello World")() // try in browser's consoleWill they land in Alpha 16?
  20. I have two proposals regarding A* in terrain-analysis-pathfinder.js: Inside the main while loop, values should not get fetched via 'this.' because there is an existence test behind and the ternary (? performs better than 'if/then' if branching is not intended. Estimated improvement >50%. I haven't seen all maps, maybe a bi-directional A* would help too.
  21. Do I have to change from this module pattern? It is excellent! HANNIBAL = (function(H){// do stuff with Hreturn H; }(HANNIBAL));And what is the issue with the debugger? It might save me some time, so if there is anything I can do except compiling, let me know.
  22. Which tool is good for capturing on Windows XP?
  23. > make a video How do you guys make youtube videos?
  24. @sander A culture DB on the native side would be great. Usually the result sets are not that huge, just a few records. Let me expand the example of grain picker above: units: [5, "food.grain GATHEREDBY WITH costs.metal = 0, costs.stone = 0, costs.wood = 0 SORT < costs.food"],From the point of the group it only cares whether the units CAN gather food.grain. It doesn't care if they are soldiers, females, slaves, what ever. It is up to the economy to find out what is currently cheapest. First it has to find out how to deliver what the group requested. So it runs the query and gets a list of templates, then it checks whether there are entities in the game not occupied by other groups matching these templates. Let's say the result is: "units.athen.support.female.citizen", checking in game is easy, just append verb + filter and run again: "units.athen.support.female.citizen INGAME WITH metadata.group = ''". If there are results, then the unit IDs are included and all left is assigning the units to the group. In the case of no in game units, the economy first has to check requirements (technology) the query is "units.athen.support.female.citizen REQUIRE". If that returns nothing next step is to find out how to produce the requested resource. The economy doesn't know a thing at this point whether these are units, technologies or structures. So it runs 3 queries: units.athen.support.female.citizen TRAINEDBY INGAMEunits.athen.support.female.citizen BUILDBY INGAMEunits.athen.support.female.citizen RESEARCHEDBY INGAMEto find out structures.athen.civil.centre is a candidate, is in the game and the engine command to produce them is "train". Basically the economy reads every tick its list of requests and checks what can be done using the query language and fires the according engine commands. It is an easy process and just requires to build proper queries using string operations. A query like : "units.athen.support.female.citizen TRAINEDBY INGAME" runs in virtually no time, because it starts with one node only and checks just a handful edges. If "TRAINEDBY" returns nothing, "INGAME" doesn't even need to run. So, yes there are probably are a lot of queries per tick. The crucial thing is whether they query in game objects or only the template space. Don't know how this could be done on native side. Also the query would need translation into SQL, which may open another can of worms because fast and simple triple store queries may lead to heavy SQL queries. More obstacles come to my mind, I think, I can make a better proposal once the bot knows a bit more than cropping.
  25. The language keeps evolving, in game entities are now linked too. Speed-wise, I figure, it is enough to load the bot's own civilisation only. Critical loops now run as while(){}, and most queries are below 1 msec, which is fine. And as long as in game entities are not involved queries are perfectly cachable. There are two other advantages of the query language: It moves domain knowledge from code to config and since it is based on a triple store it opens door to run a backward chaining inference engine, where the bot designer sets goals and the bot tries to achieve them. But that will take some time to implement. Currently I'm working on the autonomous groups, the grain-picker use these resources: units: [5, "food.grain GATHEREDBY WITH costs.metal = 0, costs.stone = 0, costs.wood = 0 SORT < costs.food"],field: [1, "food.grain PROVIDEDBY"], refuge: [1, "<units> HOLDBY CONTAIN distance < 100"],Works quite nice so far, I think I make a video once garrison looks a bit more coordinated.
×
×
  • Create New...