Skip to content

DDerl Views

Stefan Ochsenbein edited this page Jun 13, 2017 · 6 revisions

DDerl Views and Game Management

DDerl is a database browser, hosted on GitHub which also serves as a management tool for egambo. The tool is based on imem (in-memory database on a MNESIA cluster). DDerl views can be created based on SQL on the raw imem tables. Some Erlang specific data types (maps, tuples, lists, JSON) are supported and associated operations on those.

DDerl gives access to egambo data tables where game types are stored and the played games with their playing history. Important items of the egambo data are presented as tailor-made views. This includes operations (stored procedures) on the data. These predefined views were created by the system user and are accessible to all player accounts. All players currently have system super powers and can create their on views but those are normally reserved to be used by the creator only. The currently defined system views include:

ddAccount

Table of Player accounts and internal bot accounts

ddConfig

System Configuration

ddRole

Roles and permissions granted to accounts

egambo.create(GameType,Cnt,OpponentAcc)

Create a number(Cnt) of games owned by the logged in user playing against a given account (which can be a bot or another connected account). The system account cannot play, nor use this command. No match making is attempted for game offerings of the opponent. New games are unconditionally created. If the opponent is a bot, playing starts immediately and in parallel for all games.

egambo.create(GameType,Cnt,OpponentAcc,OwnerAcc)

Create a number (Cnt) of games owned by OwnerAcc (integer) playing against OpponentAcc. If both players are bots, all games are played to completion.

egambo.egGame

View of all games played so far. Use filter functions to pick only a subset of games.

egambo.egGame.Playing

List of all games in playing state

egambo.egGame.Recent

List of recently created games. Modify the SQL to change the time frame.

egambo.egGame.Sampler(GameType)

View with one calculated column giving a sample move information. This can be used to train a bot. If a game had N moves, a random move 1..N is picked and represented as a training sample. image The Erlang list (or JSON array) representing the sample has 5 elements. The above example reads as follows:

  • "X OXX OO " Game Board transformed to a normalized version where X makes the next move (blank=possible next move)
  • "XO" List of players (constant for this type of games): Alias characters of the next players, X=first player, O=second player
  • 1 Next move made by X, index into the Game Board string (0-based), Must have hit a blank board position.
  • [-1,1] Final Score of the game for all players [ScoreX, ScoreO] (-1=loose, 1=win, 0=tie)
  • 1 Tail Length: How many more moves were needed to complete the game? The learning algo may take this as a hint, how important this move was with relation to the outcome of the game.

egambo.egGame.Unfinished

Show unfinished games (playing, aborted, cancelled or waiting for a partner match)

egambo.egGame.Width13

Poor man's version of a graphical game representation for the current (or final) board of a game (GameID needed as a parameter). Only works for games with board width=13 (small GO board). Similar views exist for other board sizes:

  • egambo.egGame.Width15
  • egambo.egGame.Width19
  • egambo.egGame.Width3
  • egambo.egGame.Width4
  • egambo.egGame.Width5
  • egambo.egGame.Width6
  • egambo.egGame.Width7
  • egambo.egGame.Width8
  • egambo.egGame.Width9

egambo.egGameCategory

List of all supported game categories (only tic_tac_challenge supported today)

egambo.egGameMsg

Log table for game moves. Might be used for debugging of game broadcast messages. Pure bot-to-bot games currently do not log into this table.

egambo.egGameMsg.Recent

Recently created or played games. Use DDerl filter functions to narrow the result set.

egambo.egGameType

Currently supported game types. When adding definitions of additional games, the generation (and compilation) of the appropriate win function module might be needed. Win function module generation is supported by:

  • egambo_tictac_win:gen(Width,Height,Run) for non-periodic boards
  • egambo_tictac_wip:gen(Width,Height,Run) for periodic boards

egambo.play(GameId,CellAtom)

Play one move for logged in AccountId (called user in SQL) by giving the cell position as an atom

  • aA .. cC for the smallest possible board (tic_tac_toe)
  • a .. g for a connect_four (gravity board width=7, height=6)

egambo.play(GameId,CellInt)

Play one move for logged in AccountId (called user in SQL) by giving the cell position as an integer

  • 0 .. 8 for the smallest possible board (tic_tac_toe)
  • 0 .. 6 for a connect_four (gravity board width=7, height=6)

egambo.play_all(GameId,CellAtom)

Play one move for the player in turn (whoever that is). This makes it possible to play both roles (X and O) in a game.

egambo.play_all(GameId,CellInt)

Play one move for the player in turn (whoever that is). This makes it possible to play both roles (X and O) in a game.

egambo.result(GameId)

Return the result (or current state) of a game in JSON format.

egambo.resume(GameId)

Restart a particular game process in case it was stopped or crashed for any reason. Only possible if the game is not finished yet.

egambo.start(GameType)

Announce the willingness to start a game of given type with any other external player (not an internal bot).

egambo.start(GameType,OpponentAcc)

Announce the willingness to start a game of given type with a particular opponent (can be an internal bot).