** New AI ** Das Geändert Aggressiven Schwarm!

** New AI ** Das Geändert Aggressiven Schwarm!

A fresh perspective on battle for control of Earth, brought to you by Sanada and Snoop.

Moderators: Moderators, Content Developer

yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

(Title means: the modified aggressive swarm , according to Google Translate)

I've been tinkering with knorke's AI for Conflict Terra (Das Schwarm), and it produced this. New features are:

-Engineers walking around now reclaim any wreckage they see.

-Now uses factories instead of cloning (cloning had a tendency to paralyze the drone's economy, so I disabled it)

-Now patrols the map better

-Now has a better economy and stronger army, in terms of metal mining and unit numbers and build order.

-NOW HAS MILITARY LOGIC! The Schwarm will send it's army to any place it detects a drone under fire. (Note: this feature is currenly... hypersensitive. It often responds to slight damage from falling meteors with a full-on military offensive). In a test, the drones were able to find and destroy several dummy targets placed on the map.


I'm quite proud of my modifications, considering that I'd never seen Lua or Spring source code before starting on this.

Enjoy! Latest source is attached.
Attachments
tp_schwarmAI.lua
(21.38 KiB) Downloaded 157 times
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by SanadaUjiosan »

How easy do you think it would be for a player to set up a trap, such as attack a drone at Point A, and then move into the drone base at far away Point B while the army scuttles to Point A?
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

mmm.

army will auto-redirect to the most recent point of conflict. At least, it should. I'll do combat tests tomorrow.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by knorke »

cool.
being able to "poke" the AI and see it react is definately nice.

at one point you do

Code: Select all

for t in pairs(myTeam) do
  if (unitTeam == myTeam[t]) then
to find out if the AI controlls this unit.
I already made this as a function, better use this:

Code: Select all

--is team controlled by me?
function isTeamCBM (teamID)
-Now uses factories instead of cloning (cloning had a tendency to paralyze the drone's economy, so I disabled it)
Well yes, that happens but the real problem is something different:
knorke in other thread wrote:Making better "stages-lists" is probally not much use right now as first the makeSomeUnits() would have to be fixed to follow the list more closely. Right now it often builds more units then defined.
So disabling cloneing is merely a workaround.
Shortterm it makes the AI play better but for real improvements all that stuff needs to be fixed/rewritten.

UnitDamaged() might get called very frequent, ie if a unit is attacked by a beam laser it gets called every frame. That is okay for small calculations (like the miner[unitid].cargo =miner[unitid].cargo +1 in the harvesting gadget) but if you loop through alot of units like the AI does, it can potentially use alot of CPU.
army will auto-redirect to the most recent point of conflict.
If the units are send to wherever a unit just took damage, they might go nowhere if they are in the middle of two attacks.
I already made this unitOnMission thing to avoid units being given multiple tasks at once:
You can do
unitOnMission [unitID] = 30
(this counter will go down by 1 every frame and you can check if the unit is busy by if unitOnMission [unitID] > 0)
Currently it is only used by moveAway () and doesUnitWantBuildJob () to make sure that a unit that is moving away from the factory does not instantly start to build something. (because that would block the factory)

So just

Code: Select all

UnitDamaged()
set_waypoint (location of attack)
is not enough for military logic. The economics are so easy to adjust because there is this stages thing where it all it takes is changing some numbers.
The miliatary side needs something similiar
ie rate map locations by danger/presence of enemy and then only near units react etc.
Otherwise it will quickly hit a barrier.

There is more but you will figure that out pretty quick yourself if you continue like this ;)
Still at this point I would not want to merge your changes into my version because imo they are "too hackish" and tinker with the symptomes instead of fixing the real problems.
Ok, that sounds stupid/arrogant when my code is far from perfect as well but dont know how else to say it, no offense ;)
blablablub

Did you talk to Sanada about commit acess to SVN?
I have no problem if you want to take over this AI (or AI in general), in fact I have too many open projects anyway.
For start we could have two seperate files (like schwarmAI_knorke.lua and schwarmAI_yanom.lua) (I want to test some things myself first.)
To do that, LuaAI.lua will have to be updated (just copy&like the existing entries) as well as the gadget:GetInfo() (name etc) at top of the AI script.
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

Ill work on those improvemments when I get home
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

knorke wrote:cool.
being able to "poke" the AI and see it react is definately nice.
indeed it is.

at one point you do

Code: Select all

for t in pairs(myTeam) do
  if (unitTeam == myTeam[t]) then
to find out if the AI controlls this unit.
I already made this as a function, better use this:

Code: Select all

--is team controlled by me?
function isTeamCBM (teamID)
fixed
Well yes, that happens but the real problem is something different:

the makeSomeUnits() would have to be fixed to follow the list more closely. Right now it often builds more units then defined.
what exactly about it is broken that I must fix?
UnitDamaged() might get called very frequent, ie if a unit is attacked by a beam laser it gets called every frame. ... if you loop through alot of units like the AI does, it can potentially use alot of CPU.
I noticed that, yes. What can I do about it?
Did you talk to Sanada about commit acess to SVN?
I have no problem if you want to take over this AI (or AI in general), in fact I have too many open projects anyway.
For start we could have two seperate files (like schwarmAI_knorke.lua and schwarmAI_yanom.lua) (I want to test some things myself first.)
To do that, LuaAI.lua will have to be updated (just copy&like the existing entries) as well as the gadget:GetInfo() (name etc) at top of the AI script.
I guess I could start committing to SVN... but I've never used it before, so I don't know how it works, exactly. And I'm kinda afraid that I'll accidentally overwrite important things on the SVN or something.
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by oksnoop2 »

Oh, the svn is pretty simple stuff. Just PM me with your gmail and i'll give you access.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by zwzsg »

yanom wrote:
knorky wrote:UnitDamaged() might get called very frequent, ie if a unit is attacked by a beam laser it gets called every frame. ... if you loop through alot of units like the AI does, it can potentially use alot of CPU.
I noticed that, yes. What can I do about it?
In the UnitDamaged, just store where the damage took place. Then, in the GameFrame, once every x second (use a modulo on the frame count), check if a unit was attacked recently, and decide there to mount a counterattack.
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

ok, I solved the problem of unitDamaged sucking CPU by replacing it with unitDestroyed.

I watched it do more target practice, and it's pretty cool IMO. One little scout will wander in front of the target (an inert mobile-hq cruiser), the cruiser will blast it, and congrats cruiser, you just ticked off the hornets nest. The map will drain of drones as they all rush toward the cruiser and annihilate it. Then the engineers will reclaim the wreckage and the dead drones. (IDK why engineers get sent as part of the war group, but there pretty useful support units, as they repair in combat)

latest source is attached.
Attachments
tp_schwarmAI.lua
(21.03 KiB) Downloaded 124 times
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by SanadaUjiosan »

I totally think a Knorke Schwarm and Yanom Schwarm AI would be cool, the more AI the better. It could be fun to see whose is better in the "end"

I'm guessing Snoop is or will get you up to speed on SVN stuff. We can revert to previous revisions if you do do something catastrophic, and know that your revisions will be checked by me :twisted:
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

I'm having trouble getting both AI's in there. Currently, both the files tp_schwarmAI.lua and tp_YMSAI.lua are in the Gadgets directory and contain the same code (schwarm with my revisions), and the LuaAI.lua file says:

Code: Select all


local listOfLuaAIs = {
    {
        name = "KTAI",
        desc = "knorkes TEST ai. CRASH DANGER. safer to watch on a video: http://www.youtube.com/watch?v=aOtnOEOtVTM",
    },
    {
        name = "SchwarmAI",
        desc = "Knorke's AI for the drone's faction",
    },
	{
		name = "YMSAI",
		desc = "Yanom's Modified Schwarm AI",
	},
}
return listOfLuaAIs
when I start up springlobby, I see both Schwarm and YMSAI in the "Add bot" window. However, upon running the game, the AI only works if you choose the "Schwarm" option, not the "YMSAI" option.

However, both files are exactly the same

does anyone know why this is happening?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by knorke »

in the AI gadgets, at top in gadget:getInfo
change the name=
to the same value as in the LuaAI.lua
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

oh, ok, it's fixed now.

Question is, how do I submit the 1 new file and 1 modified file to SVN?

I've never used SVN before.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by knorke »

Have you installed a SVN programm? turtoise svn is ok.
After editing and saving a file it should have a red (!) symbol on its icon in windows explorer.
rightclick on file-> "SVN Commit" -> enter a message ("i changed this & that") -> ok
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

knorke wrote:windows explorer.
*vomits*

I'm on linux. I installed a SVN package, time to dig through the documentation....

I can comit just individual files, right, and not the whole package?
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

ok, I got SVN working but the repository keeps rejecting my username and password:

Code: Select all

Username: rothj1459@gmail.com
Password ***********************************

Also, I saw there was a thing on the googlecode website to commit files, but it kept saying "unknown server error"
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

ok, I got the web interface going.... added my changes.
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by MidKnight »

NautilusSVN (I think they renamed to 'rabbit' or something) is good. Try that, if you want SVN/explorer integration.
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

kk thx.

btw, what exactly about makeSomeUnits() is broken?
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: ** New AI ** Das Geändert Aggressiven Schwarm!

Post by yanom »

combat trials are in. Results were... remarkable.

I'm not going to post the replay here, because it's quite embarrassing to have one's *** handed to him by one's own creation*.


*well, it's knorke's creation too. he wrote most of the code.
Post Reply

Return to “Conflict Terra”