Compare commits
2 Commits
2801a3f4cd
...
07d9b659e3
Author | SHA1 | Date |
---|---|---|
randomuser | 07d9b659e3 | |
randomuser | d58ae87f8c |
|
@ -0,0 +1,11 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
let
|
||||
my-python-packages = ps: with ps; [
|
||||
prompt-toolkit
|
||||
pyautogui
|
||||
opencv4
|
||||
numpy
|
||||
# other python packages
|
||||
];
|
||||
my-python = pkgs.python3.withPackages my-python-packages;
|
||||
in my-python.env
|
|
@ -1,5 +1,6 @@
|
|||
from modules.wires import WiresModule
|
||||
from modules.button import ButtonModule
|
||||
from modules.simon import SimonModule
|
||||
from modules.comp_wires import ComplicatedWiresModule
|
||||
from modules.password import PasswordModule
|
||||
|
||||
|
@ -7,7 +8,7 @@ modules = {
|
|||
'wires': WiresModule,
|
||||
'button': ButtonModule,
|
||||
'keypad': None,
|
||||
'simon': None,
|
||||
'simon': SimonModule,
|
||||
'first': None,
|
||||
'memory': None,
|
||||
'morse': None,
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
from prompt_toolkit import prompt
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
|
||||
class SimonModule:
|
||||
buttonmapping = {
|
||||
"vowel": {
|
||||
0: {
|
||||
"red": "blue",
|
||||
"blue": "red",
|
||||
"green": "yellow",
|
||||
"yellow": "green",
|
||||
},
|
||||
1: {
|
||||
"red": "yellow",
|
||||
"blue": "green",
|
||||
"green": "blue",
|
||||
"yellow": "red",
|
||||
},
|
||||
2: {
|
||||
"red": "green",
|
||||
"blue": "red",
|
||||
"green": "yellow",
|
||||
"yellow": "blue",
|
||||
},
|
||||
},
|
||||
"novowel": {
|
||||
0: {
|
||||
"red": "blue",
|
||||
"blue": "yellow",
|
||||
"green": "green",
|
||||
"yellow": "red",
|
||||
},
|
||||
1: {
|
||||
"red": "red",
|
||||
"blue": "blue",
|
||||
"green": "yellow",
|
||||
"yellow": "green",
|
||||
},
|
||||
2: {
|
||||
"red": "yellow",
|
||||
"blue": "green",
|
||||
"green": "blue",
|
||||
"yellow": "red",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
def __init__(self, strikes, isvowel):
|
||||
self.strikes = strikes
|
||||
self.isvowel = isvowel
|
||||
self.isvowel = "vowel" if isvowel else "novowel"
|
||||
|
||||
def convert(self, color):
|
||||
return self.buttonmapping[self.isvowel][self.strikes][color]
|
||||
|
||||
@classmethod
|
||||
def interactive(cls, state, cmdline):
|
||||
try:
|
||||
obj = cls(state.strikes, state.serial.vowel)
|
||||
except AttributeError:
|
||||
print("you need to specify a serial number before running this.")
|
||||
return
|
||||
|
||||
while True:
|
||||
print("enter information")
|
||||
user_in = prompt("simon> ")
|
||||
if user_in == "strike":
|
||||
state.strikes += 1
|
||||
obj.strikes += 1
|
||||
elif user_in == "quit":
|
||||
break
|
||||
else:
|
||||
for i in user_in.split(" "):
|
||||
print(obj.convert(i))
|
Loading…
Reference in New Issue