Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AI

This is the class to play the Saloon game. This is where you should build your AI.

Hierarchy

  • BaseAI
    • AI

Index

Properties

game

game: Game

The reference to the Game instance this AI is playing.

player

player: Player

The reference to the Player this AI controls in the Game.

Methods

ended

  • ended(won: boolean, reason: string): Promise<void>
  • This is called when the game ends, you can clean up your data and dump files here if need be.

    Parameters

    • won: boolean

      True means you won, false means you lost.

    • reason: string

      The human readable string explaining why you won or lost.

    Returns Promise<void>

Protected findPath

  • findPath(start: Tile | undefined, goal: Tile | undefined): Tile[]
  • A very basic path finding algorithm (Breadth First Search) that when given a starting Tile, will return a valid path to the goal Tile.

    Parameters

    • start: Tile | undefined

      the starting Tile.

    • goal: Tile | undefined

      the goal Tile.

    Returns Tile[]

    An array of Tiles representing the path, with the first element being a valid adjacent Tile to the start, and the last element being the goal.

gameUpdated

  • gameUpdated(): Promise<void>
  • This is called every time the game's state updates, so if you are tracking anything you can update it here.

    Returns Promise<void>

getName

  • getName(): string
  • This is the name you send to the server so your AI will control the player named this string.

    Returns string

    A string for the name of your player.

getSetting

  • getSetting(key: string): string | undefined
  • Gets an AI setting passed to the program via the --aiSettings flag. If the flag was set it will be returned as a string value, undefined otherwise.

    Parameters

    • key: string

      The key of the setting you wish to get the value for.

    Returns string | undefined

    A string representing the value set via command line, or undefined if the key was not set.

invalid

  • invalid(message: string): Promise<void>
  • Invoked after this AI sends some run that is invalid

    Parameters

    • message: string

      The human readable error message about why it did something invalid.

    Returns Promise<void>

runTurn

  • runTurn(): Promise<boolean>
  • This is called every time it is this AI.player's turn.

    Returns Promise<boolean>

    Represents if you want to end your turn. True means end your turn, False means to keep your turn going and re-call this function.

start

  • start(): Promise<void>
  • This is called once the game starts and your AI knows its playerID and game. You can initialize your AI here.

    Returns Promise<void>

Generated using TypeDoc