summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-08-27 13:16:20 +0200
committerNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-08-27 13:16:20 +0200
commitd34a6ab6a2c8e386b4687c5d8e9326fc5d45be81 (patch)
tree7ba01885c575c81c5572b7e1e450732de07e80d9
parent8601458648311902aec5a3bb079066e39027e51f (diff)
add 7th proc, constrained sampling
-rw-r--r--master_thesis/frensch_procedures.py23
-rw-r--r--master_thesis/frensch_task.py32
2 files changed, 38 insertions, 17 deletions
diff --git a/master_thesis/frensch_procedures.py b/master_thesis/frensch_procedures.py
index 66f1c8c..42c6f14 100644
--- a/master_thesis/frensch_procedures.py
+++ b/master_thesis/frensch_procedures.py
@@ -98,9 +98,32 @@ class WaterSample:
print(f"Index 3: {self.index3_str()} = {self.index3()}")
print(f"Index 4: {self.index4_str()} = {self.index4()}")
print(f"Index 5: {self.index5_str()} = {self.index5()}")
+ print(f"Index 6: {self.index6_str()} = {self.index6()}")
print(f"Overall Quality: {self.overall_str()} = {self.overall()}")
+# No step should produce a negative number, greater/lesser of comparisons should not
+# use equal numbers
+def constrained_WaterSample():
+ water_sample = random_WaterSample()
+ resample = True
+ while resample:
+ water_sample = random_WaterSample()
+ resample = False
+ # check for negative results
+ for proc in water_sample.procedure_dict().keys():
+ if water_sample.procedure_dict()[proc][0]() < 0:
+ resample = True
+ # check for greater/lesser equality
+ # procedure 5
+ if (water_sample.toxin[2] - water_sample.toxin[1]) == water_sample.lime[2]:
+ resample = True
+ # procedure 6
+ if (water_sample.lime[0] + water_sample.toxin[0]) == water_sample.algae:
+ resample = True
+ return water_sample
+
+
def random_WaterSample():
solid = random.randint(1, 9)
algae = random.randint(1, 9)
diff --git a/master_thesis/frensch_task.py b/master_thesis/frensch_task.py
index 65f950d..ad67ee5 100644
--- a/master_thesis/frensch_task.py
+++ b/master_thesis/frensch_task.py
@@ -18,6 +18,10 @@ def experiment_shutdown():
WIN = visual.Window((2560, 1440), fullscr=True, units="pix")
MONITOR_FPS = 60
+TRAIN_TRIALS = 1 # 75
+TEST_TRIALS = 1 # 50
+ORDER_CONDITIONS = ["fixed", "random", "blocked"]
+PROCEDURE_KEYS = ["1", "2", "3", "4", "5", "6", "overall"]
# Cancel experiment anytime with Esc
event.globalKeys.add(key="escape", func=experiment_shutdown, name="shutdown")
@@ -71,16 +75,9 @@ def generate_procedure_display(procedure: DisplayProcedure, position):
)
return stim_procedure
-def watersample_all_positive(water_sample):
- for proc in procedure_keys:
- if water_sample.procedure_dict()[proc][0]() < 0:
- return False
- return True
def run_trial(procedure_keys: list, condition):
- water_sample = frensch_procedures.random_WaterSample()
- while not watersample_all_positive(water_sample):
- water_sample = frensch_procedures.random_WaterSample()
+ water_sample = frensch_procedures.constrained_WaterSample()
water_sample.print_all()
if condition == "random":
@@ -124,6 +121,7 @@ def run_trial(procedure_keys: list, condition):
not_finished = True
answer = "not answered"
+ start_time = core.monotonicClock.getTime()
while not_finished:
stim_answer_box.hasFocus = True
for stim in stims:
@@ -137,32 +135,32 @@ def run_trial(procedure_keys: list, condition):
# answer = ""
if "\n" in stim_answer_box.text:
not_finished = False
+ answer_time = core.monotonicClock.getTime() - start_time
+ print(f"time to answer: {answer_time}")
answers.append(answer.replace("\n", ""))
event.waitKeys(keyList=["space"])
return answers
+
intro = visual.TextBox2(WIN, "Introduction")
intro.draw()
WIN.flip()
event.waitKeys(keyList=["space"])
-order_conditions = ["fixed", "random", "blocked"]
-
-procedure_keys = ["1", "2", "3", "4", "5", "6", "overall"]
-train_procedures = procedure_keys[:-1]
+train_procedures = PROCEDURE_KEYS[:-1]
random.shuffle(train_procedures)
transfer_procedure = train_procedures[-1]
train_procedures = train_procedures[:-1]
-train_procedures.append(procedure_keys[-1])
+train_procedures.append(PROCEDURE_KEYS[-1])
print(train_procedures)
-for _ in range(1):
- print(f"Answer: {run_trial(train_procedures, order_conditions[0])}")
+for _ in range(TRAIN_TRIALS):
+ print(f"Answer: {run_trial(train_procedures, ORDER_CONDITIONS[0])}")
train_procedures[2] = transfer_procedure
print(train_procedures)
-for _ in range(1):
- print(f"Answer: {run_trial(train_procedures, order_conditions[0])}")
+for _ in range(TEST_TRIALS):
+ print(f"Answer: {run_trial(train_procedures, ORDER_CONDITIONS[0])}")