The Game
It is a two person game where each player secretly selects a choice from the three positions: Rock, Paper or Scissors. After both have chosen, the choices are compared and the game scored. If both players pick the same, it is a tie. Else one player is the winner, the other the loser, according to the sceme: scissors cut paper, paper covers rock, rock breaks scisssors.
Each player choses as name, say X and Y. Each player makes a choice, say CX and CY. Player X then runs the program like this:
rps X Y CXPlayer Y runs the program like this:
rps Y X CYThe program terminates stateing whether the player has won, lost or tied the game.
General Description
The programs will communicate using the file system, in particular by creating a file named Rock, Paper or Scissors. To prevent cheating, we will use the file system protection mechanisms, placing the named files in directories and then controling the readabililty of the directories.
After each program has committed the user's choice by creating a file inside of an unreadability directory, the two programs will rendez-vous. This is a tricky little bit of programming: to get two programs to synchronize. The programs will memorize the time of the rendez-vous. They will then make the directories readable, revealing the choices. They will check the change-time of the opponents' files to ascertain they have not cheated. The change-time must be less than the time of rendez-vous.
We can go on and do clean up, and repeated games with score keeping, and so on. But for now I will just give a more detailed description of the simple version of the program.
Details
See the rendez vous code at /rps.
The two players pick distinct names, we will call them X and Y. It is important to note which name is lexicographically smaller, since tasks are divided up depending on this. We will assume X is smaller than Y in lexicographic order.