ta3d AI
Re: ta3d AI
I think AI just need be devlop qucikly.
Re: ta3d AI
AI will crazy push and grow more crazy.
I think AI need those API:
Got the units Num in some section that belong someone.
Got the units Properties,for example, CON(Factory should belong CON)/build what(build/units)/SHIP/AIR/WEAPON/LAND/COMMDER/MadeTime/Cost/health/Climbing ability/Draft degrees/Attack from
Order the units Num in some section that belong self.
Got the Surface Properties,for example:Metal production/Gradient(lava Gradient=255,lol)/Water Depth
I think AI need those API:
Got the units Num in some section that belong someone.
Got the units Properties,for example, CON(Factory should belong CON)/build what(build/units)/SHIP/AIR/WEAPON/LAND/COMMDER/MadeTime/Cost/health/Climbing ability/Draft degrees/Attack from
Order the units Num in some section that belong self.
Got the Surface Properties,for example:Metal production/Gradient(lava Gradient=255,lol)/Water Depth
Re: ta3d AI
A Quadtree may be useful too. But I don't know what kind of algo you want to implement.
Damien Gerard
Ta3d & Yuni Developer
Ta3d & Yuni Developer
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
I also planned to implement some algorithms used in computer vision (this is my field :p) like k-means (which could be used to get the number and the position of enemy/ally bases), as well as a few things related to machine learning (like neural networks, TA3D already has the classes for that).
=>;-D Penguin Powered
Re: ta3d AI
I just want made some routine that useful in fight.For example,build defence based on metal and surface access.
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
Ok, I've added several functions that should fill most of your needs, except there is no map related function yet (you can get information about units, their type, build list, name (for debugging it may help), etc ...).
Have a look at lua_prototypes in SVN and tell us what is missing.
Have a look at lua_prototypes in SVN and tell us what is missing.
=>;-D Penguin Powered
Re: ta3d AI
A group API,that group some units for order.
And a API that return weather Units group is Ok to pass some ground.
And that Metal surface....
And a API that return weather Units group is Ok to pass some ground.
And that Metal surface....
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
grouping should be implemented in Lua because it involves reading an array which is not really fast from C code. Maybe you could write some interface functions in Lua that would call C functions for all units in an array, naming them like:
Code: Select all
add_attack_mission_group( array_of_unit_index, ... normal parameters)
=>;-D Penguin Powered
Re: ta3d AI
Ok,i will write some LUO lib for devlop.
Re: ta3d AI
Code: Select all
NewGroup
GroupAdd
GroupOrder
GroupExist
function NewGroup (GroupID)
GroupID.Num= 0
GroupID.invalid= 0
return GroupID
end
function GroupAdd (GroupID, UnitID)
if GroupID.invalid= 0
then
GroupID["Unit" .. GroupID.Num]= UnitID
GroupID.Num= GroupID.Num+ 1
else
GroupAdd (NewGroup (GroupID), UnitID)
end
return GroupID
end
function GroupMove (GroupID, pos_x, pos_z)
for (i=0; i< GroupID.Num; i= i+ 1)
add_move_mission ( GroupID["Unit" .. i], pos_x, pos_z )
end
end
function GroupAttack (GroupID, target_id)
for (i=0; i< GroupID.Num; i= i+ 1)
add_attack_mission ( GroupID["Unit" .. i], target_id )
end
end
function GroupGuard (GroupID, target_id)
for (i=0; i< GroupID.Num; i= i+ 1)
add_guard_mission ( GroupID["Unit" .. i], target_id )
end
end
function GroupPartrol (GroupID, pos_x, pos_z)
for (i=0; i< GroupID.Num; i= i+ 1)
add_patrol_mission( GroupID["Unit" .. i], pos_x, pos_z )
end
end
function GroupExist (GroupID)
if GroupID.invalid= 0 then
for (i=0; i< GroupID.Num; i= i+ 1)
if has_unit( Me, GroupID["Unit" .. i])==false
local tmp= i+ 1
GroupID["Unit" .. i]= GroupID["Unit" .. tmp]
GroupID["Unit" .. tmp]= nil
end
end
return ture
end
return false
end
I think there maybe series of groupAPI can be call, thus it will eazy to Control units
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
In Lua functions do not need to be declared like in C/C++, so your first 4 lines raise an error.
For loops are constructed like this: for var = start, end[, step do] ... end
since tables are a mix of arrays and hash tables, it's better to use the array when possible (which starts at 1 not 0 ...)
I rewrote your code in a way that should not raise errors:
then you can do:
You can also create a generic function, then create functions that will call it with a parameter
AI scripts will be started by the thread that monitors players (the last thread to be started), so it'll start in game (not at loading time).
I hope it helps
For loops are constructed like this: for var = start, end[, step do] ... end
since tables are a mix of arrays and hash tables, it's better to use the array when possible (which starts at 1 not 0 ...)
I rewrote your code in a way that should not raise errors:
Code: Select all
function NewGroup ()
local GroupID = {Num = 0, -- starts with 0 units in the group
Add = GroupAdd, -- allows object like calling convention: group:Add(myUnitID)
Move = GroupMove,
Attack = GroupAttack,
Guard = GroupGuard,
Patrol = GroupPatrol,
Exist = GroupExist};
return GroupID
end
function GroupAdd (GroupID, UnitID)
if GroupID ~= nil
then
GroupID.Num = GroupID.Num + 1
GroupID[GroupID.Num] = UnitID
else
GroupID = GroupAdd (NewGroup (), UnitID)
end
return GroupID
end
function GroupMove (GroupID, pos_x, pos_z)
for i = 1, GroupID.Num do
add_move_mission ( GroupID[i], pos_x, pos_z )
end
end
function GroupAttack (GroupID, target_id)
for i = 1, GroupID.Num do
add_attack_mission ( GroupID[i], target_id )
end
end
function GroupGuard (GroupID, target_id)
for i = 1, GroupID.Num do
add_guard_mission ( GroupID[i], target_id )
end
end
function GroupPartrol (GroupID, pos_x, pos_z)
for i = 1, GroupID.Num do
add_patrol_mission( GroupID[i], pos_x, pos_z )
end
end
function GroupExist (GroupID)
if GroupID ~= nil then
for i = 1, GroupID.Num do
if not has_unit( Me, GroupID[i]) then
local tmp = i + 1
GroupID[i] = GroupID[tmp]
GroupID[tmp] = nil
i = i - 1
end
end
return true
end
return false
end
Code: Select all
group = NewGroup()
group:Add(1)
GroupAdd(group, 2)
Code: Select all
function GroupCall (GroupID, F, ...)
for i = 1, GroupID.Num do
F ( GroupID[i], ... )
end
end
GroupMove = function (GroupID, ...) GroupCall (GroupID, add_move_mission, ...) end
I hope it helps
=>;-D Penguin Powered
Re: ta3d AI
There a big problem,when the units dead or lose by other ways,how to got this and delete this UnitID form GroupID.
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
Units have an ID which identifies them in the engine data structures and a UUID (Unique Unit ID) which identifies a unit for the whole game as opposed to ID which is a slot in an array (if the unit dies it can be replaced which is confusing ... but the new unit will have a higher UUID).
You can use get_unit_data (which returns a table when the unit exists), it'll return nil if the unit doesn't exist, and the UUID will be different if the unit has changed.
You can use get_unit_data (which returns a table when the unit exists), it'll return nil if the unit doesn't exist, and the UUID will be different if the unit has changed.
=>;-D Penguin Powered
Re: ta3d AI
It's cool!Units have an ID which identifies them in the engine data structures and a UUID (Unique Unit ID) which identifies a unit for the whole game as opposed to ID which is a slot in an array (if the unit dies it can be replaced which is confusing ... but the new unit will have a higher UUID).
Nice set,i think it made AI libs more eazy!
How about Build?Will unit auto put metal Collector on above metal?The AI must build defence in the light of metals.
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
In the C API there is a function that finds the best place for buildings, with some specific code for metal extractors. I'll add a similar one in the Lua API.
=>;-D Penguin Powered
Re: ta3d AI
Keep wait,when it finshed there will be a test AI,
Re: ta3d AI
There's a reason there are fruit
What's the time that TA3D call AI?
Just work as a thread?Or some matter made TA3D returen AI.
And some API are needed:
Section units enum,got a list,then be able to got how many enemy and the num of owner.Better the API be able to selecet spec type into list. Look like:
Got the player's energy and metal income/expand
Got one unit goto a pos through the length.
And i added a item to UnitID, UnitID.Group,will that work when I check the unitID's Group?
I don't know what's the x/y mean.Like x/y isn't pixel,do the x/y mean the waraframe?
Thus i just need addbuild to intent waraframe,Had i got it?
And i'm write a set of Got SPEC BUILD: veh/kbot/air ,adv veh/kbot/air, most suitable Energy maker/metal maker.Use the (HP*2+ DPS)/(energy/60+ metal+ time/10) to seek Best unit,every List should had own The best choice.
Something temporarily can not remember.Will added.
What's the time that TA3D call AI?
Just work as a thread?Or some matter made TA3D returen AI.
And some API are needed:
Section units enum,got a list,then be able to got how many enemy and the num of owner.Better the API be able to selecet spec type into list. Look like:
Code: Select all
section =
{
nw_x= 0;
nw_y= 0;
se_x= 0;
se_y= 0;
}
SecUnits (localplayer (), CORCA, section)
Got one unit goto a pos through the length.
And i added a item to UnitID, UnitID.Group,will that work when I check the unitID's Group?
Code: Select all
function GroupAdd (GroupID, UnitID)
if GroupID ~= nil
then
GroupID.Num = GroupID.Num + 1
GroupID[GroupID.Num] = UnitID
UnitID.Group = GroupID --xp addtion
else
GroupID = GroupAdd (NewGroup (), UnitID)
end
return GroupID
end
Thus i just need addbuild to intent waraframe,Had i got it?
And i'm write a set of Got SPEC BUILD: veh/kbot/air ,adv veh/kbot/air, most suitable Energy maker/metal maker.Use the (HP*2+ DPS)/(energy/60+ metal+ time/10) to seek Best unit,every List should had own The best choice.
Something temporarily can not remember.Will added.
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
Yes, AIs run as separate threads.
You can add everything you want in a UnitID table, but beware that it won't change the way C API will behave : it'll still create the same kind of UnitID tables, so be careful because it might overwrite some needed information.
I'll add the required functions to the API when I have time.
You can add everything you want in a UnitID table, but beware that it won't change the way C API will behave : it'll still create the same kind of UnitID tables, so be careful because it might overwrite some needed information.
I'll add the required functions to the API when I have time.
=>;-D Penguin Powered
Re: ta3d AI
I just made a mark in the missing API.So it's np.
I think separate threads mean AI couldn't got thing without driving call.
There are a series of "Prototypes for global environment manipulation",what AI can do by that?
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
AIs could share information for example, coordinate their attacks, etc ... or they could be given some instructions by scenario scripts since all Lua scripts can access the global environment
=>;-D Penguin Powered
Re: ta3d AI
share information by global environment manipulation?
Does set a missing global environment mean create new one?
Does set a missing global environment mean create new one?
- zuzuf
- Administrateur - Site Admin
- Posts: 3281
- Joined: Mon Oct 30, 2006 8:49 pm
- Location: Toulouse, France
- Contact:
Re: ta3d AI
yes, it does. Currently tables are not supported by this global environment, if needed I'll add support for them.
=>;-D Penguin Powered
Re: ta3d AI
Really cool job.
I'm considing AI ally,and some share for improve the performance of game.For example, share total units/build list/most info
Who is online
Users browsing this forum: No registered users and 12 guests