09 Enhance

Now that you have a working basic program, here are modifications you can make:

  1. World 3 refuses to change its color.

  2. Pick one world (by id number) to be the “random world” (R-world). The R-world changes its color randomly when asked to change. That is, no matter what message is sent to the R-world, it changes to a random color. This is most interesting with 3 or more worlds.

  3. Add “spam” functionality (also called “broadcast”), so that one world can set the colors of all other worlds at once. Here is one way to do this:

    • Hitting the “spam” key (“s”) sends a message to world number negative one (-1). That means pick a world number like $-1$ that no world will actually have, and use it for a special purpose.
    • Receiving a message to world number $-1$ affects every word. A conditional in your receive handler can do this.
  4. Add an “all randomize” key (“t”). Send a special message that causes every world to randomize its color.

Last modified March 15, 2024: wy-cs site update 2024-03-15 13:30 (1f67698)