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.
◆ 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()
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_num | the number of the AI player. Call player_x(pl_num) to obtain a corresponding player_x instance. Definitely store this value! |
◆ start()
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_num | the number of the AI player. Call player_x(pl_num) to obtain a corresponding player_x instance. Definitely store this value! |
◆ step()
The heartbeat of the AI player. Here, all AI-related calculations and work can be done.