Page 1 of 2

Making Hard AI, hard?

Posted: Sat Apr 14, 2012 8:13 pm
by djwhitfield
Is there a way to make the Hard AI hard?

I played against 8 or 10 Hard AIs with two friends and they were simply too easy.
We expected 3 AIs to be enough, fighting one each. But 8 or 10 Hard AIs is still too easy for us. Any suggestions please?

Posted: Sun Apr 15, 2012 9:31 pm
by psydev
on that note, can we please have a new AI for CNC, other than "easy bot"?

Posted: Sat Apr 21, 2012 1:20 am
by earthpig
It's actually pretty easy to tweak some values and get different behavior.

open this in a text editor:

openra/mods/ra/rules/system.yaml

(er... probably c:\program files\openra\moda\ra\rules\system.yaml for you windows folks)

copy and paste the lines from "HackyAI@HardAI:" to "SquadSize", so you've not got two HardAIs.

change "@HardAI" to "@myTestAI" and give it a name such as "Name:my AI" (if you have two that are named HardAI, it'll crash on startup).

To see what the things under "BuildingFractions" and "UnitsToBuild" are, open up structures.yaml, infantry.yaml, and vehicles.yaml and look around. It's fairly self-documenting.

It is very easy to tweak these values and get different behavior, it is NOT however very easy to make the AI actually harder.

If you cut down on proc (ore processing facility) for example, the AI gets a very slow start early on in the game.

Here is something y'all may find interesting: Just as I was typing this, a bot that I've been tweaking attacked me... with aircraft!

EDIT: And that AI only built 4 ore refineries, too. :)

Posted: Sat Apr 21, 2012 1:51 am
by earthpig
grrrr... last game I got strafed by an AI (first time I ever managed to make it do that, got excited) and this game both the soviet and allied bot are sitting their with aircraft on the pad/field and doing nothing with them.

Hard AI

Posted: Mon Apr 23, 2012 3:33 pm
by zypres1
There are 2 ways of making AI harder.
In yaml in your maps you can also change what they are supposed to build, for each map.
They rotate in order in what to buid.

Questions:
1: what is harder, bigger squad size or smaller? Seems like it depends when in game it is..
2: https://github.com/OpenRA/OpenRA/issues/2014 would make the Ai harder, if you can limit on how many ore refins they are allowed to build.. Comment on it if you agree

Re: Hard AI

Posted: Sun Apr 29, 2012 5:41 am
by earthpig
zypres1 wrote: 1: what is harder, bigger squad size or smaller? Seems like it depends when in game it is..
Early in the game, smaller is harder. Later in the game, larger is harder.

For #1. I'm working on making it so the squad size that is sent is pseudo random, but still trends towards squadsize: https://github.com/OpenRA/OpenRA/issues/2048

I haven't gotten around to fixing what head honcho wants fixed in the code, but I will at some point.

thank you

Posted: Sun Apr 29, 2012 9:23 pm
by zypres1
Thank you for fixing this, Earthpig..

Challenge accepted!

Posted: Wed May 30, 2012 9:38 pm
by Matt
I created an AI with optimized build order that currently beats all available bots. Put this into your mods/ra/rules/system.yaml:

Code: Select all

	HackyAI@OptiAI:
		Name:Optimized AI
		BuildingFractions:
			proc: 25.1%
			powr: 35%
			tent: 0.1%
			barr: 0.1%
			weap: 0.1%
			fix: 0.1%
			dome: 0.1%
			atek: 0.1%
			stek: 0.1%
		UnitsToBuild:
			e1: 50%
			e2: 1%
			e3: 10%
			medi: 1%
			apc: 10%
			jeep: 10%
			ftrk: 25%
			1tnk: 25%
			2tnk: 50%
			3tnk: 75%
			4tnk: 100%
			arty: 30%
			v2rl: 30%
		SquadSize: 10
It builds less refinerys (it seems to stop at 5 in the end game, but builds the second one early after the barracks) and can spend therefore more money for units. It techs faster, but only builds each production building once (not 3 radar domes). It also builds more advanced units (Mammoth tanks and medics) which can give favor to it in battles. The attacks are still a little careful stopping at the base entry hunting harvesters down and using artillery to bomb down base defend buildings, but this seems to be the attack waypoint code. It won't build any turrets to become more offensive and because the placement algorithm is not very clever at the moment. https://github.com/OpenRA/OpenRA/issues/2064

Posted: Thu May 31, 2012 2:38 am
by Generalcamo
Hopefully I can improve that AI by adding the ability to build hero units.

Posted: Thu May 31, 2012 5:23 am
by Matt
Generalcamo wrote: Hopefully I can improve that AI by adding the ability to build hero units.
That is easy: just add e7 to units to build, but I doubt he will use C4 on buildings.

Re: Challenge accepted!

Posted: Fri Jun 08, 2012 7:11 am
by earthpig
Cmd. Matt wrote: I created an AI with optimized build order that currently beats all available bots. Put this into your mods/ra/rules/system.yaml:

Code: Select all

	HackyAI@OptiAI:
		Name:Optimized AI
		BuildingFractions:
...
			v2rl: 30%
		SquadSize: 10
It builds less refinerys (it seems to stop at 5 in the end game, but builds the second one early after the barracks) and can spend therefore more money for units. It techs faster, but only builds each production building once (not 3 radar domes). It also builds more advanced units (Mammoth tanks and medics) which can give favor to it in battles. The attacks are still a little careful stopping at the base entry hunting harvesters down and using artillery to bomb down base defend buildings, but this seems to be the attack waypoint code. It won't build any turrets to become more offensive and because the placement algorithm is not very clever at the moment. https://github.com/OpenRA/OpenRA/issues/2064
Call it Matt AI (or some other cooler name - I went with famous WW2 dudes for the "Rommel AI" and "Zhukov AI" that you now see, but Patton and Monty remain unclaimed) and submit it to the bug tracker.

Posted: Fri Jun 08, 2012 11:26 am
by Matt
Maybe all bots could get this new build order. If not then I will submit it as Eisenhower AI.

Another thing: at the end the bots seems to build the last building in the list multiple times even though it is just 0.1%. Maybe the power plant should be last so he won't waste money on another radar dome or tech center.

They also don't care too much about percentage in UnitsToBuild as medi: 1% will result in ~50% medics.

Posted: Sat Jun 09, 2012 5:13 am
by earthpig
I'd suggest going with a new AI rather than replacing anything that already exists. Then me (and others) can look at yours, experiment, synthesize, etc.

Posted: Sat Jun 09, 2012 10:00 am
by Matt
I added a patch at https://github.com/OpenRA/OpenRA/issues/2204 All my github branches are full of other stuff so I can't get a clean pull request. Now also with heroe units to fulfill Generalcamos wish. However he builds too many Tanyas ignoring the 0.01% setting (it's more like 30%).

Posted: Sun Sep 23, 2012 9:54 am
by zypres1
Please come back to help Valkirie.. He needs yaml help