Chain reaction (Digital Systems)

Copyright © 2024 J. M. Spivey
Jump to navigation Jump to search

This (non-competitive) game uses several micro:bits running identical software and communicating over the radio.

  • Each micro:bit has a unique ID, derived from the chip's serial number.
  • Each micro:bit regularly broadcasts its ID in a PING message, so that other micro:bits can learn of its existence. Each micro:bit compiles a list of (up to a certain number of) other micro:bits in the game. If an element of the list is not updated for a certain time, it is deleted in case its owner has left the game. To avoid repeated collisions between PING packets, the inter-packet interval should differ slightly (and randomly) between one node and another.
  • Pressing one of the buttons on any micro:bit initiates a chain reaction as follows: first, this micro:bit performs a display animation for about two seconds. Afterwards, the node randomly chooses two neighbours and sends them BANG messages, each containing the ID of the recipient and a time-to-live of (say) 5. For a variation, one of the BANG messages could be sent immediately, and the other after a (perhaps random) delay.
  • On receiving a BANG message containing its ID, a node performs the display animation, then (if the time-to-live of the received message is greater than zero) sends BANG messages to two random neighbours with a time-to-live one smaller. The effect should be a growing reaction that dies out after a while.
  • Messages that collide on the air are necessarily lost, and BANG messages received by a node during its display animation can be ignored. Both of these factors may slightly reduce the multiplication rate of the chain reaction.