Article 13270 of alt.sources:
Path: nntpd.lkg.dec.com!pa.dec.com!decwrl!hookup!news.mathworks.com!tank.news.pipex.net!pipex!dispatch.news.demon.net!demon!news.u-net.com!news
From: a.hunger@hulmecc.nwnet.co.uk
Newsgroups: alt.sources
Subject: mmd - README 3/4
Date: Wed, 20 Mar 1996 21:06:24 GMT
Organization: Hulme Community Computing Ltd.
Lines: 122
Message-ID: <4ipscp$rpp@nuntius.u-net.net>
Reply-To: a.hunger@hulmecc.nwnet.co.uk
NNTP-Posting-Host: hulmecc.u-net.com
X-Newsreader: Forte Free Agent 1.0.82

README FOR mmd

(Thu Feb 22 16:22:18 BST 1996)

COPYRIGHT

This program is copyright by the author.  However the author gives
permission for it to be distributed freely provided that all sources
and documentation are included in the distribution.

AUTHOR

My name and a postal address that will reach me are:

Alex Hunger

81 Chorley Road,
Adlington,
Lancashire,
PR6 9LH
Great Britain

Email (preferred):

a.hunger@hulmecc.nwnet.co.uk

INTRODUCTION

mmd is a program to play mastermind - the unusual feature is that it
can guess a pattern that you choose, using an optimal
information-theoretic algorithm.

mmd is written in C++ and should compile under any C++ compiler with
multiple inheritance, ANSI header files and ANSI libraries.  See
PORTABILITY.

mmd has a pipe mode (see -pipe in the man page) so it can be run with
an X-Windows or Sunview wrapper.  If anybody wants to write one, go
ahead!  I might do it myself some time.

FILES

The distribution consists of the following files:

README       - this file

mmd.6        - manual page for mmd

mmd.cc       - C++ source for mmd

CREATION

First, you have to compile mmd.cc, for example:

gcc -o mmd -O2 mmd.cc -lm -lgpl -liostr

is the command line for djgpp.

Once it has compiled successfully, type:

mmd -gametree

This makes mmd generate a data file in the current directory.  It
takes about 13 minutes on a 33 MHz 486-SX, but only has to be done
once.  After that, mmd runs instantaneously.  The data file produced
is completely portable between different machines.  The reason I
haven't provided it is that it's so easy to generate.

PORTABILITY

The main portability problem is that some C++ compilers don't have
iostream.h but use stream.h instead.  If the preprocessor symbol
STREAM is predefined, then the program #include's <stream.h>,
otherwise it #include's <iostream.h>.

A very minor problem is that the code in movetree.cc does not use
the value returned by ftell as an "opaque" type - the class assumes
that files are a linear stream of bytes. This is true in UNIX and
MS-DOS but not in some other operating systems.

MODIFICATION

If you want to use a different scoring system, just modify the
get_score() method.  The program will still generate optimal guesses.
However, any scoring system MUST satisfy the assertion at the bottom
of the get_score() method, otherwise the code will crash.  Also, the
program assumes that the score returned by get_score() is a function
of its parameters, so no calls to rand()!  The randomising technique
assumes the scoring system is invariant under all permutations of
positions and colours, so if that assumption fails use the switch
-noscramble, which disables scrambling.

In -rightoff mode the invariance assumption still holds, as does
symmetry.  You will find that the program STILL generates optimal
moves and solves the problem - it just takes more guesses.  The only
case where it fails is when the pattern to guess has all colours the
same: e.g. 1111.  In that case, there is no way of solving the
problem, as any guess whatsoever returns the score (0).  The program
AUTOMATICALLY recognises this case and as soon as it discovers the
pattern is of this form it spits out the error message "Impossible to
solve." and terminates.

If you want the program to use an absolute path name for its data
files, instead of the current directory, just set the environment
variable MMDPATH to something else, say "/usr/games/mmdat/" - you must
have the trailing /. Obviously, you can do without this - just cd
inside a batch file that then calls mmd - but this makes life easier.

HISTORY

The program was written to test a conjecture in information theory,
and then grew into a game.  The first version was written using an old
single inheritance Zortech C++ on a PC.  It was later fixed for
multiple inheritance and moved to UNIX - it runs under MS-DOS equally
well.  The code was written simply to run fast - as you'll see if you
look at the code, elegance was not a consideration.  However, it seems
to be bug-free even though it displays all the stigmata of a C
programmer who had only just started using C++.






