Next: Protocol---Child Side Up: Parent-Child Protocol Previous: Parent-Child Protocol

Protocol---Parent Side

The parent initiates the children and uses UNIX pipes to communicate with them. For each child, input and output file descriptors are kept. After each child process is created, but before the child program is executed, the file descriptors are mapped to the standard input and standard output descriptors. Streams are then opened for each of the child file descriptors.

Once all of the children have been created with the pipes in place, the parent enters into the following protocol:

  1. If the computer is to be playing first, send the character `y' to all the children; otherwise, send the character `n'. (This and all other protocol messages are sent as ASCII characters and are terminated by a newline character.)
  2. If the computer is not moving first, send the column number (0--6) of the opponent's first move to all the children.
  3. Mark all children active.
  4. Let each child be numbered 0 to 6. Send each active child its own number. This is the move number for that child to consider.
  5. For each active child, read the signed integer evaluation of its move.
  6. Send to each active child the number of the move selected.
  7. If that move resulted in a win or the opponent's response resulted in a loss, then send the character `n' to all active children, indicating that the game is over and that they should all exit.
  8. Otherwise, for each active child whose column is full, send the character `n' and mark the child as inactive and for those whose columns are not full, send the character `y'.
  9. Send the opponent's move to each of the active children.
  10. Go to step 4.

Each time a move is selected, the parent program looks up the coordinates for the drop position over the selected column. The appropriate movement angles are computed as described in Section 5 and are encoded into a message which is sent to the robot arm.



Next: Protocol---Child Side Up: Parent-Child Protocol Previous: Parent-Child Protocol



Brian L. Stuart