defending gateways

For AI and campaign script related discussions and questions
Post Reply
User avatar
DylanDog
Code contributor
Code contributor
Posts: 347
Joined: 08 Apr 2009, 15:15
Location: Germany
Contact:

defending gateways

Post by DylanDog »

I was wondering if someone can explain how the standard warzone AI is able to build defences on gateways points without using the function:

getNearestGateway() to become aware of the gateways positions.

This would be nice to know.
My Warzone 2100 mods:
Download DyDo-AI for Warzone skirmish/multiplayer games.
Download A2C-HM (Alpha 2 Campaign - Hard Mode).
Download A3C-HM (Alpha 3 Campaign - Hard Mode).
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: defending gateways

Post by Per »

By calling skDefenseLocation() and skDefenseLocationB().
User avatar
DylanDog
Code contributor
Code contributor
Posts: 347
Joined: 08 Apr 2009, 15:15
Location: Germany
Contact:

Re: defending gateways

Post by DylanDog »

Per wrote:By calling skDefenseLocation() and skDefenseLocationB().
skDefenseLocation() is not used.

How does skDefenseLocationB() works? from the AI manual (referred to skDefenseLocation() ):

Code: Select all

bool skDefenseLocation (ref int x, ref int y, STRUCTURESTAT defenceStat, STRUCTURESTAT wallstat, DROID unit, int player)
    Given a starting x and y, make unit unit belonging to player build either a defenceStat or a row of wallStat. Returns modified x and ys. 
Does this mean that the nearest gateway to x,y coord is the first one to be fortified?
What happens when all gateways are fortified?
Valid gateways are within which range of x,y?
My Warzone 2100 mods:
Download DyDo-AI for Warzone skirmish/multiplayer games.
Download A2C-HM (Alpha 2 Campaign - Hard Mode).
Download A3C-HM (Alpha 3 Campaign - Hard Mode).
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: defending gateways

Post by Per »

Yes, the nearest gateway is fortified, and the passed in droid is given a linebuild order to construct the entire gateway in one order. It is a rather ugly hack, and it is full of bugs. I fixed some of the bugs in trunk while testing semperfi, but more bugs remain (if gateway goes into map border then gateway building is cancelled, it doesn't usually understand that a gateway is already built, etc). When all gateways are fortified, it returns false and does nothing. There is no range limitation, so droids can be sent on quite a journey in odd cases.

The difference between the two versions is that the B version will skip gateways unless it can preserve at least two empty tiles in the middle of the gateway for traffic. Probably any use of the non-B version is a bug.

If you have your own gateway building code, I am sure it is better than this.
User avatar
DylanDog
Code contributor
Code contributor
Posts: 347
Joined: 08 Apr 2009, 15:15
Location: Germany
Contact:

Re: defending gateways

Post by DylanDog »

Per wrote: If you have your own gateway building code, I am sure it is better than this.
thanks for the clarification.
Yes I am using my code but it is also using skDefenseLocationB(), I pass to that function up to three gateways coordinates (I check for the number of def buildings built in that range before pasing that coordinates to that function).
My Warzone 2100 mods:
Download DyDo-AI for Warzone skirmish/multiplayer games.
Download A2C-HM (Alpha 2 Campaign - Hard Mode).
Download A3C-HM (Alpha 3 Campaign - Hard Mode).
Post Reply