The PuzzLang Project Begins

PuzzleScript is a fascinating language for writing puzzle games, particular those of the block-pushing variety. It has a strong following, with hundreds of games written in it to various levels of quality. It is particular well-suited to prototyping a game (of a suitable genre) prior to turning it into a commercial quality distributable game. Full credit to Stephen Lavelle, whose many other creations may be found at increpare.

The aim of the PuzzLang project is to implement the PuzzleScript language using modern compiler tools, to put it on a firm footing from which it can be developed further. One reason is to target different platforms, such as Unity or mobile devices. Another is to improve the visual appearance, with higher resolution images and text. And there is the possibility of adding new features such as mouse support and new genres of puzzles based on the same pattern matching ideas.

So we begin.

Posted in PuzzLang | Leave a comment

Polygamo Release with User Games

An update to Polygamo has just been released. The release

  • supports user games
  • supports BMP files for user games
  • supports random players
  • has an improved script picker and shows the readme
  • has settable options for think time
  • macros now expand correctly, including inside strings
  • turn order works, including pass and random start
  • pieces can be defined in any order
  • fixes a number of bugs
  • improves Zillions compatibility.

The release includes 3 internal games and copies of around 30 user-created games, each with a readme.txt.

The release can be found on GitHub here.

Posted in Polygamo | Leave a comment

Polygamo Initial Release

Polygamo is a language compiler and general player for abstract games and puzzles. You can read more about it here.

The aim of Polygamo is to allow a human to play any general games and puzzles as long as there is a Game Description Language to describe them and a device to play them on.

The initial release is a Unity player with an implementation of the ZRF language. The project includes a games library, responsible for parsing the game description and providing the logic to play the game, an AI based on MCTS, a player for Unity, and a few sample games. This is just the first release, to get some feedback and gauge interest. More will follow.

This is open source software and it is free, in both senses. You are free to download it, free to use it or modify it and free to create games with it, at no charge. If you pass Polygamo or your games on to others you have to do so in exactly the same way: open source, free to use, free to modify and at no charge. For more details see Licence.

You can download Polygamo from Github here. You can submit issues there, or contact me through this web site.

Posted in Polygamo | 3 Comments

PySol

PySol is an exciting collection of more than 200 solitaire card games. Its features include support for lots of distinct games, very nice look and feel, multiple cardsets and table tiles, sound and background music, unlimited undo & redo, load & save games, player statistics and log files, hint system, demo games, support for user written plug-ins, integrated HTML help browser and lots of documentation.

Among the supported games are classics like Aces Up, Baker’s Game, Canfield, FreeCell, Forty Thieves, Golf, Klondike, Pyramid, Scorpion, Spider, Yukon, and many more…

PySol is copyrighted OpenSource software distributed under the terms of the GNU General Public License. PySol is written in 100% pure Python.

The original PySol project was discontinued in 2004, but PySolFC is a collection of more than 1000 solitaire card games. It is a fork of PySol Solitaire.

There are games that use the 52 card International Pattern deck, games for the 78 card Tarock deck, eight and ten suit Ganjifa games, Hanafuda games, Matrix games, Mahjongg games, and games for an original hexadecimal-based deck.

Its features include modern look and feel (uses Ttk widget set), multiple cardsets and tableau backgrounds, sound, unlimited undo, player statistics, a hint system, demo games, a solitaire wizard, support for user written plug-ins, an integrated HTML help browser, and lots of documentation.

PySolFC is distributed under the terms of the GNU General Public License.

http://www.pysol.org/
http://pysolfc.sourceforge.net/
https://en.wikipedia.org/wiki/PySol

The reason for including it here is as an example of the kind of game or puzzle that Polygamo intends to play, and a collection that might well be ported.

Posted in Collections | Leave a comment

Tatham Puzzles

Simon Tatham is a software engineer who created a collection of portable single-player puzzle games. Simon is better known in some circles as the author of PuTTY, but as a side project this one has been rather successful. With the help of others there are now around 40 puzzles, which run on Windows (desktop and Store), Linux, Mac OS X, Android and the Web. They are well worth a look.

Link: http://www.chiark.greenend.org.uk/~sgtatham/puzzles/

The puzzles are Open Source and written in C. The common code framework is rather low level, which rather limits the ability to implement new games or port existing ones to a games engine like Unity. The relevance to the Polygamo project is as working models: in principle it should be possible to re-implement all these games reasonably easily.

Posted in Collections | Leave a comment

A High Level View

Many abstract games and puzzles can be described in terms of players, pieces and moves on a board.

Games have two or more players, human or computer, who compete to reach some defined goal. Puzzles have one player and the goal is to solve the puzzle.

A game board consists of a set of predefined locations, each of which can hold a piece. The locations are arranged in some way for display purposes and may be related by directions and grouped into zones to assist in defining legal moves, but there is nothing special about any particular arrangement. A chess board or a card table or a crossword puzzle are all kinds of game board.

Each piece is owned by a player when it is played to a location. Pieces have a fixed visual appearance, to make them recognisable on display. As a simplifying assumption, a location can hold only one piece of one kind, so groups of pieces on a single location and pieces that are modified to look different are represented as different pieces.

Pieces are provided with legal moves according to a set of rules.Moves are arbitrarily complex, from simply placing a piece on a location on the board, to long sequences of moves and captures that may affect the entire board.

The game proceeds from a starting position through a series of played moves until it ends. The state of the game is represented by a sequence of board states comprising played pieces. These are games of perfect information, with no hidden state.

The game ends when some specific condition is satisfied. A player may win, lose or draw at the end of any turn and before the next player can move.

Both legal moves and ending conditions may have arbitrarily complex rules which depend on the players, pieces and locations. The game may define neutral players, dummy pieces and dummy locations to assist in defining complex moves and ending conditions.

Posted in Architecture | Leave a comment

Axiom

Axiom is a universal game engine developed by Greg Schmidt, that was originally based on the Zillions of Games engine. It is a system and language designed for game creation. Unlike ZoG, Axiom supports the ability for game developers to specify the AI and therefore it can be applied to non chess-like games such as territorial and connection games.

http://www.mindsports.nl/index.php/axiom
https://groups.yahoo.com/neo/groups/axiom-system/info
https://www.boardgamegeek.com/files/boardgame/all?username=gschmidt

The basic Axiom system is a DLL plug-in for Zillions, but there is also a game player that can be used instead of Zillions, and is free.

The extension language is a dialect of Forth and the Forth source code is provided. The DLL is programmed in C++ and the game player in C#, for Windows only (Windows Forms), but the source code has not been released.

Here is the source code for Tic-Tac-Toe, Forth version.

(
 *****************************************
 * Simple Game Example - Tic-Tac-Toe     *
 *                                       *
 * Uses the built-in Axiom search engine *
 *****************************************
)

$gameLog OFF

{board
	3 3	{grid}
board}

{players
	{player}	X
	{player}	O
players}


{turn-order
	{turn}		X
	{turn}		O
turn-order}

( Drops )

: DropMan
	empty? verify drop add-move
;


{moves ManDrops
	{move} DropMan
moves}


{pieces
	{piece}		man		{drops}  ManDrops
pieces}

(
**********
* Events *
**********
)

( 
  OnIsGameOver is always called from the perspective of the
  player who is about to make the next move.  axiom ensures
  that the current $movesList is correct for that player.
)

( Does the opponent occupy these 3 positions? )
: 3-in-a-row? ( pos1 pos2 pos3 -- ? )
	enemy-at? SWAP
	enemy-at? AND SWAP
	enemy-at? AND
;

( Win check - Did the player who just moved win? )
: opponent-win? ( -- ? )
	0 1 2 3-in-a-row?
	3 4 5 3-in-a-row? OR
	6 7 8 3-in-a-row? OR

	0 3 6 3-in-a-row? OR
	1 4 7 3-in-a-row? OR
	2 5 8 3-in-a-row? OR

	0 4 8 3-in-a-row? OR
	2 4 6 3-in-a-row? OR
;

( Determine if the game is over or not. )
: OnIsGameOver ( -- gameResult )
	#UnknownScore

	opponent-win?
	IF
		DROP #LossScore
	ELSE
		stalemate?
		IF
			DROP #DrawScore
		ENDIF
	ENDIF
;

Posted in Language | Leave a comment

Zillions

Zillions of Games is a commercial general game playing system developed by Jeff Mallett and Mark Lefler in 1998. The game rules are specified with S-expressions in the Zillions rule language. It was designed to handle mostly abstract strategy board games or puzzles.

After parsing the rules of the game, the system’s artificial intelligence can automatically play one or more players. It treats puzzles as solitaire games and its AI can be used to solve them.

Home http://www.zillions-of-games.com/
Wiki https://en.wikipedia.org/wiki/Zillions_of_Games
Chess variants https://www.chessvariants.com/programs.dir/zillions/

The game is written in C++ for Windows desktop (GDI) exclusively. Source code has not been released.

Here is Zillions code for Tic-Tac-Toe.

(game
  (title "Tic-Tac-Toe")
  (description "The game is played on a 3 by 3 grid between players X and O.
    Player X goes first. Each player alternately drops a man in an empty square.
    The game is won if either side gets three in a row, horizontally,
    vertically, or diagonally. Otherwise it's a draw.")
  (history "Tic-Tac-Toe is an old game and is often played when there are
    no moveable pieces available, by drawing or carving marks.
    It is played all over the world under various names, such as 'Noughts and Crosses' in
    England.")
  (strategy "With perfect play, Tic-Tac-Toe is a draw. First player has the 
    advantage, provided the first move is centre or corner. Most games are won
    by leaving two open twos that cannot both be blocked.")
  (players X O)
  (turn-order X O)
  (board
    (image "TTTbrd.png")
    (grid
      (start-rectangle 16 16 112 112) ; top-left position
      (dimensions
        ("A-/B-/C-" (0 112)) ; rows
        ("1/2/3" (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 space")
    (image X "TTTX.png"
           O "TTTO.png")
    (drops ((verify empty?) add))
  )
  (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)
    )
  )
)

 

Posted in Language | Leave a comment

PuzzleScript

PuzzleScript is an open-source HTML5 puzzle game engine. Really a script-based system for creating puzzle games.
http://www.puzzlescript.net/

Increpare Games Ltd is a video game developer based in London, England, founded and operated by Stephen “Increpare” Lavelle in 2004.
http://www.increpare.com/
http://en.wikipedia.org/wiki/Increpare_Games
https://www.patreon.com/increpare

PuzzleScript is written in JavaScript and runs in a Web browser. It is open source.

Here is the code for Sokoban.

title Microban
author David Skinner
homepage www.sneezingtiger.com/sokoban/levels/microbanText.html

(
My favourite set of sokoban levels - here're the first ten of the Microban set.
I tried contacting this guy, but he seems to have vanished from the net. The levels are in lots of places online, so I'm just chancing my arm by including them.  BUT BE WARNED.
)

========
OBJECTS
========

Background 
LIGHTGREEN GREEN
11111
01111
11101
11111     
10111   


Target 
DarkBlue 
..... 
.000.
.0.0.
.000.
.....     

Wall     
BROWN DARKBROWN     
00010
11111
01000
11111
00010

Player 
Black Orange White Blue     
.000.
.111.
22222
.333.
.3.3.

Crate
Orange Yellow
00000
0...0
0...0
0...0
00000


=======
LEGEND
=======

. = Background
# = Wall
P = Player
* = Crate
@ = Crate and Target
O = Target


=======
SOUNDS
=======

Crate MOVE 36772507
endlevel 83744503
startgame 92244503

================
COLLISIONLAYERS
================

Background
Target
Player, Wall, Crate

======
RULES     
======     

[ >  Player | Crate ] -> [  >  Player | > Crate  ]     

==============
WINCONDITIONS
==============

All Target on Crate     

=======     
LEVELS
=======

message level 1 of 10

####..
#.O#..
#..###
#@P..#
#..*.#
#..###
####..

message level 2 of 10

######
#....#
#.#P.#
#.*@.#
#.O@.#
#....#
######

message level 3 of 10

..####...
###..####
#.....*.#
#.#..#*.#
#.O.O#P.#
#########

message level 4 of 10

########
#......#
#.O@@*P#
#......#
#####..#
....####

message level 5 of 10

.#######
.#.....#
.#.O*O.#
##.*P*.#
#..O*O.#
#......#
########

message level 6 of 10

######.#####
#....###...#
#.**.....#P#
#.*.#OOO...#
#...########
#####.......

message level 7 of 10

#######
#.....#
#.O*O.#
#.*O*.#
#.O*O.#
#.*O*.#
#..P..#
#######

message level 8 of 10

..######
..#.OOP#
..#.**.#
..##.###
...#.#..
...#.#..
####.#..
#....##.
#.#...#.
#...#.#.
###...#.
..#####.

message level 9 of 10

#####.
#O..##
#P**.#
##...#
.##..#
..##O#
...###

message level 10 of 10

......#####
......#O..#
......#O#.#
#######O#.#
#.P.*.*.*.#
#.#.#.#.###
#.......#..
#########..

message congratulations!

Posted in Language | Leave a comment

Generalised Game Playing

General game playing is about playing games that you’ve never seen before, figuring out the strategy as you go. It can be done by humans or by intelligent machines. Here are some links.

Web site http://www.ggp.org/
Hosting http://tiltyard.ggp.org/hosting/
Open source base https://github.com/ggp-org/ggp-base
Repository http://ggp-repository.appspot.com/base/
More http://www.general-game-playing.de/
Games http://130.208.241.192/ggpserver/

Game Description Language, or GDL, is a language designed by Michael Genesereth as part of the General Game Playing Project at Stanford University, California. GDL describes the state of a game as a series of facts, and the game mechanics as logical rules. The language is derived from Datalog.

Language https://en.wikipedia.org/wiki/Game_Description_Language
More http://games.stanford.edu/

Source code releases for the base engine are in Java, but there is no generalised user interface.

Here is Tic-Tac-Toe in GDL, courtesy of http://games.stanford.edu/gamemaster/games/tictactoe/tictactoe.kif.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Tictactoe
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Components
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    (role white)
    (role black)

    (<= (base (cell ?m ?n x)) (index ?m) (index ?n))
    (<= (base (cell ?m ?n o)) (index ?m) (index ?n))
    (<= (base (cell ?m ?n b)) (index ?m) (index ?n))
    (base (control white))
    (base (control black))

    (<= (input ?r (mark ?m ?n)) (role ?r) (index ?m) (index ?n))
    (<= (input ?r noop) (role ?r))

    (index 1)
    (index 2)
    (index 3)
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    (init (cell 1 1 b))
    (init (cell 1 2 b))
    (init (cell 1 3 b))
    (init (cell 2 1 b))
    (init (cell 2 2 b))
    (init (cell 2 3 b))
    (init (cell 3 1 b))
    (init (cell 3 2 b))
    (init (cell 3 3 b))
    (init (control white))
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; legal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        
    (<= (legal ?w (mark ?x ?y))
        (true (cell ?x ?y b))
        (true (control ?w)))
    
    (<= (legal white noop)
        (true (control black)))
    
    (<= (legal black noop)
        (true (control white)))
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    (<= (next (cell ?m ?n x))
        (does white (mark ?m ?n))
        (true (cell ?m ?n b)))
    
    (<= (next (cell ?m ?n o))
        (does black (mark ?m ?n))
        (true (cell ?m ?n b)))
    
    (<= (next (cell ?m ?n ?w))
        (true (cell ?m ?n ?w))
        (distinct ?w b))
    
    (<= (next (cell ?m ?n b))
        (does ?w (mark ?j ?k))
        (true (cell ?m ?n b))
        (distinct ?m ?j))
    
    (<= (next (cell ?m ?n b))
        (does ?w (mark ?j ?k))
        (true (cell ?m ?n b))
        (distinct ?n ?k))
    
    (<= (next (control white))
        (true (control black)))
    
    (<= (next (control black))
        (true (control white)))
    
    
    (<= (row ?m ?x)
        (true (cell ?m 1 ?x))
        (true (cell ?m 2 ?x))
        (true (cell ?m 3 ?x)))
    
    (<= (column ?n ?x)
        (true (cell 1 ?n ?x))
        (true (cell 2 ?n ?x))
        (true (cell 3 ?n ?x)))
    
    (<= (diagonal ?x)
        (true (cell 1 1 ?x))
        (true (cell 2 2 ?x))
        (true (cell 3 3 ?x)))
    
    (<= (diagonal ?x)
        (true (cell 1 3 ?x))
        (true (cell 2 2 ?x))
        (true (cell 3 1 ?x)))
    
    
    (<= (line ?x) (row ?m ?x))
    (<= (line ?x) (column ?m ?x))
    (<= (line ?x) (diagonal ?x))
    
    
    (<= open (true (cell ?m ?n b)))
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; goal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    (<= (goal white 100)
        (line x)
        (not (line o)))
    
    (<= (goal white 50)
        (not (line x))
        (not (line o)))
    
    (<= (goal white 0)
        (not (line x))
        (line o))

    (<= (goal black 100)
        (not (line x))
        (line o))
      
    (<= (goal black 50)
        (not (line x))
        (not (line o)))
  
    (<= (goal black 0)
        (line x)
        (not (line o)))
    
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; terminal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    (<= terminal
        (line x))
    
    (<= terminal
        (line o))
    
    (<= terminal
        (not open))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Posted in GGP/GDL, Language | Leave a comment