AI scripts

You think of something which could be added to TA3D post here! /
Vous pensez à quelque chose que l'on pourrait ajouter à TA3D, postez ici!
User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

AI scripts

Post by Balthazar » Fri Sep 28, 2007 3:37 pm

You have added new AI script, so-called annihilation.c. How is it differs from defence.c ?

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Mon Oct 01, 2007 12:35 pm

hum, I don't remember exactly, need to see the code to tell the difference.
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Post by Balthazar » Mon Oct 01, 2007 2:35 pm

Whe should ship at least two script - one for land maps, one for sea maps.

Also - there could be really clever script - if use coord for unit span, give different spawned units different patrol order and send them to attack player from different angles. As I can see it that is not hard to do, all we need is map_width, map_heght, player_comm_position (x,y). Anything else could be calculated from current spawn position and those variables.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Mon Oct 01, 2007 2:55 pm

Ok, I've read those scripts, defense.c and annihilation.c are two different scripts, in fact annihilation.c is like default.c except that you have to kill all your enemy's units to win whereas in default.c, killing the commander will end the game.

Also, I think there should already be all the required functions in the script engine to create the scripts you want, if any problem just tell me.
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Post by Balthazar » Mon Oct 01, 2007 3:31 pm

Yeah :) The only problem is that i can`t test it at full force, cause there are still buggy pathfinding.

Waiting for your new release

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Mon Oct 01, 2007 3:48 pm

hm yes "pathfinding" is still a problem, I don't know if I'll look at it before week end, because I don't want to make to much changes without fixing the bugs on windows, that would make it harder to debug things.
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Post by Balthazar » Mon Oct 01, 2007 4:40 pm

Pathfinding is separate part of engine. You can tweak it anyway you like. Now we don`t expect any serious bugs in game process.

I don`t know how to add transparency in 3dmeditor. Once I chec the selection box - transparency - my model just dissapears. flour!!! FUCKING flour!!! I`ve tryed any kinds of options, but still - it doesn`t work :( Model just vanishes. FUUUCK!!

Also - can you send me your tree model in any format other than 3dm. I`ll try to make several from it, my models are still looking kind of ugly in TA3D :(

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Post by zuzuf » Mon Oct 01, 2007 5:01 pm

Transparency works with a transparency "color", you can set it with the text boxes just under the transparency option, this color is also used when you set a reflective material. By default it's set to 0 (when left blank), so set the RGB to 255 and the Alpha to 127 (to have your material half translucent).

I'll send you the trees in an other format so you can modify them. Also we need a good looking radar tower (my poor tower is badly textured), I'll send it too.
=>;-D Penguin Powered

User avatar
Balthazar
Moderator
Posts: 2055
Joined: Wed Nov 01, 2006 4:31 pm
Location: Russian Federation
Contact:

Post by Balthazar » Mon Oct 01, 2007 6:04 pm

Ok! I`ll see what I can do :)

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Sun May 10, 2009 1:56 pm

A very useful suppent:
add a console or another mothed to run "lua" when game,then we can see what's going when the lua run.It helpful in every thing

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Sun May 10, 2009 5:47 pm

Indeed, it would be useful :) (for AI and game scenario scripting, but there are too much unit scripts running to debug them that way - this should be done with 3DMEditor 2 when animation module is finished)
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Mon May 11, 2009 8:24 pm

3DMEditor 2 work with TA3D?
I mean 3DMEditor and TA3D work like one process.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Mon May 11, 2009 9:42 pm

3DMEditor 1 shares lots of code with TA3D, way too much actually since several modules from TA3D are linked with 3DMEditor even if they are useless in 3DMEditor.
Also the mesh class used to provided features for both TA3D and 3DMEditor, which finally broken several things in TA3D when working on 3DMEditor :evil: , this will no more be the case :D
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Tue May 12, 2009 12:09 pm

Blabla,that's ok.
I think about script debug,3DMEditor 2 be able to test what happen in script,thus,how it do that?

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Tue May 12, 2009 4:38 pm

3DMEditor 2 will have its own version of the script API which will use the same interface as TA3D. So you'll have the same functions, tools, etc ... except it'll run for a model and not a unit (so unitIDs will be meaningless but you can just replace them for testing). The main difference is it won't be able to interact with the engine (since there won't be any running), you'll have to run the script manually and because of monitoring it'll probably be a bit slower.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu May 21, 2009 5:42 pm

I find TA3D default AI work very good to order con(construction, I used to shortening)build in the vicinity, such as hold metal
cheers very much affected by A API like this: ConBuildType/StartBuild/StopBuild/, con build a list of units in the vicinity, when AI want hold some section, just send cons to section then
ConBuildType (HoldList, ConGroup)
StartBuild (ConGroup) --after some times
StopBuild (ConGroup)

I realize these when played TOTALAM beta3 in TA3D, I spawn 100 cons for AI, unimaginable! Those cons work good,and original AI active send weapon Unit attack me!

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Thu May 21, 2009 11:09 pm

Yeah C AIs can quickly become very hard to defeat when they get enough cons : just because they can give orders faster than humans, they can rebuild things faster than you can destroy them, but before they manage to get there they can be easily defeated :(
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Fri May 22, 2009 7:26 am

:P
I'm intereting in game script,also.
It was same as AI,but more simple,I enjoy in played some crazy script game with mod,such as defence 10000 comm charge,use hignest units fight with 100 krogs.

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Wed Jun 03, 2009 10:18 am

Unit data should show these things, also
BuildTime
BuildPower

And these 2 API really need at now:
Got the length that one unit move to somewhere.
Build a thing in some Frame, I think TA3D own builder AI is enough for selecet portion Location, thus AI just need move Builder and order Builder build something in some Frame.(That TA3D's x/y isn't Pixels but Wireframe)

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Wed Jun 03, 2009 7:43 pm

BuildTime, WorkerTime (internal name of what you called BuildPower), finding a place to build things have been implemented :).

Concerning the path length, I am going to implement it, but remember it'll be costly (really don't consider using it for each unit, for each step of the main loop ...).
TA3D uses a queue to respond to path finder queries (in the unit engine only) because it prevents using too much CPU resources when lots of units wants to find their way at the same time (avoid game lags), so you may want to consider the idea as well.
Beware that part of the path is normally computed as the unit walks to reduce CPU cost (no need to compute the whole path if the unit decide to change its way before having reached half the planned path) but here it'll be done completely in order to compute the expected path length.
=>;-D Penguin Powered

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Wed Jun 03, 2009 8:06 pm

done, beware the new function doesn't take flying units into account (for performance reasons, it's better to check that case in the Lua code)
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu Jun 04, 2009 6:17 am

Good job!
AI keep going.
Infact it was unpossable to using got len for each unit. AI control group by 2 reason : nearly enemy Num, Main units need(That random some units for conside, never outside 3).
And If it was cost too muck CPU, how about separate to more times? Got 200 units' path per second, it may help.

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu Jun 04, 2009 8:15 am

:o
Is I wrong?
I remeber there a API named "AreaUnits" or someother, for got a section's units, but I couldn't seek it in lua_prototypes.Fount this when writing a wapper, beable to got spec units in area, that Got spec player/weapon/etc unit in a area.
:shock:
I had used this API sometimes, but didn't do test, hehehehehehehe

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu Jun 04, 2009 9:18 am

And a question, is all query to same unit control the same struct in lua?
For example, asked a Unit's data, then add a data Group into this unit's data(used lua).Next time list All AI's units, then check this Group data out, will it worked?

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Thu Jun 04, 2009 5:55 pm

Optimizing pathfinder with the C++ API is easier and necessary, but the engine itself never computes path length because it would required to know the whole path before processing it which is not the case since the path is partly processed as units follows it.

"AreaUnits" oO ? There is no such API, at least for now.

NB: Lua scripts build even if you try to use some nil object as a function, it'll crash only when execution reaches this line.

For now unit structures are regenerated by the C API so you don't get with it the data you put in, but this could be changed using some metatable tricks (replacing the index function to make it use another global table when you access nil elements would ensure the data you add in will "stay" virtually). I'll have a closer look at this idea.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu Jun 04, 2009 7:36 pm

Yep, C++ couldn't dynamic alter struct.
So, add a unitGroupIDlist in lua for this, and got spec GroupID from that list when check the spec unit.Ths for tip.
And Infact I didn't think GroupId embed in cpp UnitStruct, it duo to all GroupID architecture work in lua. When the addtion(like UnitGroupId_List) be more than 3, change to cpp.Messy inertia.
And about the AreaUnits, it should work with buffer, cache all need date and just updata when need. I orderless in this cause it really useful, LOL.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Thu Jun 04, 2009 7:39 pm

What's the AreaUnits stuffs exactly ?

I am going to implement a metatable that'll virtually keep all the required Lua data in the unit structures.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu Jun 04, 2009 7:51 pm

Well, Ths for "virtually keep all the required Lua data in the unit structures"!
I'm used areaunits like this:
AreaUnits (nx, ny, sx, sy, Type, playerID)
That return a list like return of get_unit_list, limit inrectangle(The upper left corner (nx, ny), The lower right corner (sx, sy)) and limit in Builder or Weapon attribute, and the player that owned.
This is too good for unit control to mess me.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Thu Jun 04, 2009 9:17 pm

ok, virtual tables implemented for both unit and unit_type Lua structures :)
Also I fixed a nasty deadlock that would have occurred each time you call get_unit_list :evil:

I'll add AreaUnits (nx, ny, sx, sy, Type, playerID) too :)
=>;-D Penguin Powered

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Thu Jun 04, 2009 9:46 pm

AreaUnits implemented as get_area_units.

It can return the list of all units lying in the area, or only units of some type, or only Builders, or only units that can attack. It can also return units for a given player, or for all players.

Coordinates should be given in world coordinates (as usual)
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Fri Jun 05, 2009 7:50 am

OMG!
Your work are crazy! I couldn't know how can done these as soon as you.

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Fri Jun 05, 2009 6:51 pm

:)
player's energy/metal...

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Fri Jun 05, 2009 7:35 pm

you have it :)
through get_player_resources(playerID)

it returns a table with following fields set (or nil if playerID is not what's expected):
  • energy
  • energy_storage
  • energy_produced
  • energy_used
  • metal
  • metal_storage
  • metal_produced
  • metal_used
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Sat Jun 06, 2009 9:15 am

Well, this is what I doing

--Select Most:Most Good,Most enemy,most nearly,most etc,build most, harder most.
--Better in war:Cons follow attack and harder Denfence,enemy Num affect Attack/Assembly/Detour/Build more/etc,enemy position affect build/attack/guard
--Better in Build:More and more,Build best, the low HP and no weapon or Productive resources build in base.Build in radioactivity,try to cover all map in defence and base.
--Better in ponder:try to reclaim,how to plan expend in Economic construction Or Military based on enemy.

--Control By Section Group, every Group hard one section. Section had Importand/Daunger/function for decide how to handle Group.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Sat Jun 06, 2009 11:52 am

You'll need some functions to deal with reclaim orders and wreckages/trees/rocks :)
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Sat Jun 06, 2009 1:09 pm

Well, I used patrol for reclaim, :mrgreen:

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Sat Jun 06, 2009 1:27 pm

it doesn't work yet, patrolling units only attack enemy units if they can, builders don't repair or reclaim things.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Sat Jun 06, 2009 3:52 pm

But in the TA3D 0.6 it will better than need. :D
So I willn't change the reclaim mothed at now.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Sat Jun 06, 2009 3:57 pm

You should have a look at the new console commands provided for Lua debugging :) :
http://www.ta3d.org/forums/viewtopic.php?f=1&t=1046
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Sat Jun 06, 2009 4:14 pm

Yep, Yep, I'm downloading newest trunk

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Mon Jun 08, 2009 7:05 pm

The Default AI trouble in Underwater Metal Collector, and load build as OTA's Ai.txt will helpful in normal game

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Mon Jun 08, 2009 7:38 pm

hm, yes, I guess this should be done through scripting using some functions to access the VFS properly and get the map name.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Tue Jun 09, 2009 8:01 am

:D
Really strong script
Infact I seggsion do this in AreaBuild, that builder own work in a area was more useful and may used in Player help AI.

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Thu Jun 11, 2009 7:16 am

A seggtion of get_area_units

iNum get_area_units (nx, ny, sx, sy, type, playID, List)
return the type Number of area units alway
The playerID, I suppent it just need suppent the filter "ME"/ "ENEMY"
But list the unit data defend argc List, just list when it didn't nil
This will helpful in performance due to call get_area_units lots times in AI.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Thu Jun 11, 2009 4:10 pm

the playerID stuffs can be filtered by Lua code (just use playerID = -1 to get units from all players, then check results in Lua). It is better that way since the function has more general purpose.

I am sorry, I don't understand what you want to do with the List argument.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Sat Jun 13, 2009 9:16 am

playerID = -1
:) Great!
That list was a sign for get_area_units and a return table
If the list isn't nil, return the units data into list table and return Num of selecet units as return , nither just return the Num of selecet units.

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Mon Mar 15, 2010 11:20 am

I notice there are a AI path in script folden, what's that use for?
That write in main sciprt(annihilation.lua) make the AI cast too much metion, maybe a new mothed for write this script?
I mean:
some folden in AI folden, like:
TA3D ai
and there are some lua in "TA3D ai", one name eazy, one name normal, one name diffcult.
So there are 3 type AI in game for select. When user select a AI for a player, the lua will start as a
void main (player_id, max_units, map_type, start_energy, start_metal);

map_type I want used it to read map_width_list , which OTA's AI file, it can reset AI in eazly way..

Had already write some things for AI, so I can just use them in AI scipt atm, a alpha maybe.
There are like energy->metal control, group units control(where units to go), unit build control(depend in metal+, energy+ and if there are, also width), and had write some build type calc (like solar or wind or tidal), for sure and make cons be more width always.

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Mon Mar 15, 2010 11:39 am

xpoy wrote:I notice there are a AI path in script folden, what's that use for?
It's the default place for Lua AIs, TA3D will look for them here.
xpoy wrote:That write in main sciprt(annihilation.lua) make the AI cast too much metion, maybe a new mothed for write this script?
I mean:
some folden in AI folden, like:
TA3D ai
and there are some lua in "TA3D ai", one name eazy, one name normal, one name diffcult.
So there are 3 type AI in game for select. When user select a AI for a player, the lua will start as a
void main (player_id, max_units, map_type, start_energy, start_metal);

map_type I want used it to read map_width_list , which OTA's AI file, it can reset AI in eazly way..
I am not sure I understand what you mean. annihilation.lua is just a script for game rules, it doesn't control AI.
=>;-D Penguin Powered

xpoy
Posts: 669
Joined: Mon Sep 22, 2008 3:55 am

Re: AI scripts

Post by xpoy » Mon Mar 15, 2010 11:41 am

but how I make a AI for diccult? Or make a AI for eazy?
:P
Greet a simple explaim

User avatar
zuzuf
Administrateur - Site Admin
Posts: 3281
Joined: Mon Oct 30, 2006 8:49 pm
Location: Toulouse, France
Contact:

Re: AI scripts

Post by zuzuf » Mon Mar 15, 2010 11:45 am

Well you'll probably have a set of parameters in your Lua code. Just make a Lua script for each level of difficulty adapting those parameters to fit that difficulty :)
=>;-D Penguin Powered

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests