You must be logged in to post messages.
Please login or register

Modding and Scripting
Moderated by Yeebaagooon, nottud

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: AoM AI Tutorial, Courtesy of Captn_Kidd
« Previous Page  1 2 3  Next Page »
posted 22 November 2002 00:45 AM EDT (US)   
Edit on 1/29/2003: I've updated the tutorial by adding chapters 4 and 5, and including chapters 1-3 in RTF format. Chapters 4 and 5 do detailed overviews of two styles of AI scripts for scenario opponents. One has no real economy, and follows tightly specified actions at specific times...making it more rigid but very controllable. The other has a very simple economy, and has a lot of flexibility in what to do - making it less predictable for the designer but more flexible in play.
- Captn_Kidd

Courtesy of Captn_Kidd of Ensemble Studios, a new Tutorial on AI Scripting has just been posted in the Downloads Section.

This file contains a sample scenario and AI script, and three chapters of tutorial info to get people started in AI scripting. There's a lot left to cover, so more will likely be added after Thanksgiving.

The tutorial can be downloaded here:
AoM AI Tutorial (Revision 2), by Captn_Kidd

Many thanks to Captn_Kidd for this excellent tutorial!

The Chapter 1 file contains info about setting up your system config and unzipping and storing the files, so it would likely be wise to copy and paste it here:


Chapter 1:

This chapter walks you through the steps needed to install the tutorial files and configure your system for easiest AI development. It assumes that you have visual studio, but any text editor that displays line numbers can also be used.

First, store the ".scn" file in your AoM scenario directory. Store all the others in your AoM AI directory.

Next, create a user.cfg file in your AoM startup directory, and include these three lines in it:

aiDebug
showAIEchoes
developer

Then, create a user.con file in the AoM setup directory, and add this line:

map ("alt-shift-d", "root","gadgetToggle(\"XSDebugger\")")

These changes give you access to ai debugging info.

If you're using visual studio as your editor, it helps to tell it that "xs" file extensions use C language syntax, so it highlights key words and comments properly. To do that, find the registry setting for

HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\TextEditor\Tabs/Language settings\C/C++\FileExtensions

and append ";xs" to the end of the list.

In general, it will be easiest to configure your desktop this way:

Dev studio running with the XS file in the foreground, covering the top 2/3 of the screen.

The reference.txt file opened in a background window in dev studio.

The current chapter .txt file opened in notepad, in a small window on the bottom 1/3 of the screen, adjusted to a comfortable reading width. (Dev studio doesn't support word wrap, so entire paragraphs show up as one line scrolling off the screen.)

Finally, if you want to be able to run AI vs AI battles (no human player) in the normal single player interface, you'll need to take these steps:

1) Create a new profile in the options screen, named AIvsAI.
2) Using that profile, start a 1v1 RM AI game (you vs. AI.) Quit a few seconds in, exit AoM.
3) Open AIvsAI.prf (in the users directory) and edit the playerid 0 data by setting type=1, inserting "default" as the aiscript value, and 9 as the civilization (random). Save the AIvsAI.prf. Your playerdata section for playerid 0 should look like this:



0
default
1
9

4) Select the AIvsAI.prf profile when you want to set up AI vs AI battles.

Your system is now set up to do some AI development. On to chapter 2!


The Rasher
rasher@accesswave.com
[IMG]http://www.freeyellow.com/members6/therasher/Thomas.jpg[/IMG]
"You must succeed, to bring the Winds of Light into the age of darkness."
-Old Man, Magnus

[This message has been edited by Captn_Kidd (edited 01-29-2003 @ 01:55 PM).]

Replies:
posted 22 November 2002 03:18 AM EDT (US)     1 / 54  

very good, hats off to Kidd

so when is the next AI wars Rasher?

or waiting for the community to develop more?


Can you do the Double Yoda?
A sexual move, where you do a double backflip, insert your penis into the orifice of choice, and scream, "Afraid are you?"
posted 22 November 2002 06:26 AM EDT (US)     2 / 54  
This tutorial is a really good start!
The only feedback I can give about the tutorial is that it is (so far) not as clear as the Conquerors AI Tutorial. I mean still not everything is explained. But it is not complete as you mentioned, and a lot of things are still unrevealed.
I would be pleased to check things out if my processor didn't have a meltdown yesterday
You will probably hear from me again when the tutorial is finished THANKS A LOT!

Creator of Conquerors "Saiyan_AI".
posted 22 November 2002 11:15 AM EDT (US)     3 / 54  
Part of the chapter 1 file above didn't show up properly in that post. I had to remove the braces to make it display properly on this web site. It should look like this...but the actual TXT file includes the braces.

Your playerdata section....

singleplayerrandommapdata
playerdata
playerid0/playerid
aiscriptdefault/aiscript
type1/type
civilization9/civilization
/playerdata

Much more to come. Next I'll add a short summary of "what's different in AoM" for AoK scripters, which should help...the entire approach has changed radically. After that, progression plans, research, defend plans, attack plans and so on.

This should be enough to get you started and using the tools. Have fun.

[This message has been edited by Captn_Kidd (edited 11-22-2002 @ 11:21 AM).]

posted 22 November 2002 12:10 PM EDT (US)     4 / 54  

Quote:

so when is the next AI wars Rasher?


Patience, my friend... patience is a virtue.

Translation: I have no sweet clue, but I wouldn't hold your breathe. There won't be any AI-related contests or events until people have been given a chance to adjust to AI-scripting in AoM.


The Rasher
rasher@accesswave.com
[IMG]http://www.freeyellow.com/members6/therasher/Thomas.jpg[/IMG]
"You must succeed, to bring the Winds of Light into the age of darkness."
-Old Man, Magnus
posted 22 November 2002 12:18 PM EDT (US)     5 / 54  
A big thanks for helping people get started with AI's, Captn_Kidd. I can't wait to see what people produce.

TheShædøwDåwn
If you're like me, then it's possible you're a clone generated from my stolen DNA. I suggest you turn yourself in for destruction immediately.

[This message has been edited by TheShadowDawn (edited 11-22-2002 @ 12:19 PM).]

posted 22 November 2002 01:25 PM EDT (US)     6 / 54  
MUWHAHAHAHAHA!!!

Thanx Kidd! I wub ya!

Although I already know some of them

DGDN.Net has posted an article about the .xml files for Random Map scripts http://dgdn.net/dgdn.php?id=142&&cat=article_pages&&cat_ID=7&&heading_ID= 2

[This message has been edited by Zycat (edited 11-22-2002 @ 01:53 PM).]

posted 23 November 2002 12:10 PM EDT (US)     7 / 54  
*Worships Captn_Kidd*

Great tutorial, really made me interested in having a go at AI scripting.


! seilims eht rof elims
posted 24 November 2002 01:37 AM EDT (US)     8 / 54  
Kidd, I still have some questions unanswered...

* Are all of the aiChat commands REALLY REMOVED?
* How do you "COMMUNICATE" (Data sharing, or stuff like that) between A.I players.
* How can I SAVE a few things and LOAD them from a file so I can make learning A.Is.
* Can you list all of the chat (comms) strings?
* Can you list all "cheating" commands (res cheats, "map hacks", etc.)
* Ideas for next tutorial : On the Unit Picker, Attack Goal, and How the Unit Picker, Resource Gatherer (script, cost, etc.), Attack Pathing, Building Placement really works although I know how the unit picker works a lot of people may not know, and I may miss some details about it.

Thx for your attention

posted 24 November 2002 04:15 AM EDT (US)     9 / 54  
How long will it be before the next tutorials out?

Oh and the alt-q ai menus are incredible!!


! seilims eht rof elims
posted 26 November 2002 09:17 PM EDT (US)     10 / 54  
Ermm.....
Is subresource Hunt (cAIResourceSubTypeHunt) OBSOLETE? I can't get that one to work.....
posted 30 November 2002 01:56 PM EDT (US)     11 / 54  
Im sure this would be great if i were trying to do AI, currently i am stuggling through rms
ill come back when im done with my first rm script.
posted 30 November 2002 02:56 PM EDT (US)     12 / 54  
Zycat,

Only aiEcho() does anything, and that is only visible in the window of the full-screen debugger.

To my knowledge, there is no AI-AI communication or data sharing method. Ditto on memory/learning between games.

I don't have a list of the comm strings, they're in the DB somewhere...but they're basically the stuff the AIs chat when unleashing a god power or aging up, etc. I also don't have a list of cheats, but they've been posted on some fan sites.

Thanks for the next-topic suggestions. I'll be working on the next phase late this coming week.

Nydhogg13,

I'm not at the office right now, but I think the subtypes that we ended up with are subTypeEasy and subTypeAggressive (or huntAggressive?). Use the aggressive one when you want them to go hunting big game, the "easy" one should let them get deer and zebras, etc.

posted 01 December 2002 11:05 AM EDT (US)     13 / 54  
My problem is, there are constants defined for sub types Hunt, HuntAggressive, and Easy. However, Hunt doesn't seem to work for me. At least your script doesn't use this. I want my script to prioritize hunting nearby deers rather than eating cows/chickens/berries right away 'cuz it's slower than hunting. HuntAggressive works, though, but is too dangerous to do in early game...

ESO : Heero_Yuy / Tonto_Zycat

[This message has been edited by Zycat (edited 12-01-2002 @ 11:07 AM).]

posted 02 December 2002 01:45 PM EDT (US)     14 / 54  
Zycat,

I understand, but I don't think it differentiates. It basically thinks of food as farming, fishing, "safe" and "aggressive".

posted 02 December 2002 07:23 PM EDT (US)     15 / 54  
*sigh*
I do expect AoM A.I scripting to be able to save files and communicate between A.Is...

aiSetWaterMap(gWaterMap);
aiSetRandomMap(true);

What does these functions do? I suspect if I remove the aiSetRandomMap(true); line I won't get 100% handicap on Titan...

And what these variables do in a gather plan :

aiPlanSetVariableFloat(gGatherGoalPlanID, cGatherGoalPlanMinResourceAmt, cResourceGold, 500.0);
//Resource skew.
aiPlanSetVariableFloat(gGatherGoalPlanID, cGatherGoalPlanResourceSkew, cResourceGold, 1000.0);


ESO : Heero_Yuy / Tonto_Zycat

[This message has been edited by Zycat (edited 12-03-2002 @ 12:41 PM).]

posted 05 December 2002 12:37 PM EDT (US)     16 / 54  
Zycat,

aiSetWaterMap(gWaterMap);

Tells the AI system that there might be oceans, so that it's valid to consider transporting.

aiSetRandomMap(true);

I had no clue, and had to ask the master on this one. Here's what BigDog says:
This tells the C++ part of the AI to operate in RM mode (as opposed to 'scenario' mode). In addition to being part of the trigger for the logic above, this also affects when attack plans go away (allowing scenarios to have attack plans go away when they're out of units, but not orphaned), allows attack plans to auto-go-away if the attacking player is resigned/dead in an RM game (whereas scenarios don't want that behavior), allows attack plans to do some intelligent switching of who they're attacking if they're in RM mode (e.g. the attack plan really wants to kill Player 1, but his Player 2 ally has walled Player 1 in, so it's okay to switch to attacking Player 2), allows the attack plan to give up trying to gather units after a certain time, and enforces less attack route changing than in scenario mode.

It will not affect handicap in Titan difficulty.


For the final two, variables in goals are just easy storage places for script variables. These are examples where the scripts look up those variables later, they don't do anything by themselves.

posted 08 December 2002 00:24 AM EDT (US)     17 / 54  
Ok, and do you know what's the equivalent of (attack-now) command in an attack plan?

ESO : Heero_Yuy / Tonto_Zycat
posted 09 December 2002 12:50 PM EDT (US)     18 / 54  
You just set it "active". If it has the minimum numbers of each unit you specified, and it knows of a valid target type, it will go to it.
posted 23 December 2002 12:28 PM EDT (US)     19 / 54  
I realize things got frantic with the 1.02 patch and the holidays, but any ETA on Chapter 2?

Cheers,
Slak

posted 06 January 2003 02:44 PM EDT (US)     20 / 54  
Working on it now. This week, sometime.
posted 09 January 2003 01:03 PM EDT (US)     21 / 54  
Sweet. I, er, unexpectedly, have a lot more free time on my hands, now.

Cheers,
Slak

posted 25 January 2003 01:29 PM EDT (US)     22 / 54  
Ey, Kidd, can you list attack plans' variables and what does it do?

Oh, and how to prevent my villagers to attack converted animals? Even if they're converted the villagers still hunt em, and I don't know how to stop it, Probably that's because I dunno how to clear the "KBResource" Tag for converted animals.

Converted animals counts as Economic, I think. They won't get into the attack group unless I create a separate attack plan for them.

And basically what's a goal?


ESO : Heero_Yuy / Tonto_Zycat

[This message has been edited by Zycat (edited 01-25-2003 @ 04:08 PM).]

posted 28 January 2003 02:38 PM EDT (US)     23 / 54  
>> Ey, Kidd, can you list attack plans' variables and what >> does it do?

Check the tutorial under debugging, I cover a few there. Frankly, I don't know what some of them do, or even if they're all still current. (It went through a lot of changes in development.) Best suggestions I can give are to look in the scenario AI files and watch the examples.

>> Oh, and how to prevent my villagers to attack converted >> animals? Even if they're converted the villagers still >> hunt em, and I don't know how to stop it, Probably
>> that's because I dunno how to clear the "KBResource" Tag >> for converted animals.

They're considered a safe food source, same as berries or chickens. The only way I know to do that is to tell them to get nothing but farms and aggressive animals, which will ignore berries and chickens. Alternatively, you could modify the herd plan and tell them to round up at a house or military building, that might keep them far enough away from a food dropsite to have the villagers overlook them. Weird question. ;-)

>> Converted animals counts as Economic, I think. They
>> won't get into the attack group unless I create a
>> separate attack plan for them.

Never tried it.

>> And basically what's a goal?

Basically, it's a place to store data that controls plans, and it's also a plan generator.

posted 28 January 2003 02:52 PM EDT (US)     24 / 54  

Quote:

They're considered a safe food source, same as berries or chickens. The only way I know to do that is to tell them to get nothing but farms and aggressive animals, which will ignore berries and chickens. Alternatively, you could modify the herd plan and tell them to round up at a house or military building, that might keep them far enough away from a food dropsite to have the villagers overlook them. Weird question. ;-)

Tried the "herding" plan, didn't work. The villies will go over them although they're FAR away. But my idea is, can I remove specific unit ID from a certain "KB resource"?

And my priests do convert aggresive animals so the first solution won't work.

Well that's mainly because I want my A.I to use Rhinos Eles Hippos or other BIG animals to attack...

[EDIT]
See the patch 1.03? Set is a lot of fun to script hehe.


ESO : Heero_Yuy / Tonto_Zycat

[This message has been edited by Zycat (edited 01-28-2003 @ 07:34 PM).]

posted 29 January 2003 11:15 AM EDT (US)     25 / 54  
Hmmm. Have you tried making a high-priority defend plan early on, and specifying those unit types (hippo, etc.), and giving it a location well behind your town?

There's no way that I know of to change the definitions of what a resource is.

« Previous Page  1 2 3  Next Page »
Age of Mythology Heaven » Forums » Modding and Scripting » AoM AI Tutorial, Courtesy of Captn_Kidd
Top
You must be logged in to post messages.
Please login or register
Hop to:    
Age of Mythology Heaven | HeavenGames