-
Challenge for all modders out there
Now, with modders exploring the world of RTW scripting, why not to try it out, what the scripts can really do for RTW. Namely, to fix one incomplete (read: nonexistant) feature: Tactical Battlefield AI.
The Challenge:
Therefore, I challenge all capable modders of the RTW community to create a tactical battlefield AI.
AI should be able to hold a coherent battleline and execute/counter flanking manouvers with a good army. That's it. It doesn't have to be a military genius, just something that gets a job done, or at least behaves like it would try to get the job done, neither it desn't have to be campaign-compatible. Just make a custom battle with the AI.
There are plenty of useful scripting commands out there, and I'm sure we can do a better AI with them than what it is now. I know we can. We just have to do it.
Once the AI is complete the modders may get an elusive bogus price.
-
Re: Challenge for all modders out there
I noticed that some historical battles and the prologue battles already have scripted AI.
-
Re: Challenge for all modders out there
Yes, but most of those scripts are run intro, some are used to keep units marching from place a to place b (siege of sparta) where they are released from script control. In Gergovia the Gauls are ordered to charge, then control is released. The only script controlling units for some time into te battle is Trebia. There the script only makes the romans march straight to player in formation, and once a unit is close engough to player's unit, it attacks.
Actually, that is something our normal AI lacks: keeping formation. But the AI we need would have to be a bit smarter. We still need some manouvers. We need something that wouldn't pile all it's troops uselessly on the front line, but to keep them in reserve, or flank with them. You know what we need. Do it.
The last two sentences actually sounded quite weird.
-
Re: Challenge for all modders out there
Problem is writing the script which anticipates moves
Like countering outflankation
-
Re: Challenge for all modders out there
Well they may open up AI in the expansion you never know?
Lt
-
Re: Challenge for all modders out there
Quote:
Originally Posted by Myrddraal
Problem is writing the script which anticipates moves
Like countering outflankation
Not a problem. The script has just to check whether player's units threathen to outflank AI's troops, and then move reserve units to counter it.
I don't know how flexible the script engine is, but I think it could be done, although with the commands listed by blitz576 it could be a little tricky. Tricky, but possible.
Quote:
Originally Posted by lt1956
Well they may open up AI in the expansion you never know?
I hope so. [wishful thinking]Or they might make it so that we wouldn't have to fix the AI.[/wishful thinking]
-
Re: Challenge for all modders out there
yeah i think it can be done, but maybe only in single battles like the historical ones
-
Re: Challenge for all modders out there
Yes, it couldn't be done for general battles I don't think, unless you made it horendously complicated and made it run by a how to.
Even then, I don't think you can label units with a how to script, which would be neccessary...
-
Re: Challenge for all modders out there
Well, obviously, for general battles it would have to be horrendously complicated, given the number of troop types (but possible, mind you, in this respect). Dunno about how the how to scripts work, but it's still a script and should (sp) behave like any other script, and label_unit is still a command called through a script, as far as I know.
Quote:
Originally Posted by Battle of Trebia script
;label_unit ALLIANCE ARMY UNIT
label_unit 0 0 0 PLAYER_Hannibal
label_unit 0 0 1 PLAYER_poeni
label_unit 0 0 2 PLAYER_peltast1
label_unit 0 0 3 PLAYER_peltast2
label_unit 0 0 4 PLAYER_poeni3
label_unit 0 0 5 PLAYER_cavalry
label_unit 0 0 6 PLAYER_elephant
label_unit 0 0 7 PLAYER_cat_elephant
label_unit 0 0 8 PLAYER_numidian_cav
label_unit 0 0 9 PLAYER_barb_infantry
label_unit 0 0 10 PLAYER_sacred_band_cav
label_unit 0 0 11 PLAYER_med_cav
label_unit 0 0 12 PLAYER_barb_infantry2
label_unit 0 0 13 PLAYER_barb_cavalry
label_unit 0 0 14 PLAYER_poeni2
label_unit 0 0 15 PLAYER_cretan_archers
label_unit takes parametres as alliance army unit. It doesn't care if it's a how to script or a script used to get the elephants to breakdance, right?
Correct me if I'm wrong.
And the goal here is to make a some sort of dynamic AI to a custom battle, not for a campaign battle. Let's first concentrate on making the AI, after that we'll worry about getting it to work in campaign.
-
Re: Challenge for all modders out there
I doubt you can do this from external scripts. CA used the scripts in historical battles to get units to do things they would not do otherwise. I remember some discussions about how the velites were scripted to run away at Trebbia after they expended half their missiles or something like that (since they had been engaged since early morning and were spent.)
You really need some thing that works faster, and from within the core AI. It is set up to do the pattern recognition in some form...so if you script it you are going to have conflicting layers.
But I don't want to discourage anyone from trying. You could try a few simple cases to start out: such as trying to get some 1vs1 match ups to behave properly. For instance, ranged units vs. infantry or cav: get the ranged unit to stop at max range and begin firing, rather than marching up to close range only to be over run.
-
Re: Challenge for all modders out there
Quote:
Originally Posted by Red Harvest
You really need some thing that works faster, and from within the core AI. It is set up to do the pattern recognition in some form...so if you script it you are going to have conflicting layers.
There is a command that enables/disables AI for a unit, that would prevent having any conflicts between the script and AI.
But yes, something faster would be better, especially concerning the pattern recognition. The ideal would be to use the hard-coded system to do that, but some solution can be jury-rigged, no doubt. Although probably it wouldn't be pretty.
-
Re: Challenge for all modders out there
Yes my concern with how to's is that you cannot know how many units need to label.
Will the game crash if you label unit sixteen when there are only 15 units?
But there is no need anyway as it would be for a custom battle with a set enemy army.
-
Re: Challenge for all modders out there
Quote:
Originally Posted by Myrddraal
Will the game crash if you label unit sixteen when there are only 15 units?
I don't know. Will it?
I guess that if you test something with unit sixteen the test will return something with a value of invalid. This could be used to quit using the label in the script.
I don't believe it'd CTD, an error message should be the worst case scenario. The most probable case is that it will only return invalid when tested and commands given to it won't work (obviously). These are just guesses though.
And yes, we shouldn't be thinking how to implement this in campaign (although it'd be sweet ~D (and the ultimate goal)), but only to create the AI which then can be modified to suit campaign battles.
-
Re: Challenge for all modders out there
Why don't you make a program seperate from R:TW that sets up a historical battle? The player chooses a map, then factions and units. He can place the army/armies in an initial position and hit a button "Generate script". The program then fills in a template with pieces of prewritten scripts that are placed into a library.
For example a player selects map X with AI Julii versus player Britons. The program makes the following decisions:
Map X is flat so both flanks need to protected. Map X has space to deploy an army at place x,y.
AI faction is Julii so the army is placed at x,y in the typical roman formation. Additional script is added to have velites skirmishing. When they are outnumbering the players missile units than prolonge the missile war. When not than script is added to dictate that the infantry moves forward as soon as they start taking some casualities. Reserves attack when enemy are behind the first line or when first line is wavering. Cavarly is given a script to defend the flanks until infantry is in combat. Then they are given back to AI control.
It will take considerable effort from scripters to write a library of scripts, but I guess that players will appreciate the challenge.
-
Re: Challenge for all modders out there
Not a bad idea, we'd just need someone to do the program..
But, I guess I'll have a go at scripting then. Wish me luck.. And anyone willing to join scripting the AI is welcome. I'd be damned if I'd be the only one doing this... And the challenge stands, of course.
We could try your idea, DJ, but it'll take some time to get enough scripts..
-
Re: Challenge for all modders out there
I'll help, but I can't promise full time commitment, I've got enough on my plate and WoT is my main priority
-
Re: Challenge for all modders out there
Thanks, I'll just try to grab the basics quickly so we can get to serious business..
-
Re: Challenge for all modders out there
I'm starting to get creative brainwaves :idea:
Lets assume that we could get a battlescript generator working.
Then we put all our talents together and develop a strategic game on our own. When a battle occurs, a historical battle script is written. Next you load up R:TW and you play the historical battle. Then we need to extract the outcome of the battle (or perhaps just write up the results) and import it back into the strategic game. Thus you have the excellent battle engine of R:TW but with a proper AI and strategic game that can be as challenging as we want.
Or more feasable, a small program as before that lets you setup armies, but where you can also give allied AI armies commands. The strategic level is overseen by a game master to tie the battles together. For example you could replay the Wars of the Roses; you start with a historical battle and depending on the outcome you will get another one with the constraints being set by the gamemaster.
...
Hey, hello, Mr. Pink Elephant! :barrel:
-
Re: Challenge for all modders out there
Yes, good ideas all, but well.. ASSUMING...
Well, assuming that we could script the battlefield AI, then why couldn't we also script the campaign AI? (well, ignoring the load/save thingys)
That combined with a mod like EB.. Yeesss... Excellent... :evilgrin:
But about the scripting.. Any scripting references anywhere? It'd make my life much easier..
-
Re: Challenge for all modders out there
CA released 2 documents covering all commands, triggers, conditions and events that can be used in historical battle scripts. I cannot find it on my harddisk or where it was posted (I believe somewhere at the .COM boards). Luckily I have printed it out, but that is of little use to you :tongue2:
About scripting the game, I thought it didn't reload when loading a saved game. Or did someone find a workaround? It keeps resurfacing that people have found a way to make 4 turns in a year, but they keep forgetting that the script doesn't reload. Or do I not know the whole story?
-
Re: Challenge for all modders out there
The whole story is, that I have finished the four turns a year script, but it needs to be re-launched manually (using a show me how) after every time you load the game. I will polish up the files and post them within the week.
-
Re: Challenge for all modders out there
Thanks Duke, I found them at the com. No need for you to scan them and send them to me ~;p
-
Re: Challenge for all modders out there
Simple script (a paste and copy will not work unless you have the 2 sets of 2 units) :
Code:
script
; init
prepare_for_battle
label_unit 0 0 0 GAUL_GENERAL
label_unit 0 0 1 GAUL_ARCHER1
label_unit 1 0 0 ROMAN_ARCHER1
label_unit 1 0 1 ROMAN_GENERAL
;BATTLE SCRIPT
while ! I_BattleStarted ; WAIT FOR DEPLOYMENT
end_while
ai_active_set off
define_unit_group GRP_GAUL_ARMY GAUL_GENERAL GAUL_ARCHER1
define_unit_group GRP_ROMAN_ARMY ROMAN_GENERAL ROMAN_ARCHER1
declare_counter COUNTER1
unit_group_move_to_missile_range_of_group GRP_ROMAN_ARMY GRP_GAUL_ARMY
set_counter COUNTER1 1
while COUNTER1 > 0
if I_UnitPercentageAmmoLeft ROMAN_ARCHER1 < 70
unit_order_attack_unit ROMAN_GENERAL GAUL_GENERAL run
set_counter COUNTER1 -1
end_if
end_while
while I_InBattle
end_while
end_script
1. It moves the AI army group towards the player until within missile range. NOTE: it seems that the engine checks at the call of the function what the position should be. If the player moves then the army group doesn't seem to move to a new position.
2. When the ammo of the AI archers is less than 70% it attacks the players general with the AI general.
I foresee some problems with being unable to changing facing of an AI army towards the players army. But it looks promising.
I had some problems with typing commands wrong, so either you need to be very carefull or we need to look into making a scripting utility that autospellchecks scripting.
-
Re: Challenge for all modders out there
Heh..
Code:
;******************************************************************************************************************
; Setting up Battle with Script Commands
;******************************************************************************************************************
prepare_for_battle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Label Units & Groups & LOCATIONS
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;*************
;juliis
;*************
label_unit 0 0 0 julii_hastati
label_unit 0 0 1 julii_general
;*************
;brutiis
;*************
label_unit 1 0 0 brutii_archers
;**********************
; start
;**********************
ai_active_set off
unit_order_move_to_missile_range brutii_archers julii_hastati run
end_script
You just had it done further..
And yes, there's a big danger of misspelling, I spelled bruti instead of brutii in the move order line.. instant CTD.. Maybe my previous statements were a bit too optimistic.
Quote:
Originally Posted by Duke John
I foresee some problems with being unable to changing facing of an AI army towards the players army.
That is a big problem. I was literally stunned by the lack of any commands returning a position/direction.. those would've made this a lot easier. Of course we could jury-rig a solution with trigonometry or something, but it'd be quite awkward to place a multi-line equation in each and every monitor needing them.. This is assuming the script language supports them. At this point I really miss OFP scripts.. the flexibility.. Hell, someone made a runge-kutta-solver-thingy with them!
Back to the topic. A spell-checker could be useful, but it wouldn't help with misspelled variables/labels resulting in CTD.. A fully-fledged scripting proggy? But then, of course, we could just try to write them..
Code:
set_counter COUNTER1 1
while COUNTER1 > 0
if I_UnitPercentageAmmoLeft ROMAN_ARCHER1 < 70
unit_order_attack_unit ROMAN_GENERAL GAUL_GENERAL run
set_counter COUNTER1 -1
end_if
end_while
Couldn't the counter, while and if- bits be replaced with:
Code:
monitor_conditions I_UnitPercentageAmmoLeft ROMAN_ARCHER1 < 70
-
Re: Challenge for all modders out there
Quote:
Then we put all our talents together and develop a strategic game on our own. When a battle occurs, a historical battle script is written. Next you load up R:TW and you play the historical battle. Then we need to extract the outcome of the battle (or perhaps just write up the results) and import it back into the strategic game. Thus you have the excellent battle engine of R:TW but with a proper AI and strategic game that can be as challenging as we want.
that was exactly my idea for a MP campaign game. I would write a program with an MTW style campaigngame, then when a battle occurs it generates a script and the program pauses. The players then fight this battle in RTW via gamespy. After completion the campaignmap program is resumed and it reads the battle results from the battle's logfile (rtw\logfiles\), and the campaigngame continues.
It will probably be my next project after Chivalry TW (if I can still be arsed to play RTW by then :))
-
Re: Challenge for all modders out there
Mkay.. I bBegan to do a proper battle script, for a battle like the one described by Duke. Currently the script is a follows:
Code:
;############### init #####################################
prepare_for_battle
;*************
;player
;*************
label_unit 0 0 0 plr_general
label_unit 0 0 1 plr_inf1
label_unit 0 0 2 plr_inf2
label_unit 0 0 3 plr_inf3
label_unit 0 0 4 plr_inf4
label_unit 0 0 5 plr_inf5
label_unit 0 0 6 plr_inf6
label_unit 0 0 7 plr_miss1
label_unit 0 0 8 plr_miss2
label_unit 0 0 9 plr_inf7
label_unit 0 0 10 plr_inf8
label_unit 0 0 11 plr_inf9
label_unit 0 0 12 plr_inf10
label_unit 0 0 13 plr_inf11
label_unit 0 0 14 plr_inf12
define_unit_group plr_army plr_general plr_inf1 plr_inf2 plr_inf3 plr_inf4 plr_inf5 plr_inf6 plr_inf7 plr_inf8 plr_inf9 plr_inf10 plr_inf11 plr_inf112 plr_miss1 plr_miss2
define_unit_group plr_front plr_inf1 plr_inf2 plr_inf3 plr_inf4 plr_inf5 plr_inf6
define_unit_group plr_missiles plr_miss1 plr_miss2
define_unit_group plr_reserves plr_inf7 plr_inf8 plr_inf9 plr_inf10
;*************
;AI
;*************
label_unit 1 0 0 AI_general
label_unit 1 0 1 AI_leg13
label_unit 1 0 2 AI_leg21
label_unit 1 0 3 AI_leg22
label_unit 1 0 4 AI_leg33
label_unit 1 0 5 AI_leg23
label_unit 1 0 6 AI_leg12
label_unit 1 0 7 AI_leg31
label_unit 1 0 8 AI_leg32
label_unit 1 0 9 AI_leg11
label_unit 1 0 10 AI_leg_1
label_unit 1 0 11 AI_rcav
label_unit 1 0 12 AI_lcav
label_unit 1 0 13 AI_vel1
label_unit 1 0 14 AI_vel2
label_unit 1 0 15 AI_vel3
label_unit 1 0 16 AI_raux
label_unit 1 0 17 AI_laux
define_unit_group AI_ARMY AI_general AI_leg13 AI_leg21 AI_leg22 AI_leg33 AI_leg23 AI_leg12 AI_leg31 AI_leg32 AI_leg11 AI_leg_1 AI_rcav AI_lcav AI_raux AI_laux AI_vel1
AI_vel2 AI_vel3
define_unit_group AI_1line AI_leg11 AI_leg12 AI_leg13
define_unit_group AI_2line AI_leg21 AI_leg22 AI_leg23
define_unit_group AI_3line AI_leg31 AI_leg32 AI_leg33
define_unit_group AI_skirm AI_vel1 AI_vel2 AI_vel3
;************* Locations
label_location plr_center -590 -134
label_location AI_prepline -500 -134
label_location veliteloc -550 -134
;************* Declaring variables
declare_counter battlephase ; phase 0=deployment/march, 1=missile duel/skirmishing, 2=closing lines, 3=all-out attack 4=monitor situation
declare_counter skirmphase ; phase 0=closing into range, 1=shooting/throwing part, 2=disengaging skirmishers
set_counter skirmphase 0
;**********************
; start
;**********************
while ! I_BattleStarted ;standard wait part
end_while
ai_active_set off ;disable core AI in favor of scripted one
unit_set_skirmish_mode AI_vel1 off
unit_set_skirmish_mode AI_vel2 off
unit_set_skirmish_mode AI_vel3 off
battle_wait 4
unit_group_order_move_formed AI_ARMY -480 -134 run; march AI army to positons
unit_group_order_move_unformed AI_skirm -500 -134 run
battle_wait 10
while I_IsUnitGroupMoving AI_ARMY ;wait until army is in position
end_while
battle_wait 10
set_counter battlephase 1
unit_set_experience plr_general 1 ;debug nodes, watch for general's exp
while I_InBattle ; main battle loop
;**********************************
; == skirmish part ==
if battlephase = 1
if skirmphase = 0 ;skirmish phase 0: skirmishers move to range, loosen formation
; unit_group_change_unit_formation AI_skirm square_hollow
unit_group_order_move_unformed AI_skirm -560 -134 run
set_counter skirmphase 1
unit_set_experience plr_general 2
end_if
; more to come
;
end_if
;**********************************
; much more to come
end_while
end_script
Script layout plan:
[CODE]init & labels
defining monitors?
move AI army to range
while-loop, checks everything possible implemented in script
{
skirmish-part
{
{
move to range, fire next phase when rdy
}
{
shootout, check for possible threats, fire next phase when out of ammo/large casualties to skirmishers
}
{
disengaging, fire next phase when rdy
}
}
main battle part
{
{
close to precursor range (fire at will), position flank guards according to player's flanks, make flanking movements
}
{
charge
}
}
battle checks
{
{
check front line, assign reserves
}
{
check flanking attempts, assign reserves
}
{
after a delay start to check for free reserves, possibly send them to flank
}
}
possibly a delay to lessen CPU load
end_while
/CODE]
Current problems:
1) The skirmishers don't respond to orders (in skirmish part, the first order is acknowledged)
2) I can't get monitors working. Dunno what it is.
Flanking checks could be implemented by: check flanking attempts-part checks the distance of player's units from lines placed on AI's flanks and on AI's front. Flank line checks (obviously) check if player's unit is on outflanking course, front line checks if player's unit has advanced far enough for the reserves to counter it.
About
Quote:
Will the game crash if you label unit sixteen when there are only 15 units?
for example,
I_BattlePlayerArmyNumberOfMatchingUnits all > 12
tests if player has over 12 units. One could use this while labeling, assuming that the game doesn't check if-statements beforehand.
Some observations on scripting:
*invalid labeling, using invalid label, using location label in some commands that require a location = CTD on execution of command.
*mistyped command, missing/extra end_* = script doesn't work but battle runs as usual.
EDIT: Groups within groups don't work. They can be defined but some of them won't respond to commands.
-
Re: Challenge for all modders out there
Just one thing to say about RTW script engine: It's crap. It can't store variables (other than numbers), it doesn't have any functions returning values etc.
Regarding to that, I had an idea :idea:
What if one would make a proggy that'd use the information from the battle and would constantly write script commands to a file to be executed every second?
Example: A battle script calls the console command output_unit_positions, saving the positons of all units to a file. The proggy checks this file for positions. The proggy then uses the information to figure out what's going on, for exampl, flanking manouvers. When it recognises a flanking manouver it will write a command (unit_order_attack_unit plr_unit_3) to a separate script file (show_me) that is run by rome regularly.
Benefits: We can have all the commands, calculus, variables we want and need to make the AI smart.
Problems: output-command doesn't output unit status, for example, men left/ammo status/engagement status. If we can work around these there's possibly no limits.
Any thoughts?
-
Re: Challenge for all modders out there
Quote:
Originally Posted by The_Mark
Just one thing to say about RTW script engine: It's crap. It can't store variables (other than numbers), it doesn't have any functions returning values etc.
I could have told you that...
I don't know about the whole seperate program idea. The advantage of scripting is that there are loads of things you can check up on like if a unit is being attacked in the flank of back etc...
-
Re: Challenge for all modders out there
I think he was saying that you could write scripts that would return all that battle data to an external program, who could at the same time do a lot more with the data than the scripts themselves.
-
Re: Challenge for all modders out there
No hes not, there is a command which outputs the unit positions to a file, but it doesn't output anything else...