# Making roulette without predicting the location of the ball

Hi!
I’m trying to build a roulette wheel that participants can’t predict the position of ball.
I trying as this:

speed = 0.125

fps = 30

position = 0.0

# Noting whether the ball is decelerating

decelerate = False

# Draw a circle

ball = visual.Circle(win, edges=100, radius=0.02, fillColor=‘white’, lineColor=None, pos=[position,position])

# Draw a circle

color = ‘pink’, angularCycles=5, radialCycles = 0, opacity= 0.8, autoLog=False)

# Assign Numbers as Texts

text100 = visual.TextStim(win, text=‘100’, font=‘’, pos=(0.0, 0.3), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text200 = visual.TextStim(win, text=‘200’, font=‘’, pos=(0.2, 0.2), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text300 = visual.TextStim(win, text=‘300’, font=‘’, pos=(0.3, 0.1), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text400 = visual.TextStim(win, text=‘400’, font=‘’, pos=(0.3, -0.1), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text500 = visual.TextStim(win, text=‘500’, font=‘’, pos=(0.2, -0.2), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text600 = visual.TextStim(win, text=‘600’, font=‘’, pos=(0.0, -0.3), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text700 = visual.TextStim(win, text=‘700’, font=‘’, pos=(-0.2, -0.2), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text800 = visual.TextStim(win, text=‘800’, font=‘’, pos=(-0.3,-0.1), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text900 = visual.TextStim(win, text=‘900’, font=‘’, pos=(-0.3, 0.1), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

text1000 = visual.TextStim(win, text=‘1000’, font=‘’, pos=(-0.18, 0.2), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘LTR’, autoLog=None, autoDraw=False)

# Show the amount of property

text_prop = visual.TextStim(win, text=calculator, font=‘’, pos=(0.6, 0.3), height=0.035, wrapWidth=None, color=‘black’,
ori=0.0, bold=False, italic=False, alignText=‘center’, languageStyle=‘Arabic’, autoLog=None, autoDraw=False)
#if calculator == 0:

#else:

# text_prop.setText(calculator)

polygon_2 = visual.Rect(
win=win, name=‘polygon_2’,
width=(0.25, 0.05), height=(0.25, 0.05),
ori=0.0, pos=(0.6, 0.3), anchor=‘center’,
lineWidth=2.0, colorSpace=‘rgb’, lineColor=‘white’, fillColor=None,
opacity=None, depth=-4.0, interpolate=True)

# While speed is greater than 0:

while speed > 0:

``````# Change the position of the ball according to the current value of position
ball.pos = [((math.sin(position)/10) * (wheel_radius * 10)),

# Produce the visualization of the wheel
wheel.draw()

# Produce the visualization of the ball
ball.draw()

# Produce the visualization of texts
text100.draw()
text200.draw()
text300.draw()
text400.draw()
text500.draw()
text600.draw()
text700.draw()
text800.draw()
text900.draw()
text1000.draw()
text_prop.draw()

polygon_2.draw()

# If the participant hasn't asked to stop the spinner yet
if decelerate == False:

# Continue spinning the ball around the wheel according to the specified speed
position += speed

# If the participant has asked to stop the spinner
if decelerate == True:

# Randomly select a value between 0.005 and 0.035
rand_dec = random.uniform(0.005,0.035)

# Reduce speed to be a percentage (99.5% - 96.5%) of its last value
# Randomizing the the value of the deceleration will hopefully prevent
# participants from being able to predict where the ball will stop. Also
# making speed a fraction or what it once was, rather than using a linear value
# will better model friction and exponential decay in the real world
speed *= 1 - rand_dec

# Continue spinning the ball around the wheel according to the new speed
position += speed

# If speed drops below 0.001
if speed < 0.001:
# Round speed down to 0
speed = 0

ball_x = round(ball.pos, 2)
ball_y = round(ball.pos, 2)

if -0.14 <= ball_x <= 0.14:
if 0.43 <= ball_y <= 0.45:
new_benefit = 100

elif -0.45 <= ball_y <= -0.43:
new_benefit = 600

elif 0.14 < ball_x <= 0.36:
if 0.26 <= ball_y < 0.43:
new_benefit = 200

elif -0.43 < ball_y <= -0.26:
new_benefit = 500

elif 0.36 < ball_x <= 0.45:
if 0 <= ball_y < 0.26:
new_benefit = 300

elif -0.26 < ball_y < 0:
new_benefit = 400

elif -0.36 <= ball_x < -0.14:
if 0.26 <= ball_y < 0.43:
new_benefit = 1000
#if new_benefit == 1000:
#  continueRoutine = False

elif -0.43 < ball_y <= -0.26:
new_benefit = 700

elif -0.45 <= ball_x < -0.36:
if -0.26 < ball_y < 0:
new_benefit = 800

elif 0 <= ball_y < 0.26:
new_benefit = 900

core.wait(0.5)
calculator = property_calculator(calculator, calculator, new_benefit, 0, calculator, calculator)
if calculator == 1000:
continueRoutine = False # end the current routine
trials2.finished = True # exit the current loop (if your loop is called "trials
# If escape is pressed, end the task
if event.getKeys('escape'):
break

#If space is pressed, begin slowing the ball
if event.getKeys('space'):
decelerate = True

# Refresh the screen according to the core.wait rate allowing for objects and visualizations
# to change position
win.flip()

# How long psychopy should wait before updating the screen
core.wait(1/fps)
``````

Can anyone help me?