updated utils and added README

This commit is contained in:
Chris Midkiff
2020-05-15 14:19:14 -04:00
parent 7ccb087ecd
commit 0356e58416
3 changed files with 26 additions and 9 deletions

38
utils/trialGen.py Normal file
View File

@@ -0,0 +1,38 @@
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")