CSAI vs AAI 0.75

CSAI vs AAI 0.75

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

Moderators: hoijui, Moderators

Post Reply
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

CSAI vs AAI 0.75

Post by hughperkins »

Tried a single match of CSAI vs AAI 0.75 on Small Divide, AA2.23

To my surprise CSAI won! Ok I got lucky, but it shows potential.

Here's the replay: http://manageddreams.com/csai/061023-Sm ... vs-aai.sdf

CSAI is in red at topleft
AAI is in blue at bottomright

Want to try for yourself? Get it here: [snipped, please see http://taspring.clan-sy.com/wiki/AI:CSAI for download link]

CSAI is written in C#, using an event-based publisher/subscriber architecture, so it's pretty easy to modify.
Last edited by hughperkins on 24 Oct 2006, 22:38, edited 1 time in total.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

New version of CSAI:

*commander no longer blocks himself in
*factory entrances no longer blocked
*scouts created

4 matches CSAI vs AAI 0.75 on Small Divide, AA2.23:

http://manageddreams.com/csai/061023-Sm ... 3b1-20.sdf (win)
http://manageddreams.com/csai/061023-Sm ... 3b1-21.sdf (win)
http://manageddreams.com/csai/061023-Sm ... 3b1-22.sdf (lose)
http://manageddreams.com/csai/061023-Sm ... 3b1-23.sdf (win)

2 matches CSAI vs AAI 0.75 on Comet Catcher Remake v02, AA2.23

[http://manageddreams.com/csai/061023-Comet Catcher Remake-v02-0.73b1.sdf] (stalemate)
[http://manageddreams.com/csai/061023-Comet Catcher Remake-v02-0.73b1-0.sdf] (win)

CSAI plays ok as ARM on landmaps running AA2.23.

Latest CSharpAI download: [snipped, please see http://taspring.clan-sy.com/wiki/AI:CSAI for download link]

Documentation moved to wiki:

*CSAI itself: http://taspring.clan-sy.com/wiki/AI:CSAI
*Global AI C# interface: http://taspring.clan-sy.com/wiki/AI:CSAIInterface
Last edited by hughperkins on 24 Oct 2006, 22:39, edited 1 time in total.
User avatar
BvDorp
Posts: 439
Joined: 14 Oct 2005, 12:09

Post by BvDorp »

Interesting project!

From what I've seen on the Net about AI, there are several games, developed to provide a training base for AI developers. You think Spring will be ready for that kind of thing anytime soon?
Chojin
Posts: 141
Joined: 04 Oct 2006, 11:22

Post by Chojin »

Hi Hugh,

I get this error when spring is spawning CSAI:

Code: Select all

GlobalAI1: Metal analyzer rebuilding cachefile
GlobalAI1: Creating new cachefile for mod XTAPE.sd7
GlobalAI1: C# AI initialized v0.0008, team 1
GlobalAI1: Please say '.csai help' for available commands
GlobalAI1: Exception: System.NullReferenceException: Object reference not set to an instance of an object.

   at AICallbackToGiveToCS.ClosestBuildSite(IUnitDef unittobuilddef, Float3 targetpos, Double searchRadius, Int32 minDistance)

   at CSharpAI.CommanderController.CommanderBuild(IUnitDef unitdef) in 
h:\dev\test\CSharpAI\CSAI\CommanderController.cs:line 211

   at CSharpAI.CommanderController.CommanderBuildPower() in h:\dev\test\CSharpAI\CSAI\CommanderController.cs:line 233

   at CSharpAI.CSAI.InitAI(IAICallback aicallback, Int32 team) in h:\dev\test\CSharpAI\CSAI\CSAI.cs:line 127
GlobalAI1: Exception: System.NullReferenceException: Object reference not set to an instance of an object.

   at AICallbackToGiveToCS.ClosestBuildSite(IUnitDef unittobuilddef, Float3 targetpos, Double searchRadius, Int32 minDistance)

   at CSharpAI.CommanderController.CommanderBuild(IUnitDef unitdef) in h:\dev\test\CSharpAI\CSAI\CommanderController.cs:line 211

   at CSharpAI.CommanderController.CommanderBuildPower() in h:\dev\test\CSharpAI\CSAI\CommanderController.cs:line 233

   at CSharpAI.CommanderController.DoSomething() in h:\dev\test\CSharpAI\CSAI\CommanderController.cs:line 132

   at CSharpAI.CommanderController.UnitFinished(Int32 deployedunitid, IUnitDef unitdef) in h:\dev\test\CSharpAI\CSAI\CommanderController.cs:line 280

   at CSharpAI.CSAI.UnitFinishedHandler.Invoke(Int32 deployedunitid, IUnitDef unitdef)

   at CSharpAI.CSAI.UnitFinished(Int32 deployedunitid) in h:\dev\test\CSharpAI\CSAI\CSAI.cs:line 175
Maybe because I have .NET Framework 2.0 installed instead of 1.1?
Chojin
Posts: 141
Joined: 04 Oct 2006, 11:22

Post by Chojin »

OK, I just installed 1.1 (with sp1 and that hotfix) and still get the same error. I forgot to mention that the Commander of CSAI is not doing anything :(
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

CSAI needs AA2.23 to run at this time. Also, the AI must be playing ARM.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

From what I've seen on the Net about AI, there are several games, developed to provide a training base for AI developers. You think Spring will be ready for that kind of thing anytime soon?
Spring is ready for that now. Spring is awesome.

Btw, I've been meaning to say at some point that whoever added the code to Spring to make GlobalAIs possible, this is so cool! The GlobalAI interface is well done, it's easy to port to different languages, and it works well.
Last edited by hughperkins on 24 Oct 2006, 18:22, edited 1 time in total.
Chojin
Posts: 141
Joined: 04 Oct 2006, 11:22

Post by Chojin »

CSAI plays ok as ARM on landmaps running AA2.23.
Oh, didn't recognize this to be a requirement. Thanks.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

SJ added the globalAI interface, however I find it not to be well done sicne despite cain and jelmer deciding on a way to expand the interface, I am the only one who has bothered to actually make use of it, and every other patcher has flewn in the face of the agreement and added methods directly to IGlobalAI and IAICallback, making it even more spaghetti like, rather than doing ti the correct way.

Also, there are [quote] tags, they're much more convenient/clearer than using email style quoting....
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

SJ added the globalAI interface, however I find it not to be well done sicne despite cain and jelmer deciding on a way to expand the interface, I am the only one who has bothered to actually make use of it, and every other patcher has flewn in the face of the agreement and added methods directly to IGlobalAI and IAICallback, making it even more spaghetti like, rather than doing ti the correct way.
What is the official method for expanding the interface?

Note that for purposes of porting the interface to other languages, keeping all methods in just a few classes works quite well. Methods and properties with simple, non-pointer types can be easily, and automatically, ported.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

The main problem is that AI's use springs internal UnitDef structures (and others), so whenever a new spring is releases, the binary compatibility is broken and AIs have to be re-released as well.

It would be really great if we make this CSAI thing portable btw, so it can be included in spring itself. If people would then change to .NET for AI writing, you have a system where linux users and windows users can use the same AI releases and where AI's don't have to be re-released with new spring versions!
Sheekel
Posts: 1391
Joined: 19 Apr 2005, 19:23

Post by Sheekel »

/me demands EE compatability
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

New release of CSAI

[snipped link]

*Metal maps now supported
*Pack grouping heuristic added
*Enemy selection algorithm improved
*Added memory for enemy buildings

Replay fighting AAI on SpeedMetal, AA2.23:

http://manageddreams.com/csai/061025-Sp ... 73b1-2.sdf
Last edited by hughperkins on 25 Oct 2006, 19:28, edited 1 time in total.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

But then the C# interface would need changing every release and we'd need to support the extras so we'd release anyway.
and perkins:

IAICallback:
HandlCommand()
GetValue()

IGlobalAI:

HandleEvent()

All further additions where meant to be passed through these functions so that the interface did not change. Instead people decided to go around the agreement and directly add new methods to the IAICallback and IGlobalAI interfaces, despite doing changes to IGlobalAI becoming very annoying for us major AI developers who had to change to support it, when we only should be supporting the events we want to use, not to mention how much messier it made the interface. It also encourages directly calling the AI within spring rather than calling a function of the AI handler, which is what would be needed by the agreed method, thus introducing inflexibilities and future issues, aswell as making it more awkward to change the code, aswell as for people to track down where these calls are coming from..

Colorblind is particularly bad when it comes to this and did the most of changes that dont conform, and is still doing so with the groupAI interface.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Chojin wrote:
CSAI plays ok as ARM on landmaps running AA2.23.
Oh, didn't recognize this to be a requirement. Thanks.
Ok, CSAI now supports XTA7, running as ARM.

It turned out to be a trivial modification, and that standard tank rush tactics still work, at least against AAI.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

AF wrote:But then the C# interface would need changing every release and we'd need to support the extras so we'd release anyway.
I think that jcnossen's point is that if the C++/C# interface were integrated into Spring itself, then it would be recompiled automatically anyway, and the actual C# AIs might not need recompilation.

We could possibly make this the case by, for example, making IGlobalAI in the C# interfaces no longer an interface, but a class with empty methods. Then, if we want to implement a method, we override it in our derived class.

Code: Select all

class GlobalAIBase
{
   public void UnitIdle( int id )
   {
   }
}
Then it's valid to do simply:

Code: Select all

class MyAI : GlobalAIBase
{
}
but we can also choose to implement the method:

Code: Select all

class MyAI : GlobalAIBase
{
   public override void UnitIdle( int id )
   {
   }
}
By the way, pretty sure that the C# interface supports any .Net language, not just C#, so for example Boo (Python .Net) is also supported. It's just another bytecode assembly.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I object to keeping unitID's, and instead think that somewhere along the id's should be translated into a CUnit class with cached UnitDefs and positions aswell as methods for basic commands such as move repair etc...
Post Reply

Return to “AI”