Zillions of Games - Scripting Language

Scripting Language

The scripting language of Zillions-of-Games uses S expressions. The rules are stored in a text file with extension ".zrf" (zillions rules file). The users can create their own ZRF-files and make the AI of Zillions-of-Games play their newly created game.

Here is an example of rules for Tic-tac-toe (copyright by Zillions Development Inc.):

(define add-to-empty ((verify empty?) add)) (game (title "Tic-Tac-Toe") (description "...") (history "...") (strategy "...") (players X O) (turn-order X O) (board (image "images\TicTacToe\TTTbrd.bmp") (grid (start-rectangle 16 16 112 112) ; top-left position (dimensions ;3x3 ("top-/middle-/bottom-" (0 112)) ; rows ("left/middle/right" (112 0))) ; columns (directions (n -1 0) (e 0 1) (nw -1 -1) (ne -1 1)) ) ) (piece (name man) (help "Man: drops on any empty square") (image X "images\TicTacToe\TTTX.bmp" O "images\TicTacToe\TTTO.bmp") (drops (add-to-empty)) ) (board-setup (X (man off 5)) (O (man off 5)) ) (draw-condition (X O) stalemated) (win-condition (X O) (or (relative-config man n man n man) (relative-config man e man e man) (relative-config man ne man ne man) (relative-config man nw man nw man) ) ) )

The result of loading of this ZRF into Zillions-of-Games and playing against the computer is shown in screenshot at right.

The definition of games usually contains the following pattern:

  • Game title. One ZRF can contain more than one game and game title allows the user to select a certain game.
  • Description, history and strategy of the game. This is a text which shown to the user on demand to explain game rules, history and to give general gameplay advice.
  • Players. This is a list of player names used in the game. For example, for chess it would be White, Black. The player name is used in some further places, for example in initial position or game goal definitions. There could be just one player (e.g. for puzzles), two or more.
  • Turn order This specifies the order of moves made by the players. In the example above, the player X starts, the player O moves and then the whole sequence repeats. The definition of turn-order can be more complex, for example for balanced double-move chess it would be: (turn-order White repeat Black Black White White), which specifies the following order of moves: White, Black, Black, White, White, Black, Black, White, White, etc.
  • Board definition. This sections specifies geometry of the playing board, separate positions of the board and connections between them. The board definition in the example above first specifies a bitmap image to be used for the board. A 2-dimensional board is defined using pixel coordinates from the bitmap. The definition ("top-/middle-/bottom-" (0 112)) specified notations to be used for rows as well as an offset in pixels between rows. The text notation is used in move list, as well for saving the played game into ".zsg" (zillions saved game) file. The connections between board position is specifed in (directions ...) statement. The example above defines four directions: n (north) - one step up, e (east) - one step right, nw - diagonally up-left and ne - diagonally up-right. The directions are used in move definitions as well as in game goal definitions.
  • Piece definition. Defines pieces used in the game, their names and how they moved. In the example above one pieces is defined, Man, which can be dropped on any empty position of the board. Besides this two bitmaps for X and O players are specified.
  • Board setup. Specifies initial position of the game. The example above defines that the board is empty initially and each side has 5 pieces off the board, which can be dropped.
  • Goal of the game. Condition when one of players wins or when draw occurs. In Tic-Tac-Toe win condition (3-in-a-row) is defined as relative piece configurations, using directions n, e, ne and nw from board definition.

Read more about this topic:  Zillions Of Games

Famous quotes containing the word language:

    Denotation by means of sounds and markings is a remarkable abstraction. Three letters designate God for me; several lines a million things. How easy becomes the manipulation of the universe here, how evident the concentration of the intellectual world! Language is the dynamics of the spiritual realm. One word of command moves armies; the word liberty entire nations.
    Novalis [Friedrich Von Hardenberg] (1772–1801)