Artificial intelligent assistant

Many-to-one two-way communication of separate programs I have 3 different programs that I would like to intercommunicate with each other. I have an engine that needs to communicate with 2 bots and the bots with the engine. The engine is written in C++ and the bots can be written in any language. The engine writes output to stdout and both bots need to read the output. Depending on the output from the engine one of the bots will write a response to stdout (it's a turn based game). Here is crude diagram attempting to illustrate what I mean. ![enter image description here]( My current approach is like the following: mkfifo fifo0 fifo1 fifo2 ./engine | tee fifo1 fifo2 < fifo0 & ./bot1 > fifo0 < fifo1 & ./bot2 > fifo0 < fifo2 I read this post on circular I/O which suggests using tail and tee but I am not sure how to make that work with my requirements. Is it possible to do this with pipes? How would this be done with pipes?

You've got the `< fifo0` in the wrong place. You want it to be `engine`'s stdin, not `tee`'s:


mkfifo fifo0 fifo1 fifo2
< fifo0 ./engine | tee fifo1 fifo2 &
./bot1 > fifo0 < fifo1 &
./bot2 > fifo0 < fifo2


Note that many utilities start to buffer their output when it doesn't go to a tty device (here a pipe (or possibly a socket pair if the shell is ksh93)). On GNU systems and FreeBSD, you may try to use the `stdbuf` command to disable that buffering:


mkfifo fifo0 fifo1 fifo2
< fifo0 stdbuf -o0 ./engine | tee fifo1 fifo2 &
stdbuf -o0 ./bot1 > fifo0 < fifo1 &
stdbuf -o0 ./bot2 > fifo0 < fifo2

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 66195e41f8b3f7b1ca67d5ae065615b4