This will turn the scene's visibility on and off based on a timer and reset the objects randomly in one of nine specified positions when the scene comes back
check out the Vizard docs to learn how to write to files so you can record user responses.
Code:
import viz
viz.go()
viz.MainView.move(0,0,-10)
#keep nine positions in an array
pos = [[-4,0,0],[-3,0,0],[-2,0,0],[-1,0,0],[0,0,0],[1,0,0],[2,0,0],[3,0,0],[4,0,0]]
box = viz.add('box.wrl')
ball = viz.add('ball.wrl')
whiteball = viz.add('white_ball.wrl')
import random
def sceneOn():
#set objects to 3 different random positions
rand_numbers = [0,1,2,3,4,5,6,7,8]
random.shuffle(rand_numbers)
box.setPosition(pos[rand_numbers[0]])
ball.setPosition(pos[rand_numbers[1]])
whiteball.setPosition(pos[rand_numbers[2]])
viz.MainScene.visible(viz.ON)
vizact.ontimer2(2,0,sceneOff)
def sceneOff():
viz.MainScene.visible(viz.OFF)
vizact.ontimer2(2,0,sceneOn)
sceneOn()