# Two-Player Games with a bot player

Updated 2025-07-09 for GS 8.025

Since GS ver. 8.012, two-player games with a bot (AI) player are supported. This framework pairs a human player with a bot player; from the human player's point of view it looks very much like a normal two-player game (2PG)

## Experiment preparation

See also: two-player games -- Experiment preparation

To create an experiment plan for an adversarial or collaborative 2PG with a bot, you need to create an experiment plan with a name starting with the prefix `coop.` (for cooperative games) or `adve.` (for adversarial games). For example, the experiment plan `vm/adve.colorVshape-bot`, whose trial list file sits in the directory `/opt/w2020/game-data/trial-lists/vm/adve.colorVshape-bot`, describes an experiment with adversarial two-player game(s); the plan `vm/coop.colorVshape-bot`, for a cooperative ones. This is exactly the same name pattern as used for 2PGs with two human players.

To indicate to the server that you want the 2PG to involve a human and a bot, you need each of your trial lists files to have a column named `bot`, the value in which should indicate the name of the bot you want to use (typically, a wrapper over some AI algorithm). The only bot included in GS 8.012 is `pseudo`, which stands for "pseudo learning".

Additionally, the trial list file may include columns containing the necessary parameter values for the bot in question. The one column that the bot `pseudo` uses is named `pseudo_halftime`; it contains an integer value that specifies how fast the bot pretends to learn.

### Using a dynamic plan

If you have a 2PG experiment plan which you normally use for a game of two human partners (your "base plan"), you can also use it for a 2PG-with-a-bot play. To do that: go to the launch form, scroll down to Form 2, and enter a P:-type dynamic plan name which will include the name of your "base plan" and the name of a modifier. For example, if your base plan is `2PG/adve.test_1`, and you want to use the modifier `bot/pseudo-10` (whose file is in `/opt/w2020/game-data/modifiers/bot/pseudo-10`, you will enter `P:2PG/adve.test_1:bot/pseudo-10` in the plan name box.

The way P:-type dynamic plan works, the columns from the modifier file (which, in this case, specify the bot type and parameters) are virtually pasted at the end of all lines of the base plan's trial list files, thus resulting in a 2PG-with-a-bot file.

## The pseudo-learning bot

This bot does not have much of real AI in it. It merely pretends to learn, as in reality it cheats, since it "knows" the rule set from the start.

As of ver. 8.025, the pseudo learning bot uses the same algorithm as the one used in bot assist games. For details of the algorithm and its parameters, see Bot Assist: Bot algo parameters.

This bot works as follows: if the bot makes the first move on some rule set, hen it picks any move attempt (trying to move any game piece to any bucket) with an equal probability; so the attempt will likely fail, depending on how many pieces are movable, and to how many buckets. For each subsequent attempted move, the bot decreases the probability of being wrong; the decrease is exponential, so that after the two players have made in total `pseudo_halftime` move attempts on a give rule set, the probability of the bot's move being incorrect is 1/2 of what that probability was for the first move.

This means that eventually (after the players have made several times as many move attempts as `pseudo_halftime`), the pseudo-learning bot will rarely make mistakes any more. As a result, if you're playing an adversarial game (where a player is allowed to keep making moves, as long as they are successful), the bot, once allowed to make a move, will likely clear the entire board without allowing the human player to make even a single move. If you're playing a coop gsame, then, when the bot is making no more mistakes, achieving a team win will be entirely up to the human player.