diff options
-rw-r--r-- | master_thesis/elio_procedures.py | 24 | ||||
-rw-r--r-- | master_thesis/frensch_procedures.py | 34 | ||||
-rw-r--r-- | master_thesis/frensch_task.py | 18 |
3 files changed, 47 insertions, 29 deletions
diff --git a/master_thesis/elio_procedures.py b/master_thesis/elio_procedures.py deleted file mode 100644 index cd4848e..0000000 --- a/master_thesis/elio_procedures.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 - - -class Procedure: - pass - - -class Variable: - def __init__(self, name: str, subscript: int = 0): - self.name = name - self.subscript = subscript - - - def __str__(self): - return f"{self.name}_{self.subscript}" - - def get_result(self, Variables: dict): - if not self.subscript: - return Variables[self.name] - else: - return Variables - -x = Variable("solid", 2) -print(x) diff --git a/master_thesis/frensch_procedures.py b/master_thesis/frensch_procedures.py index 88aa29d..66f1c8c 100644 --- a/master_thesis/frensch_procedures.py +++ b/master_thesis/frensch_procedures.py @@ -17,6 +17,33 @@ class WaterSample: self.lime = lime self.toxin = toxin + def procedure_dict(self): + procedures = { + "1": (self.index1, self.index1_str), + "2": (self.index2, self.index2_str), + "3": (self.index3, self.index3_str), + "4": (self.index4, self.index4_str), + "5": (self.index5, self.index5_str), + "6": (self.index6, self.index6_str), + "overall": (self.overall, self.overall_str), + } + return procedures + + def select_procedures(self): + procedures = [ + (self.index1, self.index1_str), + (self.index2, self.index2_str), + (self.index3, self.index3_str), + (self.index4, self.index4_str), + (self.index5, self.index5_str), + (self.index6, self.index6_str), + ] + random.shuffle(procedures) + training_procedures = procedures[:-1] + training_procedures.append((self.overall, self.overall_str)) + + return training_procedures, procedures[-1] + def index1(self): return (self.lime[3] - self.lime[1]) * self.solid @@ -47,6 +74,12 @@ class WaterSample: def index5_str(self): return "Greater of [(Toxin_3 - Toxin_2), Lime_3]" + def index6(self): + return min(self.algae, (self.lime[0] + self.toxin[0])) + + def index6_str(self): + return "Lesser of [Algae, (Lime_1 + Toxin_1)]" + def overall(self): return 100 - max( self.index1(), self.index2(), self.index3(), self.index4(), self.index5() @@ -75,4 +108,3 @@ def random_WaterSample(): toxin = tuple(random.randint(1, 9) for _ in range(4)) return WaterSample(solid, algae, lime, toxin) - diff --git a/master_thesis/frensch_task.py b/master_thesis/frensch_task.py index 309153f..fc4c0ea 100644 --- a/master_thesis/frensch_task.py +++ b/master_thesis/frensch_task.py @@ -4,6 +4,7 @@ from __future__ import annotations from psychopy import constants, core, event, gui, visual from collections import namedtuple import frensch_procedures +import random DisplayVariable = namedtuple("DisplayVariable", ["name", "values"]) @@ -71,7 +72,7 @@ def generate_procedure_display(procedure: DisplayProcedure): return stim_procedure -def run_trial(): +def run_trial(procedure_keys: list): water_sample = frensch_procedures.random_WaterSample() water_sample.print_all() @@ -83,7 +84,8 @@ def run_trial(): stims = generate_variable_display([solid, algae, lime, toxin], x_positions) - p1 = DisplayProcedure(water_sample.index5_str(), water_sample.index1()) + procedures = water_sample.procedure_dict() + p1 = DisplayProcedure(procedures[procedure_keys[0]][1](), procedures[procedure_keys[0]][0]()) p1 = generate_procedure_display(p1) stims.append(p1) @@ -111,9 +113,17 @@ def run_trial(): if "\n" in stim_answer_box.text: not_finished = False - event.waitKeys(keyList=["space"]) return answer -print(f"Answer: {run_trial()}") + +procedure_keys = ["1", "2", "3", "4", "5", "6", "overall"] +train_procedures = procedure_keys[:-1] +random.shuffle(train_procedures) +train_procedures = train_procedures[:-1] +train_procedures.append(procedure_keys[-1]) +print(train_procedures) + + +print(f"Answer: {run_trial(train_procedures)}") |