This is the first of many ‘Micro:Challenges’ for use by TAG Junior-Engineers with Micro:Bit devices. The intent of this particular post is to create an initial layout, feedback flow, and some interaction to test the concept for ongoing use.
This program, when loaded on two or more Micro:Bits and running in near proximity to each other will allow players to play a simple game that is vaguely similar to Battleship.
How it works | How to play:
- Load the program on two or more Micro:Bits
- The game starts with all players on channel 0
- Players will press button A to change channels on their device
- The other Micro:Bits that are still on the same channel will also switch to the new channel – BUT some may not have (due to that player also having pressed the A button or their device lagging behind)
- The current channel that a player’s device is using is displayed on the LED display (0-5)
- When two or more players are on the same channel, the first player to press the B button will signal the others to play a short melody and present a large ‘X’ on the LED display to signify that they have lost.
The code can also be found at https://makecode.microbit.org/_MohWmDViRdJ0
def on_received_number(receivedNumber): global channel channel = receivedNumber basic.show_number(channel) radio.set_group(channel) radio.on_received_number(on_received_number) def on_button_pressed_a(): global channel channel = randint(0, 5) radio.send_number(channel) basic.show_number(channel) radio.set_group(channel) input.on_button_pressed(Button.A, on_button_pressed_a) def on_received_string(receivedString): basic.show_icon(IconNames.NO) music.start_melody(music.built_in_melody(Melodies.DADADADUM), MelodyOptions.ONCE) radio.on_received_string(on_received_string) def on_button_pressed_b(): radio.send_string("BOOM") input.on_button_pressed(Button.B, on_button_pressed_b) channel = 0 radio.set_group(channel)
Players can still press the B key – even after they have been disqualified. That does not seem fair.
Players can immediately hit the B key at start of the game – this might be a quick strategy, or it might be a flaw. Perhaps the first press of the B key should be disallowed until after the first channel change?
Can you think of more improvements?