View topic - Shard 0.35RC2 & 0.31.1 Not So Ballsey



All times are UTC + 1 hour


Post new topic Reply to topic  [ 569 posts ]  Go to page Previous  1 ... 13, 14, 15, 16, 17, 18, 19 ... 29  Next
Author Message
 Post subject: Re: Shard
PostPosted: 29 Aug 2011, 19:50 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
keep the drama thread to the drama thread

There is chance that the thread might be usefull to some.
Maybe in some time somebody wants to read about Spring AIs and it would be pretty embarrassing if that person has to wad through all this ot crap?
/edit
yea lol, now it looks like i deleted all that posts?
I did not. When I delete stuff I always put a note and it would be nice if others could do that too..


Top
 Online Profile  
 
 Post subject: Re: Shard
PostPosted: 31 Aug 2011, 12:21 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Shard has been re-continued due to recent advances.

Details will be posted shortly.


Top
 Offline Profile  
 
PostPosted: 01 Sep 2011, 17:30 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
http://darkstars.co.uk/2011/shard-0-31- ... o-ballsey/

The missing equals sign has been fixed, the BA config is now indented, Cans & Sumos are recognised as attackers in BA, and the name has been adjusted!


Top
 Offline Profile  
 
PostPosted: 15 Sep 2011, 15:40 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Someone asked for help on how to configure shard from a beginners point of view:

Shard runs off of behaviours, and by default construction units are assigned a TaskQueueBehaviour.

This piece of code looks at a file called taskqueues.lua containing a table that says Unit A will build B,C,D,E,F,then G, repeat.

The reason Shard only builds peewees is because I told it to in taskqueues.lua. To change this you will want to go to the BA subfolder and modify the BA specific taskqueues.lua by adding/removing/re-ordering the unit names listed.

e.g. ai/BA/taskqueues.lua :
Code:
taskqueues = {
   unitname = {
      "unitname",
      "unitname",
      "etc",
   },
   -- e.g.:
   corck = { -- core construction kbot
      "corsolar", -- build a solar
      "cormex", -- then a mex
      "cormex", -- then another mex
      "corllt", -- now a light laser tower
      "corrad", -- now a radar tower
      "corllt", -- another light laser tower
      "corsolar", -- another solar!
      "corllt", -- etc
      "corsolar",
      "cormex",
      "corhlt",
      "cornanotc",
      "corllt",
   },
   armlab = { -- arm kbot lab
      "armck", -- build a con bot
      "armck", -- then build a second one
      "armck", -- then a 3rd
      "armpw", -- now a peewee
      "armpw", -- and then another one
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      "armpw", -- and another
      -- all done, now repeat again
   },
}


You might see examples where instead of a table containing a list of things to build, you see the name of a function returning a list of things to build, or a function, or a predefined table ( helps reduce copy pasta if you define it once and then just sue the table name ).


Top
 Offline Profile  
 
PostPosted: 26 Sep 2011, 16:22 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
An update on the current situation regarding Gadget AIs:

http://darkstars.co.uk/2011/shard-gadge ... anagement/


Top
 Offline Profile  
 
PostPosted: 27 Sep 2011, 14:27 
User avatar

Joined: 20 Aug 2009, 19:49
How would i make a builder search for map features and reclaim them?


Top
 Offline Profile  
 
PostPosted: 27 Sep 2011, 17:15 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
You can use map:GetMapFeatures() to retrieve all the map features, it can also take 2 parameters, a position, and a radius.

This will return a table of feature objects, which has 3 methods:

Code:
feature = ...
integer feature:ID()
string feature:Name()
Position feature:GetPosition()


You have 2 ways of reclaiming a feature.

Code:
engineunit:Reclaim(feature)
engineunit:AreaReclaim(feature:GetPosition(),10)


If you have requests for extra functions/methods for getting various pieces of data on features, let me by putting in a request here:

https://github.com/Tarendai/Shard/issues

( ps: this isn't a clickety clackety tracker I setup myself that might go boom soon, it's github, it's here to stay! )

May i ask what game you're working on for this?


Top
 Offline Profile  
 
PostPosted: 27 Sep 2011, 17:46 
User avatar

Joined: 20 Aug 2009, 19:49
Its called "Void" and it uses economy based on reclaiming, which kinda explains why this part is important.


Top
 Offline Profile  
 
PostPosted: 27 Sep 2011, 18:05 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Interesting, care to PM me more details? I can think of a few things that might help you out


Top
 Offline Profile  
 
PostPosted: 27 Sep 2011, 18:28 
User avatar

Joined: 20 Aug 2009, 19:49
Edit: Got it working

Edit2: The "wait" function for the buildlists does not work, it either cancels everything or has no effect at all.


Top
 Offline Profile  
 
PostPosted: 28 Sep 2011, 17:04 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Not so ballsey doesn't have that functionality in, unless you're using the git master version? Not so ballsey was intended to fix the syntax error rather than to push out the latest and greatest version.

I take it from your post though that you're making a builder build things then pause so that the autoreclaim behaviour can take control, then yield control when the unit is next idle so it can resume construction?

I've one or two changes I want to make to the behaviour control routines, when a unit becomes idle, rather than handing off to the current active behaviour ( and waiting for said behaviour to do the elect behaviour call ), instead I want the unit object to call the elect behaviour call every single time the unit is idle, and then at regular intervals of every 1-2 seconds if no behaviour desires control.

This should make more sense than what is currently in use with minimal changes.

An active behaviour can then retain its control by raising its priority return value so it retains control. This way if another behaviour urgently needs to intervene, it can do so at the next unit idle call by giving itself a very high priority, e.g. you can make your behaviour check if there's a resource shortage, and if so return some uber high number as it's priority so it will go off to find resources, rather than continue building.


If you could let me take a look at what you've done so I can see and maybe make suggestions? It'd help me see how people are using my APIs and plan accordingly.


Top
 Offline Profile  
 
PostPosted: 30 Sep 2011, 22:04 
User avatar

Joined: 20 Aug 2009, 19:49
Bug:
UnitDead is called for every behaviour for each unit in possession of the AI player, i don't think this is intended( i thought it would be called only when a unit with that behaviour dies not for every unit).

In addition it is called for each frame while the unit dies, for example a building with a "topple-over" animation that lasts 30 gameframes would trigger it 30 times, could this possibly be fixed?



Also:
Is there a function to initialize stuff(playstyle for example) for an AI player that is called before everything else?


Top
 Offline Profile  
 
PostPosted: 01 Oct 2011, 22:51 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Erik wrote:
Bug:
UnitDead is called for every behaviour for each unit in possession of the AI player, i don't think this is intended( i thought it would be called only when a unit with that behaviour dies not for every unit).

This is desirable behaviour, for example say unit A, a super uber bomber, needs to attack a fusion reactor, but unit B needs to die first ( specialised super uber bomber killer turret ), a behaviour that made A wait until the defences were down would be impossible if the behaviour was only notified of its own death and not that of others.


Quote:
In addition it is called for each frame while the unit dies, for example a building with a "topple-over" animation that lasts 30 gameframes would trigger it 30 times, could this possibly be fixed?


This is most certainly a bug, and one in the AI interface at that. You can work around it but an API fix would be a lot better. Talk to Hoijui about this and if he can't sort it, he'll point you to someone who can. If not, let me know what he says ( he'll probably post in this thread now )

Quote:
Also:
Is there a function to initialize stuff(playstyle for example) for an AI player that is called before everything else?


Yes! They're called Modules, they're like behaviours but they're not attached to anything in particular. Look at the attack system. It has a behaviour for each unit, and a global Module that coordinates.


Top
 Offline Profile  
 
PostPosted: 02 Oct 2011, 18:07 
User avatar

Joined: 20 Aug 2009, 19:49
Another bug/strange behaviour thingy:

In the buildques if i call a function that returns nil the build process is stopped altogether instead of just skipping that entry.

Also would help to be able to return "wait" commands.


Top
 Offline Profile  
 
PostPosted: 02 Oct 2011, 19:50 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
You can return wait commands by returning exactly the same thing as what you would put to declare a wait command.

Are you using git master or not so ballsey now?


Top
 Offline Profile  
 
PostPosted: 02 Oct 2011, 20:15 
User avatar

Joined: 20 Aug 2009, 19:49
still using the "not so ballsy" one


Top
 Offline Profile  
 
PostPosted: 02 Oct 2011, 20:52 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
There's no wait command in not so ballsey

I advise moving to git master


Top
 Offline Profile  
 
PostPosted: 04 Oct 2011, 15:27 
User avatar

Joined: 20 Aug 2009, 19:49
Three more questions:

How would i best keep track of an AIs unit count for example it always wants to have at least 2 builders?

How do i get an AIs ressource pool (with example if possible)?


Is there a function i could call that returns all enemies that the AI can see currently?


Top
 Offline Profile  
 
PostPosted: 04 Oct 2011, 19:03 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
If you refer to a file called preload/api.lua you can see all the calls possible to the game and map objects.

To determine the overrall unit count you can simply count the number of objects returned int he table when calling game:GetFriendlies(), and vice versa for game:GetEnemies()

To count the builders you would either iterate through the returned items and check each if they were a builder, or you can store the value via a module, and increment and decrement on unit created and unit death events. ( latter would be preferable as it's far less intensive )

Here is the current Shard resources API:

Code:
   function game:GetResource(idx) --  returns a Resource object
      return game_engine:GetResource(idx)
   end

   function game:GetResourceCount() -- return the number of resources
      return game_engine:GetResourceCount()
   end

   function game:GetResource(name) -- returns a Resource object, takes the name of the resource
      return game_engine:GetResource(name)
   end

   function game:GetResources() -- returns a table of Resource objects, takes the name of the resource

      local rcount = game_engine:GetResourceCount()
      if(rcount > 0) then

         local resources = {}

         for i = 0,rcount do
            local res = game:GetResource(i)
            if res.name ~= "" then
               resources[res.name] = res
            end
         end
         return resources
      else
         return nil
      end
   end


IMO this portion of the API is lacking, especially with regards to features.


Top
 Offline Profile  
 
PostPosted: 04 Oct 2011, 23:10 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
To clarify things I've made additions that should make you and foreboding/IK happy

  • Added boolean Reclaimable() to feature objects
  • Added float ResourceValue(integer resource_id) to features objects, takes the ID of a resource and returns the amount of resources in said feature left for reclaiming. Returns -1 on error
  • Added float ResourceCost(integer resource_id) to unit definition objects, takes the ID of a resource and returns the amount of resources in said feature left for reclaiming. Returns -1 on error
  • Added float ReclaimSpeed() to unit objects, returns 0 if the unit cannot reclaim. Thus doubles as a CanReclaim method
  • Resource objects returned by calls to the game object now have a subvalue called id for use in aforementioned API calls
  • A minor example for anyone lurking wanting a gadget API port
  • Added game:GetTeamID, returns the ID of Shards current team
  • Added game:GetUnits(), retrieves Shards units, but not allied units
  • Unit objects now have a Team method returning their teamID
  • Experimental MaxWeaponDamage method added to unit objects ( untested, unsure of results as there is no straightforward way of determining the damage a weapon will do via AI API without knowing more details of context)


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 569 posts ]  Go to page Previous  1 ... 13, 14, 15, 16, 17, 18, 19 ... 29  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.