Let's say I have two programs which play chess: chess_1
and chess_2
. They keep track of the board themselves, and take as input opposing moves, and then output their moves. For example, if I wanted to play against chess_1
, I would do the following:
I would start the program (assuming I am white)
$ ./chess_1 # program starts and hangs for input
<my move> # my input
<the bot's move> # bot output
<my next move> # my input
.... < etc. > .....
And the bot would keep track of the game board. My question is, how can I make chess_1
play against chess_2
?
chess1
to stdin ofchess2
and vice versa? For a start I would say you should be allowing the move to be specified throughstdin
rather than via a command line argument. After that, why not just use named pipes? – Wildcard Apr 19 '16 at 01:54fifo
s (for "first in first out"); that may help. The tool to create them ismkfifo
but the man page assumes you already know what they are. :) Here's an Introduction to Named Pipes. – Wildcard Apr 19 '16 at 01:57