Simutrans-Squirrel-API
Functions
AI interface

Functions

void new_month ()
 
void new_year ()
 
void resume_game (int pl_num)
 
void start (int pl_num)
 
void step ()
 

Detailed Description

The following methods are vital for the functioning of a scripted AI. They will be called from simutrans to interact with the script. You should consider implementing them.

Function Documentation

◆ new_month()

void new_month ( )

Called at the beginning of a new month. Statistics of the last (complete) month is now in position [1] of any statistics array.

◆ new_year()

void new_year ( )

Called at the beginning of a new year. Statistics of the last (complete) year is now in position [1] of any statistics array.

◆ resume_game()

void resume_game ( int  pl_num)

This function is called when a savegame with active AI player is loaded. Do all the initializations and post-processing here.

Parameters
pl_numthe number of the AI player. Call player_x(pl_num) to obtain a corresponding player_x instance. Definitely store this value!

◆ start()

void start ( int  pl_num)

This function is called when the AI starts. Do all the initializations here, as you cannot initialize global variables with non-built-in squirrel types.

Parameters
pl_numthe number of the AI player. Call player_x(pl_num) to obtain a corresponding player_x instance. Definitely store this value!

◆ step()

void step ( )

The heartbeat of the AI player. Here, all AI-related calculations and work can be done.