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.
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?