home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1996 #3 / AmigaPlus_CD-ROM-EXTRA_Nr.3.bin / aminet-spiele / brettspiele / funkylady / funkylady.doc < prev   
Text File  |  1995-04-16  |  16KB  |  363 lines

  1.         Funkylady, the Othello contestor
  2.         Copyright © 1993 Ola Liljedahl, all rights reserved
  3.         Freely distributable
  4.  
  5.         Contents:
  6.         1. Introduction
  7.         2. Usage
  8.         3. Configuration
  9.         4. Position files
  10.         5. Othello goals and tactics
  11.         6. Implementation
  12.         7. Background
  13.         8. Thanks
  14.         9. Author
  15.     
  16. 1. Introduction
  17.  
  18.    Funkylady is a highly optimized Othello program with a simple text user
  19.    interface.
  20.  
  21.    I think Funkylady is very good, in autumn 1993 it probably ranked among
  22.    the 10 best Othello programs in the world.
  23.  
  24. 2. Usage
  25.  
  26.    Funkylady must be started from the command line. Make sure the stack is
  27.    large enough, 16K is ok. The font in the console window ought to be of
  28.    fixed width and support bold characters nicely.
  29.  
  30.    Command line options:
  31.       ?        Display the command line options.
  32.  
  33.       -ccolor <color>
  34.                Specify the computer's disc color, must be one of 'black'
  35.                or 'white'. Default is white, i.e. human player (who is black)
  36.                starts.
  37.  
  38.       -ttime <time>
  39.                Specify target time, the total time for the computer to
  40.                spend during the game, specified in minutes. It is possible
  41.                that the computer will exceed this time limit, game tree
  42.                traversal time is not easily predicted.
  43.  
  44.       -load <filename>
  45.                Load a saved position, start playing where saved. Can be
  46.                combined/enhanced with the -from option.
  47.  
  48.       -from <move number>
  49.                Specify from which move to start the game when restarting
  50.                from a loaded position. Moves are numbered from 1 till 64
  51.                (or even larger than 64, since passes count as moves).
  52.  
  53.       -cachesize <number of elements>
  54.                Specify size (number of elements) of the evaluation cache.
  55.                The use of a (large) evaluation cache may speed up the
  56.                evaluation of positions and therefor speed up the search.
  57.                Should be a large value, probably also a prime number is
  58.                better.
  59.  
  60.       -deterministic <boolean>
  61.                Specify that Funkylady play deterministically. Normally
  62.                Funkylady tries to vary the (within limits) the playing even
  63.                when starting from identical positions. However when evaluating
  64.                newly implemented optimizations in the game tree traversal
  65.                algorithm determinism is absolutely necessary. Valid values
  66.                are 'true' and 'false'.
  67.  
  68.       -opponent <name>
  69.                Specify the name of Funkylady's oppponent, usually the human
  70.                player (you).
  71.  
  72.       -nodump  Normally Funkylady dumps the resulting position in a file
  73.                named dump.<big number> when the game is over. When this
  74.                option is specified no position is dumped at the end of the
  75.                game.
  76.  
  77.       -pipe <inpipename> <outpipename>
  78.                Specify two filenames (names pipes) that Funkylady shall use
  79.                for reading the human's move and writing it's own move. Two
  80.                instances of Funkylady should be started, each in a separate
  81.                window and with the pipe names swapped.
  82.                Window 1 : 'funkylady -ccolor black -pipe pipe:x pipe:y'
  83.                Window 2 : 'funkylady -ccolor white -pipe pipe:y pipe:x'
  84.            Now these two instances play against each other. Can be used
  85.            to automate the process of evaluating two (different) versions
  86.            of Funkylady (or another Othello program).
  87.            Note that I had problems with named pipes, I had to open and
  88.            close the pipe before/after each read or write to make it work.
  89.            probably to overcome some buffering in AmigaDOS.
  90.  
  91.    Commands (at the 'Enter your move:' prompt):
  92.  
  93.       ?        Display available commands.
  94.  
  95.       quit     Quit Funkylady.
  96.  
  97.       undo [numofmoves]
  98.                Undo specified number of moves, one move if none specified.
  99.                'undo 2' is required to correct a stupid move.
  100.  
  101.       save [filename]
  102.                Save the current position to specified file. If none specified
  103.                a filename is prompted.
  104.  
  105.       load [filename [frommove]]
  106.                Load a position from the specified file. If none specified a
  107.                filename is prompted. Optionally the move from which the saved
  108.                position should be played can be specified. This way a lost
  109.                game can be replayed from a selected position.
  110.  
  111.       help [targettime]
  112.                Ask the computer to think for you and suggest a good move.
  113.                Optionally a search target time (in seconds) can be specified.
  114.  
  115.    Moves are entered column first (a letter in the range 'a'..'h' or 'A'..'H')
  116.    followed by the row (a digit in the range '1'..'8'). If no move is possible
  117.    one has to pass and enters 'ps'. Pressing enter without any value prints
  118.    one's possible moves. However if only one or less moves are possible this
  119.    move or pass is automatically entered.
  120.  
  121. 3. Configuration
  122.  
  123.    At startup Funkylady initializes game parameters to builtin defaults. If
  124.    the file funky.param exists (in the current directory) it is read and game
  125.    parameters are adjusted accordingly. Last but not least options on the
  126.    command line affect the game parameters.
  127.    
  128.    This is an example funky.param file:
  129.  
  130.       #this is Funkylady's parameter file
  131.       computercolor white
  132.       computername Funkylady
  133.       targettime 1200
  134.       cachesize 0
  135.       deterministic false
  136.       potmobility 1
  137.       winloss 45
  138.       discdiff 49
  139.  
  140.    The hash character '#' signifies that this line shall be ignored (is a
  141.       comment).
  142.    'computercolor' is the disc color of the computer, valid values are 'black'
  143.       and 'white'.
  144.    'computername' is the name of the computer (Funkylady).
  145.    'targettime' is the total time the computer shall spend during the game.
  146.       This value is specified in seconds (and not in minutes as on the command
  147.       line, a small piece of inconsistency).
  148.    'cachesize' is the size (number of elements) of the evaluation cache. If
  149.       specified it should be a large (>50000?) value and probably a prime
  150.       number. Use 0 for no cache.
  151.    'deterministic' specifies that Funkylady play deterministically. Valid
  152.       values are 'true' and 'false'.
  153.  
  154.    'potmobility', 'winloss' and 'discdiff' are different evaluation funtions
  155.       used by the game tree traversal.
  156.    'potmobility 1' specifies that the potmobility evaluation should be used
  157.       from move 1. 'winloss 45' specifies that winloss evaluation should be
  158.       used from move 45. 'discdiff 49' specifies that discdiff evaluation
  159.       should be used from move 49 till the end. These values are suitable for 
  160.       a 20 minute game (per player) on a 25 MHz 68030. For a slower computer
  161.       the following values could be used:
  162.          potmobility 1
  163.          winloss 51
  164.          discdiff 55
  165.       If the computer continuously violates the time target these values
  166.       should be increased.
  167.  
  168. 4. Position files
  169.  
  170.    The position file contains a snapshot of a position in the game or after
  171.    the games was ended. It can be used to start playing from the saved position
  172.    or (with the -from option) to restart the game at an earlier stage. A
  173.    position file is automatically written to the current directory when the
  174.    game has ended, this behaviour can be disabled with the -nodump option.
  175.  
  176.    The position file contain the same fields as the parameter file (funky.param)
  177.    and additionally:
  178.  
  179.       board
  180.       ........
  181.       ........
  182.       ...xo...
  183.       ..ooo...
  184.       ..xxo...
  185.       .x.x....
  186.       ........
  187.       ........
  188.       timestamp 798000556
  189.       humantime 32
  190.       computertime 17
  191.       turntomove black
  192.       passes 0
  193.       moves d3 c5 b6 e3 d6 c4 
  194.       times 19 0 4 0 9 17 
  195.  
  196.    'board' obviously describes the board at the time the position was saved.
  197.    'timestamp' is a time stamp from the moment the game was started. Used to
  198.       enforce determinism (I think).
  199.    'humantime' is the number of seconds the human has spent thinking
  200.       (computing?).
  201.    'computertime' is number of seconds the computer has spent computing
  202.       (thinking?).
  203.    'turntomove' is the color of the player to move.
  204.    'passes' is the number of passes in this position.
  205.    'moves' is followed by a list of the played moves. Passes are included.
  206.    'times' is followed by a list of the number of seconds the player spent
  207.       contemplating the position.
  208.  
  209. 5. Othello goals and tactics
  210.  
  211.    The goal of Othello is to have the most discs when the game is OVER. The
  212.    game is over when all discs have been placed on the board or no player 
  213.    can place any disc. A move is legal if it (together with another of the
  214.    player's discs) encloses one or more of the opponent's discs. These discs
  215.    are then turned into the color of the player's disc.
  216.  
  217.    Tactics:
  218.    During most of the game it is much more important for the player to have
  219.    the possiblity to place as many discs as possible (in as good positions
  220.    as possible of course, some positions are very bad). A good player has many
  221.    (good) moves in the end of the game whilst his opponent only has a few (bad)
  222.    moves or no moves at all. In reality this contradicts the ultimate goal (of
  223.    having the largets number of discs) during most part of the game.
  224.    
  225.    Algorithm:
  226.    Few discs during the game, ALL discs when the game is over, a transitional
  227.    period in the end where all discs are turned to your color.
  228.  
  229.    Implementation:
  230.    Only heuristics that approximate the wanted result are known. Many exists,
  231.    few are good. One of the best is "potential mobility" as defined by the
  232.    British matematician/Othello player Joel F. Feinstein and is used in his
  233.    program 'Modot'. Modot has been used as a sparring partner to Funkylady
  234.    whose heuristics had to evolve to win against Modot. Differences in speed
  235.    mattered less.
  236.    
  237.    Potential mobility is the quantity of opponent discs facing empty squares.
  238.    Subtract the quantity of own discs that face empty squares and use this
  239.    value as a measure of the goodness of the position. Simple.
  240.  
  241. 6. Implementation
  242.  
  243.    Algorithms + Data Structures = Programs (Wirth)
  244.    Algorithms + Data Structures + Heuristics = A.I. Programs
  245.    (Somewhere we forgot the user interface, another important part these days)
  246.  
  247.    Three design decisions are important for game playing programs:
  248.    1: datatype (for board)
  249.    2: game tree traversal algorithm
  250.    3: heuristics (board evaluation functions)
  251.    (in a probable, increasing order of importance)
  252.  
  253.    Funkylady uses bitboards, i.e. boards are described by bit vectors, in
  254.    Funkylady's case 64 bit integers (long long). Bitboards are compact and
  255.    can be manipulated with bit operations. Whole boards are operated on at
  256.    once, for instance computing all legal moves with a few (?) bit operations.
  257.    Many ideas came from Desdemona's (rather simple) board operations which were
  258.    implemented in hardware.
  259.  
  260.    To traverse the game tree efficiently Funkylady uses the alfabeta pruning
  261.    version of minimax with minimal window/scout presearch. These are standard
  262.    techniques, find a standard artificial intelligence text book.
  263.  
  264.    The heuristics used are an evolution of Joel F. Feinsteins potential
  265.    mobility which could be called inverse combined potential mobility (???).
  266.    This heuristic is used for evaluation until the end game search starts.
  267.    Close to the end of the game Funkylady searches to the (bitter) end but
  268.    only evaluates the final position as a win, a loss or a draw. This makes
  269.    for faster searching since more possibilites can be pruned from the search.
  270.    Real close to the end Funkylady evaluates the disc difference at the end of
  271.    the game computing the exact utcome.
  272.  
  273.    The code is written with GCC in mind, especially the use of long long and
  274.    of inlining of functions and even some inline assembly on 68K machines. It
  275.    is possible to compile it with other compilers supporting 64 bit integers
  276.    such as SunSofts SPARCCompiler. A native 64 bit CPU would be perfect.
  277.  
  278. 7. Background
  279.  
  280.    In the spring of 1993 I particiated in two seven week courses at the
  281.    Department of Computer Engineering headed by Prof. Lars Philipsson (at Lund
  282.    University), Design Methods for Computer Systems (KDS) and Computer Systems
  283.    Design (DSK).
  284.  
  285.    The goals were:
  286.    KDS: create a project plan and a prototype of an Othello playing machine
  287.    DSK: build the Othello playing machine according to the plan
  288.  
  289.    During KDS I worked with the prototype, designing the hardware that would
  290.    perform Othello operations. Our design - called Desdemona - (pipelined
  291.    design with 5 Actel-2 FPGA's and a commercial telephone switching circuit
  292.    from LSI Logic for move ordering) won (there were two teams competing).
  293.  
  294.    During DSK I worked with the functional model that was to be the reference
  295.    for the actual hardware. It was also used in place of the hardware to test
  296.    the software of Desdemona before the hardware was finished.
  297.  
  298.    We made it! (However not on time, who does?)
  299.  
  300.    The full Desdemona machine consists of a 286 PC with 2 Megs of RAM, a VGA
  301.    graphics card and a not too big hard drive. In an extension slot sits our
  302.    custom designed 8 bit ISA board with the FPGA's (among other circuits). The
  303.    hardware runs at ~3.5 MHz and evaluates ~150,000 Othello positions per
  304.    second. That is enough for a 20 level end game search.
  305.  
  306.    Desdemona participated in 1993's Othello Championship held in Paderborn
  307.    Germany and reached a joint 6:th position (of 12 participants) together
  308.    with Joel Feinstein's Modot. After the competition it was clear that
  309.    Desdemona used the brute force method (fast hardware, simple heuristics)
  310.    whilst the winner used advanced pattern evaluation techniques (complex
  311.    software and 60M (!) of precomputed evaluation tables). The future lies in
  312.    software running on a general purpose computer.
  313.  
  314.    As a spinoff to the Desdemona project I had a fully functional prototype to
  315.    an Othello program. I spent several months optimizing the code and the
  316.    heuristics (position evaluation functions) and wrote my own user interface.
  317.    Result: Funkylady.
  318.  
  319. 8. Thanks
  320.  
  321.    Thanks go to:
  322.  
  323.    Joel F. Feinstein for the source of Modot and many valuable insights into
  324.    Othello game playing.
  325.  
  326.    Nils Berner, the Swedish Othello champion, for help with Desdemona's/
  327.    Funkylady's (rather simple) opening book and Desdemona sparring.
  328.  
  329.    Ingvar Lindgren for being the prime Funkylady sparring partner (besides
  330.    Modot...). Those days were fun.
  331.  
  332.    And some prominent members of the Desdemona project:
  333.  
  334.    Lars Johansson, project head KDS
  335.  
  336.    Torbjörn Andersson, prototype codesigner (KDS), project head DSK
  337.    
  338.    Johannes Elg, chief silicon implementor (DSK)
  339.  
  340.    If you ever meet them, they're bright, dedicated and hard working.
  341.  
  342. 9. Author
  343.  
  344.    My name is Ola Liljedahl. I have owned and used Amigas since 1987, coded
  345.    some demos (mostly unreleased vector graphics) and programmed a lot in C
  346.    and 68K. I (almost) hold a Computer Science/Engineering Master's exam from
  347.    Lund University Sweden. There still some minor things to finish...
  348.  
  349.    Currently I am employed by Enea Data, a company that specializes in 
  350.    consulting in the areas of real time systems, OO methods and quality
  351.    assurance (boring but necessary, I assure you). Enea also develops and
  352.    sells a family of real time operating systems, OSE. That is my job, OSE
  353.    development.
  354.    
  355.    My current computer system is an Amiga 3000 25 MHz, 4M fast and 2M chip RAM,
  356.    50M + 520M harddisk, Picasso II graphics board (excellent) and KS/WB 3.1.
  357.    I desperately need more RAM, but ZIP's are hard to find these days.
  358.  
  359.    I am reachable with Internet mail at the address olli@enea.se. Feel free
  360.    to mail if you are having problems with Funkylady, have interesting views on
  361.    artifical intelligence, (computer) game playing etc. or if you can tell me
  362.    where to buy another 4M of static column ZIP RAM.
  363.