-
Notifications
You must be signed in to change notification settings - Fork 3
/
paper-rock-scissor-implementation1.py
57 lines (45 loc) · 1.2 KB
/
paper-rock-scissor-implementation1.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
52
53
54
55
56
57
from microbit import *
from radio import *
from random import*
#turn radio on and
on()
config(group=6, length=251)
typeTransmitted = randint(0,2)
# R – rock, S – scissors, P – paper
rps = [ "r", "s", "p" ]
shaken = False
# 0=stein, 1=saks, 2=papir
def win(me, he):
if(me == 0 and he == 1):
return True
elif(me == 0 and he == 2):
return False
elif(me == 1 and he == 0):
return False
elif(me == 1 and he == 2):
return True
elif(me == 2 and he == 0):
return True
elif(me == 2 and he == 1):
return False
else:
return False
while True:
if button_a.was_pressed() and shaken:
shaken = False
send(str(typeTransmitted))
if accelerometer.was_gesture("shake"):
#send the images
shaken = True
typeTransmitted = randint(0,2)
display.scroll(rps[typeTransmitted])
display.clear()
#receive data
data = receive()
#check that we have received any data
if data != None:
display.scroll(str(win(typeTransmitted, int(data))))
#split the data into different pictures by the marker
#display.scroll(data)
#clear the screen
display.clear()