Problem Solving Games

The program game runs problem solving games. Currently these games are available:

Program Features

Automatic Trial Generation

A common property of these problem solving tasks is that the solution is a series of discrete transformations of one problem state into another. These transformations usually "move" objects from one position to another position. Parameter files for the game program differ from the parameter files of other PXL programs in that they must not contain multiple copies of trials since the program creates its trial list automatically while solving the task. Each move corresponds to a single trial and a completed problem corresponds to a block. Thus the number of trials in a block of the data file corresponds to the number of moves needed to solve the problem.

Sometimes only single moves are to be made. This may be forced by setting the flag M. In this case a block may contain more than a single trial.

Initial and Final State Definition

The initial state of each problem is given in the integer array istate. The meaning of istate's entries depends on the problem type. The final and target state may be defined by different methods. In most cases the final state is a fixed state which "solves" the problem. The program will automatically detect this solution and stop the game. Some problems like the Tower of Hanoi will need an additional parameter to specify the solution. This parameter is goal. In the Tower of Hanoi it defines the target pole position. However, it may be necessary to exactly specify some arbitray problem state as a target. In this case finalstate my be used to exactly specify the target state. A game sequence is stopped automatically if the target state is reached. The string parameter answer is used to store the current state of the problem. If the flag M is set then there is only a single move allowed for each game. In this case each block of the parameter file results in only one trial.

Only Valid Moves are Allowed

All the games have rules which forbid certain moves. Only legal moves are accepted by game. An attempt to make an illegal move results in a warning signal and the input is ignored. The warning signal may be disabled by the flag Q.

Emergency Exit

The game program also has an emergency exit for lost subjects. Klicking at the bottom of the screen will bring up two messages: one is goonmsg and the other is giveupmsg. The game is stopped if the subjects klicks on giveupmsg. If the subject klicks on goonmsg then the game goes on. The emergency exit may be disabled by setting the flag E.

The Tower of Hanoi

The program presents eiter a top or a side view of the disk tower, depending on the flag T. In the top view disks are gray and the smaller the disk the lighter the gray. The pole positions are marked by a cross. The task is to move the disks from the start pole to the target pole.

There are n disks, the starting position of all disks is start and the target position is goal. The radius of the largest disk is size and the thickness is weight. position is the horizontal distance of the left and right tower from the center tower.

The TOH game is by default startet with all disks on position start. However, if the integer array istate is set then there have to be exactly n entries giving the initial position of each disk. Thus the game can be started in any state wanted.

For each legal move the parameter frompos holds the position from where a disk is picked up and topos holds the position where the disk is moved to. The current state is recorded in answer. This string contains the current position of each disk. If the integer array finalstate is set then it has to contain n entries like istate and the game is stopped if the disk positions are those given in finalstate.

Missionaries and Cannibals

The MC problem has n missionaries and n cannibals. The boat has seats positions to fill. The initial state of the MC problem is defined by the values of cannibals and monks, which is the number of the respective species on the left bank, and by boat, which is the position of the boat (0 = left, 1 = right). Currently the only available target state is to have all of the personnel on the right bank.

Chinese Rings

This shows a series of black and white dots. The task is to clear all the dots to the background color. Dots may be converted by klicking on them. However, one may only convert a dot's color if There are n dots to work on. The dot diameter is size. The initial dot pattern is given by istate. This has to be a single integer which is interpreted as a binary number giving the state of each dot by the value of each binary digit. The current state of the game is both stored as a string in answer and as an integer in dspstate.

Water Jugs

Three jugs are shown with numbers below indicating the amount of water in each jug and its volume. The target number is given on the bottom. It specifies the amount of water which has to be in one of the jugs. This amount may be arrived at by pouring water in and out of the jugs. To pour the content of one jug into another one it has to be picked with the mouse pointer, moved on top of the target jug and then the mouse button has to be released.

The initial state of task has to be specified in the array istate. It has to contain exactly 3 entries giving the amount of water in each jug. The volume of the jugs is given in the array jugs which also has to contain exactly 3 integers giving the volume of each jug. The target volume is goal. The optical width of a jug on the screen is size and position is the distance of the left and right jug center from the center jug. A jug's heigth on the screen corresponds to its volume. It is scaled according to jugscale which gives the pxlm per unit of volume.

The parameters frompos and topos store from which jug water is poured into which target. answer contains the current amount of water in each jug.

The Tile Shift Puzzle

The TSP is a rectangular frame of n positions containing n-1 tiles numbered from 1 to n-1. There are rows horizontal rows and n/rows vertical columns. Tiles which are next to the empty position may be shifted to the empty position by klicking on the tile.

The tiles are squares and their side length is size. The initial state of the game is given by the array \cistate. For each of the n positions in the frame istate contains the number of the tile at that positions. The number 0 corresponds to the empty position. istate has to contain exactly n entries. Positions are numbered from top left to bottom right.

Each move is recorded by storing the position from where a tile is picked into frompos and the target position into topos. The string answer contains the number of each tile on each of the n positions. The TSP game is considered to be solved if the tiles are arranged in numeric order and the empty field is at the bottom right corner.

Program Parameters

boat (int)
Current boat position (0=left, 1=right, MC only).

cannibals (int)
Current number of cannibals on left bank (MC only).

charsize (int)
Character size of text shown while the game task is running. This parameter also controlls the vertical positioning of the volumes in WJ.

dspcount (int)
Counts the number of moves.

errors (string)
Records the errors which have been made within a trial. The string allows to identify error types by the error numbers which are defined in game.h. If there are no errors then errors is "-".

finaldelay (int)
Waiting time between goal state detection and screen clearing.

finalstate (int)
This may be an array which defines the target problem state in the same way as istate defines the initial state. Whenever finalstate is defined then the game is stopped if the finalstate is reached. This precedes the stopping mechanism controlled by goal.

flags (string)
E
Disable emergency exit. If this flag is set then klicking at the bottom of the screen is illegal.

M
Make single step moves. This allows only one single move per trial. The standard mode is to allow moves until the problem is solved by reaching the goal state. In this case trials are created on line and must not be defined in the parameter file.

Q
Be quiet on errors. Do not beep if the subject tries to make an invalid move.

T
Use a top view version of the Tower of Hanoi.

frompos (int)
Position from where a move was startet in the current trial.

game (int)
Game type: Tower of Hanoi (0), Transportation (1), Chinese Rings (2), Water Jugs (3), Tiles (4).

giveupmsg (string)
Text asking whether the subject wants to stop the game in case she has klicked in the bottom area.

goal (int)
Target pole (TOH) or target volume (WJ).

goonmsg (string)
Text asking whether the subject wants to go on in case she has klicked in the bottom area.

istate (int)
Initial state of the game. In TOH istate gives the positions of each disk. Thus in a game with 5 disks we may set
   istate = [0, 0, 0, 2, 2]
to specify a state where the largest 3 disks still are on the starting pole 0 and the other two disks are on the target pole 2.

In WJ istate gives the inital amount of water in each jug. Thus

   istate = [28, 0, 0]
indicates 28 units in the leftmost jug while the other two jugs are empty.

jugs (int)
Array of jug volumes:
   jugs = [28, 3, 8]
specifies three jugs with volumes 28, 3, and 8 units. jugs must contain exactly 3 entries (WJ only).

jugscale (int)
A scaling factor for drawing the water jugs. The factor corresponds to the number of pxlm per liter volume (WJ only).

monks (int)
Current number of missionaries on left bank (MC only).

n (int)
Number of game objects like disks (TOH), persons per species (MC), rings (CR), and tiles (TSP).

pointerx , pointery (int)
Start position of the mouse pointer at the beginning of a trial.

position (int)
Horizontal position of game objects in case of multiple objects: Physical horizontal pole distances on the screen (TOH) or jug positions (WJ).

rows (int)
Number of rows in the tile shift puzzle (TSP only).

rtime (int)
Duration of a single move. The unit is timeunit ms.

seats (int)
Number of seats in the boat (MC only).

size (int)
Size of game objects like disks (TOH), rings (CR), jugs (WJ), or tiles (TSP).

start (int)
Start position (TOH only).

timeunit (int)
Duration (im ms) of one unit of time which is used to record durations. Times must not be longer than 30000 units. timeunit should at least be 10 ms to allow one move to take 300 seconds. In this case durations are measured in 1/100 s.

topos (int)
Target position of a move in the current trial.

weight (int)
Weight of game objects like disk thickness (TOH).

Example Experiments

The Tower of Hanoi

The first example is a parameter file for running the Tower of Hanoi once. The number of disks may be defined in the command line by using a command line option: -DDSK=5 creates a 5 disk problem. If no option is given then 3 disks are used.\labelgameDEF
Parameter file tohanoi.x from directory \pxl\app\game

Note that the trial arguments are only used to define what parameters should be saved between trials.

Transportation

The next example is a parameter file for running the Missionaries and Cannibals problem. Here also one may define the number of persons and the number of seats in the command line. The default are 3 persons and 2 seats. The command line option -DPN=5 -DSE=3 selects 5 persons and 3 seats.


Parameter file mcgame.x from directory \pxl\app\game

Back to table of contents


Author: Hans Irtel

irtel@psychologie.uni-mannheim.de