Parallel Othello with Work Queue

In the previous assignment, you connected together existing programs into a high throughput workflow for video rendering. In this assignment, you will go the opposite direction, taking a sequential program, and adapting it to a distributed system using the Work Queue.

The Work Queue

Download and install the Work Queue in your home directory. Read the Users Manual and try out the example therein.

The Game of Othello

Othello is a traditional board game played with pieces that have black (X) on one side, and white (O) on the other. There are several variations on the game, but we will play with the following rules:
  • Regardless of the size of the board, the game begins with this position at the middle of the board:
    . . . .
    . X O .
    . O X .
    . . . .
    
  • Player X goes first.
  • Players take turns placing one piece onto the board, until it is full.
  • Each piece must be played adjacent -- horizontally, vertially, or diagonally -- to another piece on the board.
  • Any pieces of the opposing color in any straight line that ends in the newly-placed piece and another piece of the same color are flipped to become the other color.
  • The player with the most pieces on the board at the end of the game wins.
  • Here are the first few moves in a small game:
    % ./othello 4 4 3
    
       0 1 2 3
     0 . . . .
     1 . X O .
     2 . O X .
     3 . . . .
    
    computer moves: 2 0
       0 1 2 3
     0 . . X .
     1 . X X .
     2 . O X .
     3 . . . .
    
    your move: 3 0
       0 1 2 3
     0 . . X O
     1 . X O .
     2 . O X .
     3 . . . .
    
    computer moves: 0 2
       0 1 2 3
     0 . . X O
     1 . X O .
     2 X X X .
     3 . . . .
    
    your move: 1 0
       0 1 2 3
     0 . O O O
     1 . X O .
     2 X X X .
     3 . . . .
    
    Othello is a nice example of a game that can be played by implementing a search tree with the Minimax Algorithm. We will discuss this extensively in class, so I won't repeat it here.

    The Assignment

  • Write a sequential program called othello that plays Othello interactively with the user. The program should be invoked as othello width height depth where width and height describe the size of the board, and depth is the maximum depth of the minimax tree to explore on the computer's move. For each computer move, print out the time taken and number of board positions evaluated. To get you started, here is a skeleton of a program to follow.

  • Write a sequential program called othello_worker that is invoked as othello_worker board depth, where board is the name of a file containing any arbitrary board configuration. The program should determine the minimax score of the configuration and print it on the standard output.

  • Write a program called othello_master that plays Othello interactively with the user, as in step 1. However, instead of doing computation locally, use the Work Queue to run multiple instances of othello_worker in parallel in order to determine the next move. As above, for each computer move, print out the time taken and number of board positions evaluated.

  • Compare the performance of the sequential and Work Queue implementations. Vary the board size and search depths, and report the time for each move. How much faster is the Work Queue implementation? Try to use as many workers as possible: are there limits to how fast you can go?
  • What to Turn In

    Your dropbox directory is:
    /afs/nd.edu/courses/cse/cse40771.01/dropbox/YOURNAME/a2
    
    Turn in the following:
  • The source code for othello.c, othello_worker.c, and othello_master.c.
  • A Makefile that builds everything.
  • A short lab report (.txt or .doc) that outlines your methods, results, and conclusions.
  • This assignment is due on 16 February at the beginning of class.