-
Notifications
You must be signed in to change notification settings - Fork 3
/
paper-rock-scissor-implementation2.py
51 lines (43 loc) · 1.08 KB
/
paper-rock-scissor-implementation2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from microbit import *
from radio import *
import random
on()
config(group=1, length=251)
result = {
'papir': {
'papir': 'DRAW',
'saks': 'LOSE',
'stein': 'WIN'
},
'saks': {
'papir': 'WIN',
'saks': 'DRAW',
'stein': 'LOSE'
},
'stein': {
'papir': 'LOSE',
'saks': 'WIN',
'stein': 'DRAW'
}
}
convert_to_string = ['papir', 'saks', 'stein']
display.scroll('shake')
while True:
shake = ''
if accelerometer.was_gesture("shake"):
shake = random.choice(convert_to_string)
display.scroll(shake)
sleep(5000)
# wait for result
data = None
send(shake)
while data is None:
data = receive()
sleep(500)
if data not in convert_to_string:
display.scroll("FAIL")
sleep(10000)
continue
display.scroll(result[shake][data])
sleep(5000)
display.clear()