View topic - Shard 0.35RC2 & 0.31.1 Not So Ballsey


All times are UTC + 1 hour


Post new topic Reply to topic  [ 717 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20 ... 36  Next
Author Message
PostPosted: 04 Oct 2011, 23:33 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
An experimental MorphInto method has also been added to the engine unit object, it takes a unit type object as a parameter and returns true/false.

It's assumed the Morphing implementation takes the command ID 32210 and takes the unit definition ID as its first parameter. Thanks to Knorke for the help.
Top
 Offline Profile  
 
PostPosted: 05 Oct 2011, 00:42 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Here's 0.35RC1

http://www.darkstars.co.uk/downloads/vi ... d0.35RC.7z

This is built from git master, so it includes a raft of stability fixes and safeguards, the things I mentioned in the previous posts, and a lot of other small changes and architectural improvements.

Please use this build if you're developing with Shard or using it for your game, so that I can iterate quickly in the coming days.
Top
 Offline Profile  
 
PostPosted: 05 Oct 2011, 11:24 
User avatar

Joined: 20 Aug 2009, 19:49
GetMapFeatures() does not work:
[i called: game.map:GetMapFeatures() and map:GetMapFeatures() neither works]

Code:
[f=0000500] <SkirmishAI: Shard 0.35RC (team 1)>: Wrong arguments for overloaded function 'IMap_GetMapFeatures'
  Possible C/C++ prototypes are:
    IMap::GetMapFeatures()
    IMap::GetMapFeatures(Position,double)
Top
 Offline Profile  
 
PostPosted: 05 Oct 2011, 15:41 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Oh dear =( I will look into this when I get home.
Top
 Offline Profile  
 
PostPosted: 05 Oct 2011, 23:28 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Can you verify it used to work and doesn't now? ( and not that it never worked ), also does GetUnits work?
Top
 Offline Profile  
 
PostPosted: 05 Oct 2011, 23:57 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Nevermind I've cleared up the ambiguity

There's now:

map:GetMapFeaturesAt
game:GetResourceByName

Redownload via the same link and extract over the top
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 09:12 
User avatar

Joined: 20 Aug 2009, 19:49
When calling that function:
Code:
local features = map:GetMapFeaturesAt(pos,5000)


it results in:
Code:
[f=0000500] <SkirmishAI: Shard 0.35RC (team 1)>: ...\_Spring\AI\Skirmish\Shard\0.35RC\ai\preload\api.lua:174: attempt to index local 'fv' (a userdata value)
stack traceback:
   [C]: ?
   [C]: ?


still does not work .-.
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 11:10 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
In api.lua replace it with:

Code:
   function map:GetMapFeaturesAt(position,radius)
      local m = game_engine:Map()
      local fv = m:GetMapFeaturesAt(position,radius)
      local f = {}
      local i = 0
      if fv:empty() then
         fv = nil
         return nil
      else
         while i  < fv:size() do
            table.insert(f,fv[i])
            i = i + 1
         end
         fv = nil
         return f
      end
   end


My theory at the moment is that it could not handle the API returning no units. If true I'll modify the other functions accordingly, but I'm at work so I can't test atm
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 13:12 
User avatar

Joined: 20 Aug 2009, 19:49
nope thats not it, i tried by grabbing all features on the map which has plenty of them. The error should be somwhere within the function since it has to do with the variable fv which is not even returned.


Also it would be really usefull to have not only a list of all functions that are available but also some example calls as there are some non intuitive things there.
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 13:41 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
best thing to do if a call seems unintuitive to you, is to find out how it works yourself, and document it on your fork of spring on github, in this file:
https://github.com/spring/spring/blob/3 ... Callback.h

... that applies to calls from the spring AI Interface callback only, of course.
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 14:41 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
fv is a C++ object wrapped by swig and then insulated via that proxy function so that what is returned is a pure lua table.

To be precise the fv object is of type std::vector<IMapFeature*>

My fix above works under the premise that iterating on an empty C++ STL container is never a good idea
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 14:58 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Code:
std::vector<IMapFeature*> CSpringMap::GetMapFeaturesAt(Position p, double radius){
   SAIFloat3 pos;
   pos.x = p.x;
   pos.y = p.y;
   pos.z = p.z;
   std::vector< IMapFeature*> mapFeatures;

   std::vector<springai::Feature*> features = callback->GetFeaturesIn(pos,radius);
   std::vector<springai::Feature*>::iterator i = features.begin();
   for(;i != features.end(); ++i){
      CSpringMapFeature* f = new CSpringMapFeature(callback,*i,game);
      mapFeatures.push_back(f);
   }
   return mapFeatures;
}


Is the implementation on the C++ side.

Can I see the code you're using to make the call to map:GetMapFeaturesAt() ?

My only other suggestion so far is to replace:

Code:
table.insert(f,fv[i])


with

Code:
table.insert(f,fv:at(i))


and to create a position:

Code:
p = api.Position()
p.x = 0
p.y = 0
p.z = 0
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 15:31 
User avatar

Joined: 20 Aug 2009, 19:49
I just called the function and assigned it to a new local variable, the same way it is done with "GetEnemies" in "attackhandler.lua".
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 17:58 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
So you're not passing any parameters in?
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 20:08 
User avatar

Joined: 20 Aug 2009, 19:49
I tried with parameters and without neither worked
Top
 Offline Profile  
 
PostPosted: 06 Oct 2011, 21:56 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
Can you send me your setup so I can debug without going back and forth?
Top
 Offline Profile  
 
PostPosted: 07 Oct 2011, 09:31 
User avatar

Joined: 20 Aug 2009, 19:49
there you go


Attachments:
0.35RC.7z [339.38 KiB]
Downloaded 14 times
Top
 Offline Profile  
 
PostPosted: 07 Oct 2011, 15:30 

Joined: 07 Oct 2011, 15:15
Hello all,

I'm new to the Forum, but have played Spring for the last 3 or 4 years,
and now i decide to write my own BA config for Shard, but i have a serious Problem:

My LUA skills are Bad... :cry:

I need your Help.

For my Build units i try to check how much units from a specific Typ are aleready build. (i.e. How many Solar Collectors are build)
Is there a way to count all units and see how many of them are Solar Collectors?
I Try fiddling arround with game:GetUnits, but i dont realy understand how it works. I am able to count all Units, but how can i find out how many are Solar Collectors

I have read through the Whole Thread, and looked into other Shard Config files, but i dont get it... :cry:

Maybe someone can explain it to me? In this Thread or via PN...

P.S. Sorry for my Bad englisch :oops:
Top
 Offline Profile  
 
PostPosted: 07 Oct 2011, 18:09 
AI Coder
User avatar

Joined: 14 Sep 2004, 10:32
Location: Cookieland
The way I would reccomend is:

  • Add an empty module
  • This module will have a table such that tableobject[unittype] = XofThisType
  • Everytime a unit of yours is built, increment the number
  • Decrement on unit death
  • To get the number of units for say a corsolar, all you would need to do now is local solarCount = tableobject["corsolar"] or something similar.

We currently have something similar to this already to count factories for evo, and I'm thinking this is such a nice example of a module I'll probably write up a tutorial when I get home ( yay ). The code Erik posted above has 2 behaviours that do the same thing, basically acting as tags on a unit and doing nothing more than incrementing and decrementing a number on creation and death.

AttackBehaviour also does very little too, when an attack is built, it says to the Attack Handler, I'm here, and waits. It does this every time the attack is idle.

All in all you should be able to go quite far with just modifying taskqueues for BA, but there are a lot of primitive simple behaviours that will help a lot.
Top
 Offline Profile  
 
PostPosted: 07 Oct 2011, 18:36 

Joined: 07 Oct 2011, 15:15
Hi AF,

first of all i have to Thank you for your great AI.
I played al lot of games against NTai a few years ago, but Shard is much better, i think. :-)

I hope i can follow your instructions... :shock:

I have seen the 'Unit Inventory' stuff in the EvoRTS Config, but it seems very complex. (for me) I will try modify that functions for my BA Config if no one is angainst that.

Ah, and thanks for the quick Reply.
Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 717 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20 ... 36  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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.