Leaderboard
Popular Content
Showing content with the highest reputation on 2014-02-18 in all areas
-
2 points
-
My first question was what objects the bot might use, so here is 'global' the equivalent of 'window' in a browser environment.logObject(global); Accessibility: function Accessibility() {"use strict";} ... AssocArraytoArray: function AssocArraytoArray(assocArray) {"use strict";var end ... BaseAI: function BaseAI(settings) {"use strict";if (!settings) {retu ... Class: function Class(data) {"use strict";var ctor;if (data._init) ... DoesModificationApply: function DoesModificationApply(modification, classes) {"use ... Engine: OBJECT (ProfileStart, ProfileStop, IncludeModule, DumpHeap, ForceGC, ...)[8] Entity: (function (sharedAI, entity) {"use strict";this._super.call( ... EntityCollection: function EntityCollection(sharedAI, entities, filters) {"use ... EntityTemplate: (function (template, techModifications) {"use strict";this._ ... Filters: OBJECT (byType, byClass, byClassesAnd, byClassesOr, byMetadata, ...)[27] GameState: (function () {"use strict";this.ai = null;this.cellSize = 4; ... GetTechModifiedProperty: function GetTechModifiedProperty(currentTechModifications, e ... ManhattanDistance: function ManhattanDistance(a, {"use strict";var dx = a[0] ... Map: function Map(sharedScript, originalMap, actualCopy) {"use st ... Memoize: function Memoize(funcname, func) {"use strict";return functi ... MemoizeInit: function MemoizeInit(obj) {"use strict";obj._memoizeCache = ... PickRandom: function PickRandom(list) {"use strict";if (list.length === ... PlayerID: NUMBER (1) Resources: function Resources(amounts, population) {"use strict";if (am ... ShallowClone: function ShallowClone(obj) {"use strict";var ret = {};for (v ... SharedScript: function SharedScript(settings) {"use strict";if (!settings) ... SquareVectorDistance: function SquareVectorDistance(a, {"use strict";var dx = a ... TERRITORY_PLAYER_MASK: NUMBER (63) Technology: function Technology(allTemplates, templateName) {"use strict ... TerrainAnalysis: function TerrainAnalysis() {"use strict";this.cellSize = 4;} ... VectorDistance: function VectorDistance(a, {"use strict";var dx = a[0] - ... aStarPath: function aStarPath(gameState, onWater, disregardEntities, ta ... copyPrototype: function copyPrototype(descendant, parent) {"use strict";var ... deepcopy: function deepcopy() {[native code]} ... error: function error() {[native code]} ... g_FoundationForbiddenComponents: OBJECT (ProductionQueue, ResourceSupply, ResourceDropsite, GarrisonHolder, ...)[4] g_ResourceForbiddenComponents: OBJECT (Cost, Decay, Health, UnitAI, UnitMotion, ...)[6] global: OBJECT (global, Engine, print, log, warn, ...)[49] inRange: function inRange(a, b, range) {"use strict";if (a === undefi ... log: function log() {[native code]} ... print: function print() {[native code]} ... warn: function warn() {[native code]} ...That already gives a hint on the rich API 0 A.D. provides. Engine looks interesting: logObject(Engine): DumpHeap: function DumpHeap() {[native code]} ... DumpImage: function DumpImage() {[native code]} ... ForceGC: function ForceGC() {[native code]} ... IncludeModule: function IncludeModule() {[native code]} ... PostCommand: function PostCommand() {[native code]} ... ProfileStart: function ProfileStart() {[native code]} ... ProfileStop: function ProfileStop() {[native code]} ... RegisterSerializablePrototype: function RegisterSerializablePrototype() {[native code]} ...It turns out the API functions and objects are either provided by the host environment/SpiderMonkey [warn, log, etc.] or by 0 A.D. itself written in C++ [PostCommand, etc] or by code written in JavaScript. Next part will extend XBot and get in touch with settings, gameState, sharedScript and BaseAI. To be continued. PS. if you can't wait, explore this folder: D:\Games\0 A.D. alpha\binaries\data\mods\public\simulation\ai\common-api-v3 or inspect the other example bots.2 points
-
First I'll describe how to set up your system and show the basic layout of an 0 A.D. bot. It starts with downloading and installing the game, on my system that's the path d:\games\0.A.D\. Check out this guide for other systems and other paths mentioned below. A bit deeper is a huge zip file called public.zip, extract that into its folder keeping the folder structure intact. Now you'll find a folder called d:\Games\0 A.D. alpha\binaries\data\mods\public\simulation\ai Here the fun starts. Think of a good name, let's say XBot, and create a xbot sub folder as a sibling to qbot, testbot, aegis, etc, then two files are needed: data.json and _xbot.js.{ "name": "XBot", "description": "XBot - example", "constructor": "XBot", "useShared": true }Engine.IncludeModule("common-api-v3");function xbot(settings) { BaseAI.call(this, settings);}xbot.constructor = xbot;xbot.prototype = new BaseAI();xbot.prototype.CustomInit = function(gameState, sharedScript) {};xbot.prototype.OnUpdate = function(sharedScript) {};The files in your bot folder are loaded alphabetically, so the underscore makes sure the api is included first. I use a local.cfg file C:\Documents and Settings\Owner\Application Data\0ad\config in to ease development: windowed = truesplashscreenenable = falsepauseonfocusloss = truexres = 1024yres = 768jsdebugger.enable = false2 points
-
After playing 0 A.D. far to often I decided to program my own AI/bot. 0 A.D. is an interesting client for an AI because first it is so beautiful, second it requires solving real world problems and, well, bots need to be written in JavaScript, which is quite popular. So this is kind of a forum blog of a Linux/Internet guy developing on an old Windows XP license against Mozilla's SpiderMonkey having no clue about C++ programming or compiling. The following wouldn't be impossible without a working AI. Wraitii's excellent Aegis Bot is nearly game complete and was a challenging opponent for dozens of rounds. Aegis implements resource allocation, queueing and management, building placement, map exploration and more - all important things needed whatever logic an AI prefers. I love the idea of AIs showing their capabilties in a complex environment fighting against each other. Hopefully developers reading this feel challenged and Hannibal gets opponents really soon, which is the purpose of this writing. Since all code is open everybody can use and optimize each other solutions and strategies. If you are interested, this is a good starting point. I'll plan to continue this series at least until the sample bot trains units and let them gather resources. I have a few design goals in mind: With highest difficulty the AI should be unbeatable while the lowest should be just interesting enough to engage beginners. Unit groups should solve most problems more or less autonomously. And at a later point research would be required to restrict the AI to launch only attacks according to the selected civilisation. Hannibal will use kind of a state machine to implement behaviours based on frames. Frames will run in a special context/closure providing something as close to a domain specific language (DSL) as JavaScript, time and "strict mode" allows. Everything below and above refers to 0 A.D. Alpha 15 Osiris (running on Windows) using SpiderMonkey 4 impementing Javascript 1.85. Some statements might be based on untested information found in the wiki or this forum and could be wrong or misleading. Please, let me know!1 point
-
Before Blender became so prevalent, 3DS Max was the tool that exported the majority of models and animations until around 2006-2007. It should still be possible, in fact many original .max file are available in the artist's SVN repository if you would like to view those. It sounds like you need general information of how to do rigging, not specifically how to get 3ds models and animations into the game? There are numerous resources for the former, and I'm one of the few resources for the later. So if you ask me specific questions I'll do my best to answer them. I'll subscribe to this thread and try to keep up with answering ASAP. Like blender - the goal is to output a .dae file. The method behind the output could vary. For example you could use the character studio feature of 3ds Max for your bones structure or you could use your own custom bone objects. You could use the skin or the physique modifiers for interpolating the mesh and assigning weights to each vertex. So right off the bat you have two options. I haven't exported to .dae in years and I think I was using 3ds Max R7 at the time with a open source freeware plugin called ColladaMax. This was because the default .dae exporter from max at the time was doing a poor job and the .dae file outputted weren't recognized by the engine at the time. The first step I would try if I were you would be to try and simply export one of the old models with the new version of max and it's .dae plugin and see if it breaks. Here is one you can play with. I think there is some very basic animation in it using a few bones (helpers) and a skin modifier. chariot.zip1 point
-
There is a browser based JS debugger allowing breakpoints and variable inspection, but I got it running only once or twice, so dbgView from SysInternals is my debugging tool of choice. A bot has 3 possibilities to talk to you while running, 1) chatting, 2) the in game console and 3) logging to std, in this case dbgView. The console is of little use since it runs in another context. However, the Aegis Bot uses it quite well to explain its actions once debug is set in its config. I decided to use dbgView only and keep the chat function to entertain the human opponent. SpiderMonkey is very picky and demands properly written code. I use Sublime Text as editor and a JSLint plugin to make sure SpiderMonkey is happy before 0 A.D. fails to load the code. JSLint is even more picky, but there is nothing wrong with using a good coding style restricted to the good parts of JavaScript. In terms of style I tend to prefer Google's JavaScript Style Guide. You probably want to start developing with a simple map. Get used to the map editor Atlas and create a map with two Civil Centers one for your bot (Player 1) and one for Aegis (Player 2). It's actually quite simple. Since maps are XML files, direct editing is possible too. Atlas saves maps in a special windows folder, mine is: C:\Daten\My Games\0ad\mods\user\maps\scenarios My first map is attached. You start it with this command line:"D:\Games\0 A.D. alpha\binaries\system\pyrogenesis.exe" -quickstart -autostart=xbotmap01 -autostart-ai=1:xbot -autostart-ai=2:aegisAt this point you have an Bot which is functional, but as clever as a stone. It is a good idea to learn the hotkeys, triple clicks give you some advantages, also there is an useful developer overlay. xbotmap01.xml1 point
-
Maybe I could ? What is needed ? Edit Made the Animation of the Cart Edit 2 : Also, It would be nice to have the same props as the corral for player color, you know the little tissue stuff on the fence.1 point