Lines of Communication
version 1 by Aaron Reed
Example: ** Man vs Robot - Imagining a chess match with both an external chess computer and a peanut gallery of online commenters.
This example demonstrates using two simultaneous file channels: a chess computer and a peanut gallery. Both receive the player's moves, but the chess computer responds with commands to play (which are parsed differently while this channel is switched on) and the peanut gallery responds with text utterances, presumably from some chat server which the external module is ferrying game moves to.
To test this, try to PLAY one of the gambits, then open up commentOutput.glkdata and try saving a command like "SUGGEST ooh look, he's weak on the left flank!" (without the quotes). For the computer to make up its mind, add a line like "PLAY BISHOP'S UNMENTIONABLES" to chessOutput.glkdata. Set the polling speed in milliseconds to a high number to see how the extension can correctly deal with input from both sources if they come in at the same time.
"Man vs Robot"
Include Lines of Communication by Aaron Reed.
The File of chess-input is called "chessInput". The File of chess-output is called "chessOutput".
The chess computer is a real-time file channel. The input file is File of chess-input. The output file is File of chess-output.
The File of comment-input is called "commentInput". The File of comment-output is called "commentOutput".
The peanut gallery is a real-time file channel. The input file is File of comment-input. The output file is File of comment-output.
The Arena is a room. A hulking metal robot is a man in Arena. A chessboard is here. For writing a paragraph about robot: say "Your opponent, a hulking metal robot, hunches over [the chessboard]."
A chess gambit is a kind of thing. The queen's gamble, the bishop's unmentionables, and the knight's orangutan are chess gambits in Arena. For writing a paragraph about a chess gambit: say "Possible strategies include [the list of visible chess gambits]."
Understand "play [a chess gambit]" as playing. Playing is an action applying to one thing.
Check playing when chess computer is switched on: instead try the robot playing the noun.
Carry out playing:
say "Boldly, you play [the noun]. Your opponent begins to think. [run paragraph on]";
inform chess computer that "[the noun]";
now chess computer is switched on;
inform peanut gallery that "Human plays [the noun]!";
now peanut gallery is switched on.
Carry out the robot playing:
say "[paragraph break]The robot's gears finally grind, and it decides to play [the noun]. 'YOUR MOVE,' it grates.";
now chess computer is switched off;
inform peanut gallery that "Robot plays [the noun]!";
now peanut gallery is switched off.
Understand "suggest [text]" as suggesting. Suggesting is an action applying to one topic. Carry out suggesting: say "Comment from the peanut gallery: '[the topic understood]'".