agentx Posted May 15, 2014 Report Share Posted May 15, 2014 This is a little Hannibal spin-off, a bot which does nothing except logging some stats about other players. Currently it uses print() and dbgView is one way of capturing the output. It probably needs some cleansing by hand. It should look like this:time;id;name;civ;phase;food;wood;stone;metal;tresaure;unitsLost;unitsTrai;bldgsCons;bldgsLost;techs;popcnt;popcap;popmax;explored;kills0.6;1;Player 1;brit;village;300;300;300;300;0;0;0;0;0;2;9;20;300;8;00.6;2;Cleopatra Selene;ptol;village;300;300;300;300;0;0;0;0;0;1;9;20;300;8;02.2;1;Player 1;brit;village;300;300;300;300;0;0;0;0;0;2;9;20;300;8;02.2;2;Cleopatra Selene;ptol;village;300;300;300;300;0;0;0;0;0;1;9;20;300;8;03.8;1;Player 1;brit;village;300;300;300;300;0;0;0;0;0;2;9;20;300;8;03.8;2;Cleopatra Selene;ptol;village;250;300;300;300;0;0;0;0;0;1;10;20;300;8;05.4;1;Player 1;brit;village;300;300;300;300;0;0;0;0;0;2;9;20;300;8;05.4;2;Cleopatra Selene;ptol;village;200;300;300;300;0;0;0;0;0;1;10;20;300;8;07.0;1;Player 1;brit;village;300;300;300;300;0;0;0;0;0;2;9;20;300;8;07.0;2;Cleopatra Selene;ptol;village;150;300;300;300;0;0;0;0;0;1;10;20;300;8;0More columns can be easily included, the attached code gives a few hints what else is available. I use an IPython Notebook to analyze the data, it is here: http://nbviewer.ipython.org/url/dl.dropboxusercontent.com/u/354885/notebooks/Numerus.ipynbAnd that's me playing against another bot:numerus.zip 3 Quote Link to comment Share on other sites More sharing options...
Radagast. Posted May 16, 2014 Report Share Posted May 16, 2014 Awesome, do you think it's possible performancewise to plot it ingame as 'realtime' statistics somewhere in the GUI? 1 Quote Link to comment Share on other sites More sharing options...
agentx Posted May 16, 2014 Author Report Share Posted May 16, 2014 Awesome, do you think it's possible performancewise to plot it ingame as 'realtime' statistics somewhere in the GUI?Don't know, haven't investigated the GUI system yet. But in principle, I'd say yes, it is only a few numbers per second, thus only a few pixel to draw. But you are the master of mod! In any case, I think it'd be worth the effort, especially new comers appreciate to know where exactly the opponent is performing better. On the other hand, having live stats from your enemy is close to cheating, right?At second thought, at least on Linux it should be possible to live capture Numeris' output and draw it onto a separate window/canvas. This looks like a good starting point: http://www.tutorialspoint.com/python/tk_canvas.htmMmh, going that route, a 0 A. D. launcher is pretty close, something where one selects mod, ai, map, etc. and get live stats in return, well, no fullscreen then.Do you speak Python? Quote Link to comment Share on other sites More sharing options...
leper Posted May 16, 2014 Report Share Posted May 16, 2014 Any reason why you didn't extend the StatisticsTracker component to do this? Quote Link to comment Share on other sites More sharing options...
agentx Posted May 16, 2014 Author Report Share Posted May 16, 2014 Any reason why you didn't extend the StatisticsTracker component to do this?No, it is just I have no clue how components work, I'm already lost at the prototype.Schema line. Can it be used to draw pixels instead of numbers? Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted May 16, 2014 Report Share Posted May 16, 2014 No, the components just do the simulation part. For the drawing, you must look into the gui.The components work quite simply, in an object oriented way, and the schema is just an xml definition used for the entities. Quote Link to comment Share on other sites More sharing options...
agentx Posted May 16, 2014 Author Report Share Posted May 16, 2014 No, the components just do the simulation part. For the drawing, you must look into the gui.So, adding a tab and drawing pixels involves compiling? Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted May 16, 2014 Report Share Posted May 16, 2014 The gui is also scripted, but the engine is made towards drawing rectangles with textures and text, so I don't really know if you can draw per pixel in an efficient way. Quote Link to comment Share on other sites More sharing options...
agentx Posted May 16, 2014 Author Report Share Posted May 16, 2014 The gui is also scripted, but the engine is made towards drawing rectangles with textures and text, so I don't really know if you can draw per pixel in an efficient way.Well, let's say pixels are very little rectangles and graphic stats appear only at game end, so no cheating and no efficiency headache. StatisticsTracker could possibly be extended to store all its data in an growing array with time stamp. Apparently the GUI can already ask StatisticsTracker for numbers and draw them. Where does that happen? Deep links, please Quote Link to comment Share on other sites More sharing options...
agentx Posted May 21, 2014 Author Report Share Posted May 21, 2014 > The gui is also scripted...Just found out the GUI hot loads on script changes, that's simply crazy. Can someone please tell Mozilla and Google how that works. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted May 22, 2014 Report Share Posted May 22, 2014 Right, deep links. Sorry for being so late. The statistics tracker: http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/StatisticsTracker.js This is a component per player. And at the end of each game, the Gui queries the GetStatistics for every player. That returns just a JS object. Currently it only contains the totals, but you can make the object as complicated as you want. The gui: http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/gui/summary Well, as I said, now it only displays numbers. I've got no idea how hard it will be to make graphs. 1 Quote Link to comment Share on other sites More sharing options...
agentx Posted May 22, 2014 Author Report Share Posted May 22, 2014 Thx, I think I spend the tracker a timer, but would prefer it get called on tick, any idea? Re GUI/XML, is there a way to create <objects> on the fly with JS and set size, width, height? Also where are the II_xxxx constants defined, searched all code to no success. I have already a chart panel, will make there subpanels per metric and use many little coloured dot objects per player.Like it? Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted May 22, 2014 Report Share Posted May 22, 2014 I don't think you can add Object tags on the fly. You can edit their size on the fly though. Not sure what you want with the tracker. You can listen to the OnUpdate message to get executed every tick. But that would cause huge objects (those objects are also send to the lobby server when a game is finished). I think listening to the separate actions, and getting the time from the Timer component would help. And what constants do you mean? Do you have a code example of where they are used? Quote Link to comment Share on other sites More sharing options...
agentx Posted May 22, 2014 Author Report Share Posted May 22, 2014 I don't think you can add Object tags on the fly. You can edit their size on the fly though.Ummh, that would make a few thousand objects hand edited, are you sure...? Quote Link to comment Share on other sites More sharing options...
Radagast. Posted May 22, 2014 Report Share Posted May 22, 2014 Hephaestion looks around and wonders if he is dreaming or seeing a chart in 0AD.We could somehow generate those objects in a generator (like your webpage for Hannibal) and copy it over. Not ideal, but better than by hand.Do you need to pop up a panel/page too? PostPage I think is the command. In comparison to SwitchPage which changes the major page. (I hope that's right but I'm not sure anymore. Anyway, I think you already pretty awesomely solved it.) Quote Link to comment Share on other sites More sharing options...
thamlett Posted May 23, 2014 Report Share Posted May 23, 2014 * is glad that this project is so well underway. He wishes that it could also be in a real-time window, so that it could conceivably show up on his second monitor. Quote Link to comment Share on other sites More sharing options...
agentx Posted May 23, 2014 Author Report Share Posted May 23, 2014 > seeing a chart in 0ADUnfortunately it is still a chart in Gimp. Generating the <objects> is a good idea and feasible. But has anybody experience if the UI can manage 8 players * 10 metrics * 100 dots? Actually I'd prefer rounded dots not squares, so these are in fact images. Do PNGs with alpha channel work?> listen to the OnUpdate messageI want to use the tracker, because the numbers are already there. How do I make it listen to the OnUpdate message? All the stats may amount to a few kilo bytes, is that of concern?Here is an II_xxxx example:var cmpUnitEntityIdentity = Engine.QueryInterface(trainedUnit, IID_Identity);Btw: anybody keen on thinking of the priorities of the metrics? What is a must have? Is units top?// found in StatisticsTracker.js, there is more...unitsTrainedunitsLostunitsLostValueenemyUnitsKilledenemyUnitsKilledValuebuildingsConstructedbuildingsLostbuildingsLostValueenemyBuildingsDestroyedenemyBuildingsDestroyedValueresourcesGatheredresourcesUsedresourcesSoldresourcesBoughttributesSenttributesReceivedtradeIncometreasuresCollectedpercentMapExplored Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted May 23, 2014 Report Share Posted May 23, 2014 I said that the graph would be the most difficult thing. You'll have to add a new sort gui object, a graph, that accepts coordinate pairs and draws lines. That new object would have to be defined in c++.For the OnUpdate message, just create a method in the statTracker's prototype with that name. Methods starting with On are always recognised as message handlers by the Engine.And the IID_interface comes from components/interfaces. Registering an interface creates that global. Quote Link to comment Share on other sites More sharing options...
agentx Posted May 23, 2014 Author Report Share Posted May 23, 2014 Thx, excellent infos, should put me on the right track. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 25, 2014 Report Share Posted May 25, 2014 The GUI scripting reference might be helpful. The only feasible way to do a graph with the current system would be by using the <repeat> element with some size manipulations similar to what options.js does during initialization. That said; at best the graph drawing code would be a mess. The best solution would be a C++ extension, but if you aren't familiar with C++ this might work in the mean time. 2 Quote Link to comment Share on other sites More sharing options...
agentx Posted May 25, 2014 Author Report Share Posted May 25, 2014 Screenshot taken from 0 A.D.It's fake data, but png with alpha works, also the metric menu. Credit goes to Josh and <repeat>. Quote Link to comment Share on other sites More sharing options...
Radagast. Posted May 27, 2014 Report Share Posted May 27, 2014 wow, that's coming along great. (though I wonder that you use the old buttons, I thought they were grey now .. )* is glad that this project is so well underway. He wishes that it could also be in a real-time window, so that it could conceivably show up on his second monitor.I think it was decided that having it ingame should be avoided due to performance + cheating in multiplayer. Though there might be workarounds and the performance impact is not certain too. Quote Link to comment Share on other sites More sharing options...
agentx Posted May 27, 2014 Author Report Share Posted May 27, 2014 > that you use the old buttonsStill on A15, because I figured I need to switch to dev on Linux because of better testing, stdout and such. So the charts are postponed a bit. May be you have the time to make a quick mod test on A16? You can switch metrics and toggle player on/off. Would need feedback whether GUI handling is OK. And I need an idea to nicely highlight the active metric in the menu....charts-02.zip Quote Link to comment Share on other sites More sharing options...
Radagast. Posted May 27, 2014 Report Share Posted May 27, 2014 thx man, working like a charm, though there are undefined values the charts show up:Charts.action: undefined, undefinedshowMetric: Units, p: 1, vis: trueshowMetric: Units, p: 2, vis: trueshowMetric: Units, p: 3, vis: trueshowMetric: Units, p: 4, vis: falseshowMetric: Units, p: 5, vis: falseshowMetric: Units, p: 6, vis: falseshowMetric: Units, p: 7, vis: falseshowMetric: Units, p: 8, vis: false Quote Link to comment Share on other sites More sharing options...
thamlett Posted May 28, 2014 Report Share Posted May 28, 2014 * wonders if graphs in 0 A. D. might be useful* quickly decides in the affirmative! 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.