AI Settings

Ideas and suggestions for how to improve the Warzone 2100 base game only. Ideas for mods go in Mapping/Modding instead. Read sticky posts first!
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

AI Settings

Post by aubergine »

Inspired by this post and this post...

It would be nice if AIs could define settings, and default values for those settings.

A js file could be used to define settings, but IMHO that gives too much flexibility. So, maybe define settings in an ini file?

There would be a limited number of setting types:

* boolean (single checkbox)
* option (radio group or drop-down list)
* range (slider)

The settings could be defined in the .ai file as follows:

Code: Select all

[AI]
name = "SomeBot v1.23"
js = somebot.js
tip = "SomeBot - an AI with settings!"
settings = 3 // number of settings sections

[setting_1]
id = "allowRush" // the property name in resultant JS 'settings' object
type = boolean // setting type
name = "Allow rush" // what gets displayed on screen
default = 0, 0, 1, 1 // defaults for easy, medium, hard, insane difficulty

[setting_2]
id = "personality"
type = option
name = "Personality"
options = "Machineguns / Cannons", "Flamers / Rockets" // options shown to user
default = 0, 0, 1, 1 // index in options list, for each AI difficulty level

[setting_3]
id = "turtleness"
type = range
name = "Defensiveness"
min = 0
max = 5
default = 5, 4, 3, 0
This makes it easy for UI to be automated, and leaves the door open to future enhancements. Also, should we reach a point where custom UIs can be defined by mods, it will make it easier for modders to script the AI settings panel in their UI.

When the game starts, the AI will see a new global 'settings' object. The object has named properties, in the example above they would be "allowRush", "personality", "turtleness".

Boolean settings

In the ini, 0 = false, 1 = true.

Option settings

The user selects one item from the things in 'options'.

The script is given the index of the user's selection.

If there are more than 3 options, a drop-down list is shown. Otherwise radio buttons are shown.

Range settings

The 'min' and 'max' define upper/lower limits of the range.

The user sees a slider to choose the value (ideally with selected value being shown as number at side). Values are always rounded to integers.

Example

If I ticked "Allow rush", selected "Flamers / Rockets" and set "Defensiveness" to 3, the 'settings' object for that AI player would be:

Code: Select all

settings = {allowRush: true, personality: 1, turtleness: 3}
Notes

Putting the settings definitions in to an .ini has following benefits:

* overview of the AI all in one place (don't have to go hunting for additional files to find settings)
* don't need to run a script environment just to find out what settings are
* modlets can be used to customise settings
* <mapname>.ini, <challenge>.ini, etc., can easily define what settings to use

While new setting data types and features can be added at later date, it's best to keep it super-simple to avoid cumbersome AI configs being developed.

GUI

The settings could be accessed via the AI difficulty button.

If an AI has no settings, then the difficulty selector works like it does now - you click the icon, up pops a list of difficulties, you select one, the difficulty list disappears and the icon is updated to show the new difficulty.

If the AI does have settings, a little 'cog' icon is superimposed over the difficulty icon (so user can see which AIs have extra settings). The cog icon would just be an outline of the cog if defaults for that AI are being used. However, if the settings are changed (ie. not the default for the difficulty level), the cog outline will be flood-filled so you can see that non-default settings are applied to that player.

When the user clicks the difficulty icon, the usual list of difficulties is shown, but also, to the side, a the settings are shown.

Besides each setting is a little cog - outline if the setting is default value for current difficulty, filled if it's been altered. Clicking a filled cog reverts the setting to it's default for the difficulty level.

When you change difficulty level, settings with outlined cogs update to the default associated with the new difficulty level.

Note: Even if a filled cog setting is now the same value as the default for the selected difficulty level, the cog remains filled. Thus you can customise a setting (it's cog is filled) and then change difficulty several times without fear that that setting will unexpectedly return to default (empty cog) mode. (hope that makes sense!)

Once the player is happy with the settings, they click the "OK" button - the difficulty/settings panel disappears, the icon next to the AI player shows the selected difficulty level and the cog will be filled if it's additional settings are not the defaults for that difficulty.

Obviously, this will be much easier to implement once we get access to GUI functions and the ability to script the user interface.

There would likely be a startGame() function (or similar) and the settings would be passed in to that in some way.

For example:

Code: Select all

playerData[] // array of player objects defining the players
playerSettings[] // array of settings objects to pass through to scripts

...

startGame(mapName, scavengers, ...., playerData, playerSettings);
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO