[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Stratagus-devel] AI in stratagus
From: |
Crestez Leonard |
Subject: |
Re: [Stratagus-devel] AI in stratagus |
Date: |
Thu, 28 Aug 2003 20:10:11 +0300 |
Don't we already have that? NEW_AI (the default) is a scheme script that
keeps executing. Please read data/ccl/ai.ccl. There is no need for
individual unit AI, unit actions are hardcoded but work rather fine.
Also, having AI scripts for every unit can get very expensive.
I don't think that we have to make everything configurable, we might
just as well write everything in scheme.
On Thu, 2003-08-28 at 20:13, ludo wrote:
> Hello !
>
> I had a look some time ago to fr^H^Hstratagus's computer AI. I was wondering
> how to enhance it...
>
> I rapidly saw that lots of behaviour were hardcoded ( how workers goes to
> mines, ... ), and not easy to read, because you have to keep the state of the
> unit from game cycle to game cycle.
>
> So I searched a way to make AI more "customizable"...
>
> I came to the idea that it could be interesting to write units's AI
> sequencially, as if their code was executing in separate threads.
> I think it could make AI for unit very simple; for exemple :
>
> function attak(goal){
> while (!canFire(goal)){
> moveNear(goal,fireRange);
> }
> fire(goal);
> }
>
> There we have a problem if the goal can't be reached, but this could be
> solved
> by the way of exception : moveNear(...) throw an exception, which the caller
> of attack will receive. If the caller is the player, the exception will just
> be printed on the screen (can't attack : can't move to unit).
>
> We can also define these function in a kind of "class", binded to UnitType,
> so
> that a new unittype could use its own attack function...
>
> The same approach can be followed for computer IA. It could be possible to
> write some small script ( ground attack, air attack, mixed attack, ... ) and
> then make the AI choose between them :
>
> function transported_attack(attackers,transporter,landzone,attackzone){
> foreach unit in attackers{
> // Give some orders...
> attackers.stand
> transporter.take(attacker)
> }
>
> while(not all_orders_done){
> // Wait some time
> wait
> }
> attacker.moveTo(landzone)
> while((not transporter.underAttack)&&(not all_orders_done)){
> wait
> }
> attacker.unloadAll();
> foreach unit in attackers {
> attackers.attack(attackzone)
> }
> }
>
> This way, it is possible to go further, by allowing the IA to execute
> simultaneously multiple functions ...
> So the hardcoded AI would resume to choose which and how many scripts it
> should execute at a given moment... ( maybe based on its ressources, ... )
>
> I started working on this approach, by writing the interpreter which would
> allow such scripts to be executed in parallel, at low cost ( cpu & memory ).
>
> But before i go further on this direction, I'd really like to know what you
> think about these ideas ?
>
> Ludovic