1. Home
  2. FRUITMACHINE procedure


Runs a fruit machine using pop-up menus and Genstat graphics (R.W. Payne).


PRINT = string tokens What to print (display, reels, summary, transcript); default * i.e. nothing
CREDIT = scalar Credit for the game; default *
NTIMES = scalar Limit on the number of pulls in the current session; default 999
PICTURES = string token Which pictures to use (cards, fruit); default frui
REPLICATION = scalar or variate Number of times each picture should occur on each reel; default 1
WINS = scalar or variate Amount to win on a complete line of each picture; default 5
SEED = scalar Seed for random numbers to form the reels and execute the pulls; default 0
SAVE = pointer Saves or specifies the state of a game so that it can be continued

No parameters


The Genstat fruit machine is designed to provide amusement, and to allow the properties of these gambling machines to be studied. It has three reels, and displays three lines at a time. The PICTURES option controls whether they display pictures of 13 different types of fruit or of playing cards (Ace, 2-10, Jack, Queen and King). The default is to show fruits. You win if any of these lines contains the same picture on all three wheels.

To play the game you need only execute the command


Genstat uses default options to set up the machine, and pops up a dialog telling you how much you will win for each line of identical pictures and asking you to enter some credit. (You will lose one unit of credit for each unsuccessful pull, and win the specified units of credit for each win.) It then displays a graph showing the initial configuration of lines, and pops up a dialog with your choices. With the initial display you can choose one of the following.

Nudge – to move one or more of the reels down one line. (This may allow you to complete a line, using cards from an earlier line.)

Pull some reels – to  pull one or more of the reels. (You might want to do this if any of the lines contains two identical cards.)

Pull all reels – to pull all the reels.

Quit – to end the game.

If you choose either of the first two options, they will not be available next time. Genstat remembers the state of the game after you quit. So if you execute FRUITMACHINE again, you will be given the choice of starting a new game, or continuing the previous game (adding the credit that you enter to any credit left from the previous game).

The options can be used to customize the machine. The REPLICATION option specifies how many times each of the pictures appears on each reel. This can be a scalar if they are all to appear the same number of times, or a variate with 13 values if they are to appear different numbers of times. By default, each card appears once. The WINS option specifies how much you win on a complete line of each picture. You can specify a scalar to win the same amount on every picture, or a variate (with 13 values) to win different amounts. The default is that you win five on any of the pictures. The SEED option specifies the seed for the random numbers used to form the reels, and to execute the pulls. The default of zero continues any existing sequence of random numbers, or selects a seed at random using the computer’s clock.

The NTIMES option sets a limit on the number of pulls (or nudges) in each game; default 999. This can be used to ensure that a batch run terminates, or to ensure that you do not play for too long interactively!

You can use the CREDIT option to specify the credit in the command, rather than in the initial dialog. You must use this if you are running Genstat in batch. In fact, in a batch run, no dialogs are popped up. Instead Genstat decides on the best strategy (nudge, pull selected reels or pull all reels) at each stage, until either the credit runs out, or the number of pulls exceeds NTIMES.

The SAVE option can save the current state of the game, in a pointer. You might want to use this to override the automatically saved game, if you wanted to run a game again trying different strategies.

The PRINT option specifies what output is required, with settings:

display prints the lines displayed in each successive graph;

reels prints the contents of the reels;

summary prints a summary, giving the number of pulls, wins and losses and the credit remaining, at the end of each game; and

transcript prints a transcript of the information appearing in each pop-up, and the actions taken.



The dialogs are produced by the QDIALOG directive.

See also



             !t('Credit 20 and maximum number of pulls 50,',\
             'with default options for replication (1) and wins (5).');\
FRUITMACHINE [PRINT=reels,summary,transcript; CREDIT=20; NTIMES=50; SEED=476794]
Updated on February 6, 2023

Was this article helpful?