Author Topic: Scripts of aliens AI  (Read 3009 times)

Offline redv

  • Colonel
  • ****
  • Posts: 336
    • View Profile
Scripts of aliens AI
« on: March 12, 2013, 03:19:40 pm »
Suggest to formalize the behavior of aliens in the form of scripts.
The script describes actions and the condition of the action.
For example, could be three stages:
1. Search for the enemy (conditions – percent of TU);
2. Attack the enemy (conditions – shooting mode selection; percent of TU);
3. Search for cover.

For each type of units in Xcom1Ruleset.rul, write path that point to script.

Feature: if you write a script for soldiers, then the battle will be in automatic mode:)

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: Scripts of aliens AI
« Reply #1 on: March 13, 2013, 03:24:55 am »
This seems like a good idea at a glance but what sort of script would you write?
What would you write it in?

For instance, I've embedded Lua in a C project before and I would expect it to take at least two months to get everything working smoothly.  There's no way it would happen before the upcoming release; it would be too much of a new feature. Also it's totally not necessary for the purpose of mimicking xcom1.

Offline redv

  • Colonel
  • ****
  • Posts: 336
    • View Profile
Re: Scripts of aliens AI
« Reply #2 on: March 13, 2013, 11:26:40 am »
In OpenTTD, AIs are located in separate files.

OpenXcom can use this way.
I think, this is not executable script. This is description of the settings AI.
For example (for sectoid, floater, etc):

Code: [Select]
stage1 : seek
percentTU: 50 https:// maximum TU for search target
stage2 : destroy
STR_PSI_AMP: 25 https:// prioritet of weapons (if have) and maximum TU for use it (if have)
STR_ALIEN_GRENADE: 60
STR_BLASTER_LAUNCHER: 60
STR_SMALL_LAUNCHER: 50
STR_HEAVY_PLASMA: 40
STR_PLASMA_RIFLE: 40
STR_PLASMA_PISTOL: 40
stage3 : cover
percentTU: 100 https:// maximum TU for search cover
Reapers, Crysalids, Zombie, etc each must have own script.

Volutar

  • Guest
Re: Scripts of aliens AI
« Reply #3 on: March 13, 2013, 12:31:43 pm »
It's not a script. It's just list of values.

Offline michal

  • Commander
  • *****
  • Posts: 636
    • View Profile
Re: Scripts of aliens AI
« Reply #4 on: March 13, 2013, 01:16:28 pm »
Exactly, should be doable in yaml.

Offline redv

  • Colonel
  • ****
  • Posts: 336
    • View Profile
Re: Scripts of aliens AI
« Reply #5 on: March 13, 2013, 01:26:46 pm »
Volutar, this is only one variant. Another variant may be better.
Basic idea - rejection of hardcode of behavior. This will simplify the code. As the same time complicate and diversify behavior of aliens.

Volutar

  • Guest
Re: Scripts of aliens AI
« Reply #6 on: March 13, 2013, 01:47:36 pm »
You won't be able to diversify behaviour through those values. It's more like a list of "behaviour patterns" which are really limited in logic.

Truly diverse behaviour is subject of low-level programming, not scripting. There are tons of factors, parameters, characteristics of environment and conditions which simply cannot be described with list of values. And really I don't see why we should try to move to scripting rails. That actually lessen behaviour diversity, and field to apply programmer's skills.
« Last Edit: March 13, 2013, 01:54:52 pm by Volutar »

Offline redv

  • Colonel
  • ****
  • Posts: 336
    • View Profile
Re: Scripts of aliens AI
« Reply #7 on: March 13, 2013, 03:01:35 pm »
I propose to divide the goals and methods to achieve them.
For example:
Script: to patrol; resource – max 20 TU.
Code: no problem! choose a direction; calculate the path; move unit; if unit see the enemy, then stop.
Script: use this weapon; resource – max 60 TU.
Code: no problem! estimate the distance to the target; choose the shooting mode (depending on the distance, accuracy, etc); shoot at the enemy; reload weapon (if need).
Script: go to cover; resource – max 30 TU
Code: no problem! seeking near shelter; move unit.

This is like instinct and intellect. Intellect sets goals and allocates resources. Instinct looking for the best way for solving within the constraints "tons of factors, parameters, characteristics of environment and conditions".
I suggest keeping in the code only instinct.
Intellect cannot be hardcoded))

Behavior of Alien Commander will be different from the behavior of Soldier.
Behavior of Ethereal will be different from the behavior of Sectoid.

Offline hmaon

  • Sergeant
  • **
  • Posts: 40
  • C jockey
    • View Profile
Re: Scripts of aliens AI
« Reply #8 on: March 16, 2013, 12:49:20 am »
That could work but what you described is exactly what the code does now, short of reserving precise TU values. That would be good to have. What do you want beyond that?

Some ideas I've been mulling over—like units working in teams, any kind of analysis of the whole battlefield, or ambush setup—would need to be done in C++.