Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AI

An Artificial Intelligence that can play the game.

This class contains logic for timing A.I actions but no implemenetaiton of gameplay logic.

Hierarchy

Index

Constructors

constructor

  • Construct an Artificial Intelligence that can play the game

    Parameters

    • playerNumber: number

      The number of the player which the A.I will control

    • game: ClientGame

      A ClientGame instance for the A.I to observe and take actions

    • deck: DeckList

      The DeckList of the deck the A.I will use

    Returns AI

Properties

Protected actionSequence

actionSequence: Array<function> = []

Protected Optional animator

animator: Animator

Protected deck

deck: DeckList

The DeckList of the deck the A.I will use

Private eventQueue

eventQueue: GameSyncEvent[] = []

Protected game

A ClientGame instance for the A.I to observe and take actions

Protected isImmediateMode

isImmediateMode: boolean = false

Protected playerNumber

playerNumber: number

The number of the player which the A.I will control

Private processingEvent

processingEvent: boolean = false

Protected thinking

thinking: boolean = false

Private timer

timer: any

Methods

Protected addActionToSequence

  • addActionToSequence(action: function, front?: boolean): void
  • Adds an action to be run at some point in the future depending on the A.Is timing mode

    Parameters

    • action: function

      The action to be added to the sequence

        • (): boolean
        • Returns boolean

    • Default value front: boolean = false

      If true the action will be added to the beginning of the sequence, otherwise it will go at the end.

    Returns void

Protected applyNextAction

  • applyNextAction(): void
  • Checks if we can take an action, if we can then takes the next one in the action sequence.

    Returns void

getPlayerNumber

  • getPlayerNumber(): number
  • Gets the number of the player this A.I controlls

    Returns number

handleGameEvent

  • Parameters

    • event: GameSyncEvent

      A Game Synchronization Event sent by the server

    Returns void

onGainPriority

  • onGainPriority(): void
  • Signals to the A.I that it has gained priority and may take actions

    Returns void

Private runAction

  • runAction(action: function): void
  • Executes an action checking if it returns an error status code. If it does then prints out a message.

    Parameters

    • action: function
        • (): boolean
        • Returns boolean

    Returns void

Protected sequenceActions

  • sequenceActions(actions: Array<function>): void
  • Adds a list of actions to be run to end of the sequence.

    Parameters

    • actions: Array<function>

      The actions to add

    Returns void

startActingDelayMode

  • startActingDelayMode(delayTimeMs: number, animator: Animator): void
  • Tells the A.I to start taking actions, but to spread them out over time. It will also wait until the given animator has completed any animations. This is to keep the A.I from taking all its actions simultaneously when playing against a human.

    Parameters

    • delayTimeMs: number
    • animator: Animator

    Returns void

startActingImmediateMode

  • startActingImmediateMode(): void
  • Tells the A.I to start acting and to immediatly take any action it likes. This is to make the A.I faster for A.I vs A.I battles

    Returns void

stopActing

  • stopActing(): void
  • Tells the A.I to stop taking any moves when the game is over

    Returns void

Protected Abstract think

  • think(): void
  • Triggers the A.I to plan out its next actions

    Returns void

Generated using TypeDoc