FittsLaw/utils/sampleGen.py

38 lines
1.0 KiB
Python
Raw Normal View History

2020-05-15 14:06:34 -04:00
import json
from random import choice,shuffle
direction = ["Up","Left","Right"]
distance = ["Short","Medium","Long"]
devices = ["cardboard","mouse","oculus"]
options = []
for x in direction:
for y in distance:
options.append(x+y)
print(options)
numDots = int(input("Number of Dots per Trial: "))
numTrials = int(input("Number of Trials: "))
totalNum = numDots * numTrials
mod = totalNum % len(options)
dots = []
if mod is 0:
c = totalNum//len(options)
for option in options:
dots = dots + ([option] * c)
print(dots.count(option))
shuffle(dots)
print(dots)
trials = []
for x in range(numTrials):
trial = []
for y in range(numDots):
trial.append(dots.pop())
trials.append(trial)
root = {}
for d in devices:
root['trials'] = trials
root['inputMethod'] = d
root['participantId'] = 0
with open(d+'Trials.json','w') as f:
json.dump(root,f,indent=4)
else:
print("Please enter evenly divisible numbers")