An invention was patented in 1948 that has assisted millions in making decisions. Long before widespread access to computers, this device - completely mechanical gave instant answers to questions - no AI or LLM required.
I refer to ... the Magic 8 Ball.
It doesn't take much of a web search to find examples of programs to recreate the Magic 8 Ball. It's an easy exercise - for example, here's one at geeksforgeeks.org that made a fun starting point for me to adapt for some Adafruit fun.
It wasn't hard to adapt that code into CircuitPython for the NeoTrinkey. I put together Magic8.py. Load that on a NeoTrinkey - copied to code.py. When run, it will display a blinking idle pattern. Touch either touch pad and it will go to Green (yes), Yellow (maybe) or Red (no). If you are running it in an IDE like Mu or Thonny, the REPL will print an answer appropriate to the verdict. Touch the pad again to return to the idle pattern.
But, why not make a better, smarter tool - something that you can use to calculate the answer? And why not have it SPEAK the answer?
In my DecisionMaker repository you'll find all you need to do that.
Starting with MakeCode I created a two-mode DecisonMaker for Circuit Playground Express. With the switch to the right, press the "A" button and it will give you a Green/Yellow/Red verdict. In addition, IF it is plugged in to a computer with a usb cable, touching A4 will give you a verdict and TYPE the appropriate message text. (note: If the CPX is not connected to a computer, touching A4 will crash the program; also, if you copy DecisionMaker.js into MakeCode, you'll need to add the Keyboard Extension; it's already in the version at this link).
The other mode is what you get when you move the switch to the left. This lets you give more input for the program to evaluate your question. Essentially, break your question into factors (as many as you want) and give each factor a value good or bad, then ask the DecisionMaker to weigh in. With each factor press A from one to five times (for Good) and B from one to five times (for Bad). After scoring the factor, touch A1 to add it in.
For example, lets say your question is "Should I go see the new movie Super Space Blockbuster XIII?" and you break down the factors to:
- I love Super Space Blockbusters - read all the books and comics and have all the action figures
- I didn't like the last three that much
- I hear they added famous actor Kirk Handsome
- I think it will be streaming in a couple of months.
So, here's the steps in the evaluation:
Put all those together, and hit the A2 touch to get the verdict.......
One more feature: After an evaluation, touching A7 will show you the last result.
AND now, Circuit Python!
The fun thing about using MakeCode is, it provides a quick way to prototype a project. And, since the web IDE includes a simulator, you can test the project to see how it works as you put it together. After creating a working DecisonMaker in MakeCode, I wanted to make the Circuit Python version - because that would let me add speech! I recorded all the eight messages as .WAV files and saved them to m8/ on the device.
Then I followed the design from the MakeCode version - all the controls are the same. Copy the WAV files to m8/ and the DecisionMaker.py to code.py.
- Switch to Right: "Magic 8 Ball" mode. Just press A for your answer (and HEAR it)
- Switch to Left: "Brain" mode
-
- A - press 1-5 times for scoring +'s on a factor
- B- press 1-5 times for scoring -'s on a factor
- Touch A1 to add a factor in
- Touch A2 to evaluate the factors (and hear the verdict)
- Touch A7 to replay the last verdict.
-
There you have it! Turn your CircuitPlayground into an advisor you can put in your pocket!
This page (Decison Maker!) was last updated on July 22, 2024.
Text editor powered by tinymce.