lychanl / AITournament

Engine for training and developing AI engine for games

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AITournament

Engine for training and developing AI engine for games.

Created with tensorflow support to easily configure and run

About basic classes

To know what some concepts mean

  • Engine - this is what prepares the players and runs the games
  • Game - an enviroment for players, it takes actions, shows state and, after finished, gives results
  • Player - an actor in the game, makes actions based on current state
  • Player pool - a population or generator of players, it may be used to adjust a group of players based on their respective and overall results

How does it work?

  1. Firstly, instances of game, players and player pools are created.
  2. Then it starts with running test runs once.
  3. Finally for every epoch it runs training and testing.

Every run, train or test, consits of some number of iterations, where iteration is:

  1. Preparing players for iteration by concatenating players with those given by player pools. Each specified player is taken and from specified player pools equal number of players is generated - at least one, up to the pools' and game's upper limits.
  2. Game is run until finished. For each step every player is shown current state and moves are requested from those who are supposed to act at that moment.
  3. Players and player pools are given their respective results (for pools it will be reuslts of all players that were generated by them in this iteration) to allow them to adjust themselves.

How to configure it?

Configuration is divided between a config file and command line arguments.

Config file

Config files are written in yaml and consits of following elements (optional are in square brackets):

  • [modules] - definition of modules to be imported
    • [module] - identified by name, with value being path to module python source file
  • [players] - defnition of players
    • [player] - identified by name, with value being a symbol specification
  • [pools] - definition of player pools
    • [pool] - identified by name, with value being a symbol specification
  • [train] - specifies players and pools for training runs
    • [players] - list of player names for train runs
    • [pools] - list of player pool names for train runs
  • [test] - specifies players and pools for test runs
    • [players] - list of player names for test runs
    • [pools] - list of player pool names for test runs
  • game - game definition, with value being a symbol specification
  • [events] - list of events, identified by name with value being a function specification. To see more about available events see Events section

At least one player or player pool must be specified.

Symbol specification consits of following elements:

  • module - name of the module for symbol to be imported from
  • class - name of the class to import from module
  • params - params to be passed on initalization
    • param - identified by name, with value being the value to be passed. session is a keyword meaning engine tensorflow session, that is initialized if required

Function specification consits of following elements:

  • module - name of the module for function to be imported from
  • func - name of the func to import from module

For examples see sample directory

Command line arguments

Optional arguments are enclosed in square brackers

--config-file FILE

[--test-runs N], default 1

[--train-runs N], default 0

[--epochs N], default 0

[-h / --help]

Available events

  • on_start
    Default: engine.events.default_on_start
    Arguments:

    • configuration
    • game
    • train_players
    • train_pools
    • test_players
    • test_pools

    Raised after config is loaded, objects created and, if required, tensorflow variables initialized

  • on_finished
    Default: engine.events.default_on_finished
    Arguments:

    Raised after all epochs ended, before closing eventual tensorflow session

  • on_epoch_started
    Default: engine.events.default_on_epoch_started
    Arguments:

    • epoch

    Raised on epoch start, before test runs

  • on_test_step
    Default: None
    Arguments:

    • game
    • players
    • pools_by_player

    Raised in test runs after applying moves selected by players

  • on_train_step
    Default: None
    Arguments:

    • game
    • players
    • pools_by_player

    Raised in training runs after applying moves selected by players

  • on_test_game_finished
    Default: None
    Arguments:

    • game_in_run
    • game
    • result_by_player
    • pools_by_players

    Raised in test runs after game was completed

  • on_train_game_finished
    Default: None
    Arguments:

    • game_in_run
    • game
    • result_by_player
    • pools_by_players

    Raised in training runs after game was completed, before training on game over is called

  • on_test_run_finished
    Default: engine.events.default_on_test_run_finished
    Arguments:

    • results_by_players
    • results_by_pools

    Raised after all test runs in epoch were completed

  • on_train_run_finished
    Default: None
    Arguments:

    • results_by_players
    • results_by_pools

    Raised after all training runs in epoch were completed

About

Engine for training and developing AI engine for games

License:MIT License


Languages

Language:Python 100.0%