Anyone know how to make Shard AI work with Conflict Terra? - Page 1

Anyone know how to make Shard AI work with Conflict Terra?

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by knorke »

oksnoop2 wrote:The problem here is getting mining towers to morph near rocks and unmorph when that space runs dry.
tp_KTAI.lua in CT has a (bad&ugly) function to find the nearest rocks from a unit:

Code: Select all

local resid, tx, ty,tz,distance = nearest_res_from_unit (unitID)
If distance is too large, you know it has has to move.

You could check every few seconds if all towers are still in range of rocks and if not then do something like:

Code: Select all

function deployAt (unitID, tx,tz)
	Spring.GiveOrderToUnit(unitID, CMD.MOVE , {tx, Spring.GetGroundHeight (tx,tz), tz  }, {})  --moves the unit
	Spring.GiveOrderToUnit(unitID, 31210,{UnitDefNames["kdroneminingtower"].id},{"shift"})  --deploys
end
undeploying goes like

Code: Select all

Spring.GiveOrderToUnit(unitID, 31210,{UnitDefNames["kdroneengineer"].id},{})
I have no idea where into Shard that has to be inserted but thats how I'd do it if it was a normal Lua AI.
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by oksnoop2 »

AF has told me like a million times, but i can't remember. behaviours.lua maybe? AF where would this code be shoe horned into?
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by yanom »

oksnoop2 wrote:I'll do just about anything game side to get working AI.
You could make the drone faction more ai-agreeable, like remove the mining towers and have engineers just reclaim the rocks (but slow, so that i'd be balanced vs the other faction).
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by yanom »

oksnoop2 wrote:Look to the taskques.lua here is an example:
http://code.google.com/p/conflictterra/ ... queues.lua

Basically something like this:

taskqueues = {
kdroneengineer = {
"kdronestructure",
"kairdronefactory",

{ action="wait",frames=30},
everything in taskqueues.lua is prefixed with a "b", not a "k" as shown here. is the k the drone faction and b the flying cruiser faction (NKG i belive)?
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by oksnoop2 »

The mining does not work by reclaim. The rocks are actually neutral units that the miners and towers attck. The k prefix indicates in his case kevin's units which would be drone. Here is a list of the internal unit names used by shard and the engine:
http://code.google.com/p/conflictterra/ ... units?fp=2
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by AF »

knorke wrote:
the entire affair can be conducted with a copy of 7zip and a text editor
Thats like saying all you need to build a space shuttle is metal, some wires and a screwdriver...
modify CT so that a gadget responds with the necessary information ( or executes the desired action ).
Not much modifying required, if any at all.
(At least I don't remember anybody saying "this needs to be added.", imo CT is ai-playable if somebody bothers to try)
The two main problems to make CT playable by AI
are: 1) morphing cruisers & 2) mining.

1) The morph gadget is already useable by AIs. (at least there is some AICallin() thing and afaik its some custom command which AIs can already send anyway.)
Would need logic as when and where to use cruisers as factories and when to use them as fighting units.
There are some other units that can morph between two forms (ie flak truck) but thats not necessarily needed.

2) Mining is just building miners and then doing nothing or giving them a command once to start mining. (vs sending them back to the rocks when they want to go to the dropoff, like shard/other AIs currently seem to do)
Next stop would be a logic where to mine, where to place new dropoff depots, when to momentary move miners out of the way of attacks etc.
Not so easy imo, surely not as trivial as "make mex on all free spots."

The only other Lua thing are jumpjets but only ~3 units have them.

The drones faction would probally be simpler to make an AI with btw.

tl;dr:
yanom: to avoid confusion...are you even interessted in AI making or do you just want to play? ;)
AF: if anybody was to ever to make shard play ct, it would most likely be you.

Building Miners and making them do nothing

I have explained on these forums more than once how to do that.
  • Make a new behaviour that does absolutely nothing.
  • Assign it to the miners
  • Tell builders to build miners
  • Load game
Morph

Your implementation of morphing isnt th eonly one out there, nor does it provide a way of telling the AI if A can morph or not, and if it will morph into B C or D.

But having said that, if one off morphing of a single unit is all that's needed then:

Code: Select all

game:sendtocontent("ok morph that command cruiser now please")
And since there's an AICallin thing then that's your job made even easier. Make a behaviour, assign it to the cruisers, and make it send a message in the first frame, hey presto.


Tools

7Zip is to extract the game files and repackage them. A tetx editor is to modify the lua code.

You do not need anything more, and fi what you have told me about the AI Callin is correct, then you don't even need 7zip.

I'm not going to be able to hold your hand, and while I can help on the Shard side, I don't know the intimate details of your game, and to expect me to is unrealistic. The days of an AI programmer knowing the full scope of the domain is over unless you want hefty specialisation.

It doesn't matter if the AI is C++/Java/lua/Python/Lua widget, game developer involvement is necessary.

What strikes me is that your willing to have a go at me for saying a text editor is all that's needed, when your admitting there's an AICallin that I was not aware of. As far as I knew, I and oksnoop looked into it but he didn't know what to do and I didn't have enough time to investigate myself.


So as the core developer, I am telling you:
  • This is not a complicated thing to do
  • Shard was designed for this to be easy
  • Shards entire goal was to be easy to extend
  • Since Shards release I have made this even easier
  • Shard itself is small and light, and is probably dwarfed by the code you've written in gadgets
If you dig back Im sure I even posted an example of a NullBehaviour that did nothing ( or maybe it was just sendign hello world to the console, or maybe I sent it in a pastebin message to oksnoop ).

I went to great lengths to make sure that the worst case scenario was my C++ portion failing to compile, and if that happened, it would be very easy to fix as its merely a wrapper, something that any C++ developer here of novice ability could fix easily, and something the engine developers do already for the old AIs.

There is no AI logic of any kind in the C++ portion, and the logic in the lua portion is not dependant on it for structure, and can be ported to a completely different engine if needs be with no changes. I know I'm not going to be here forever, and I know that no single AI developer could ever fulfill the demands of an entire community as it stands today.


Put quite simply, you expect me to do all the work given a nod int eh right direction, when you could have had it all done months ago if a barely competent lua coder had spent 30 minutes.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by knorke »

Your implementation of morphing isnt th eonly one out there, nor does it provide a way of telling the AI if A can morph or not, and if it will morph into B C or D.
morphing gadget is this one: http://code.google.com/p/conflictterra/ ... _morph.lua
I believe it is the same as used in zeroK, S44 etc. though it might be outdated.

About the AICallin I didnt know myself until this thread (http://springrts.com/phpbb/viewtopic.php?f=15&t=26105) but it seems to go like:
-- Exemple of AI messages:
-- "aiShortName|morph|762" -- morph the unit of unitId 762

At top there is some more example stuff like
-- Print all the morphing possibilities:
Though I have never tested that much, its not my gadget, its from CA or whereever oksnoop2 found it.
Make a behaviour, assign it to the cruisers, and make it send a message in the first frame, hey presto.
And the cruiser morphs right in the construction bay, blocking it.
Also where would one even look to figure out the gameframe. In Spring its Spring.GetGameFrame() but in Shard?
Put quite simply, you expect me to do all the work given a nod int eh right direction, when you could have had it all done months ago if a barely competent lua coder had spent 30 minutes.
I dont expect you to do it at all, its not even my game :roll:
Just saying that you are the most likely person to make Shard play something because
1) you know Shard & Lua
2) others do not. Those who could maybe figure it out cba and would rather make a complete Lua AI.
Well, now there is enough info about CT's Lua and Shard's working, lets see what happens.
Seems we both are just pointing out problems/possible solutions but cba to put it together for several reasons.
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by yanom »

ok, I'm clearly in way over my head here, with all this lua stuff... I am kinda interested in how the AI works though.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by AF »

yanom wrote:ok, I'm clearly in way over my head here, with all this lua stuff... I am kinda interested in how the AI works though.
Dont worry I built Shard so that you dont need to code any logic if you don't have to in order to modify its behaviour, its more when new behaviours or new behaviour logic is needed, as is the case here.

The API Shard exposes, is actually a lua proxy table that's written out in api.lua, so you can see the entire API there with all its parameters, without having to dig into C++
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by yanom »

so where do I get this new AI?
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by oksnoop2 »

It's a luaai so it's built right into the game. Just get the latest revision.
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by yanom »

ahhh, there it is. Thanks! Was this AI made just recently, after my question about Shard?
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by oksnoop2 »

yeah, knorke made it like... today? i guess.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Anyone know how to make Shard AI work with Conflict Terra?

Post by knorke »

Yesterday, depending on timezones.
I had the idea for some time but this thread inspired me to actually start.
It is not a Shard AI, though some things could be reused perhaps. For example the move-engineers-to-rocks works basically like written here:
http://springrts.com/phpbb/viewtopic.ph ... 8&start=11

Code: Select all

function deployNearRes (unitID, keys)
	local nearest_resID, rx,ry,rz, nearest_res_distance  = nearestResFromUnit (unitID)
	local x,y,z = getBuildSpot (rx,ry,rz, "kdroneminingtower", 20, 5)
	deployAt (unitID,  x,z , keys)
end
The spring specific stuff like Spring.GetUnitsInCylinder would have to be replaced by Shard specific stuff.
Post Reply

Return to “AI”