summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDobbertin, Niclas <niclas.dobbertin@gmx.de>2023-08-18 11:09:48 +0200
committerDobbertin, Niclas <niclas.dobbertin@gmx.de>2023-08-18 11:09:48 +0200
commit8601458648311902aec5a3bb079066e39027e51f (patch)
tree3a201dd15aa5467d350920920ce919c285309508
parent11bab9715e6f68c3d90b4ba04a3b2e54f43c06a3 (diff)
update
-rw-r--r--master_thesis/frensch_task.py101
1 files changed, 70 insertions, 31 deletions
diff --git a/master_thesis/frensch_task.py b/master_thesis/frensch_task.py
index fc4c0ea..65f950d 100644
--- a/master_thesis/frensch_task.py
+++ b/master_thesis/frensch_task.py
@@ -60,10 +60,10 @@ def generate_variable_display(varx: list[DisplayVariable], x_positions: list[int
return stims
-def generate_procedure_display(procedure: DisplayProcedure):
+def generate_procedure_display(procedure: DisplayProcedure, position):
stim_procedure = visual.TextBox2(
WIN,
- pos=[-800, -100],
+ pos=position,
text=procedure.procedure,
# size=[1000, 1000],
letterHeight=50,
@@ -71,11 +71,21 @@ def generate_procedure_display(procedure: DisplayProcedure):
)
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):
+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.print_all()
+ if condition == "random":
+ random.shuffle(procedure_keys)
+
solid = DisplayVariable("SOLID", [water_sample.solid])
algae = DisplayVariable("ALGAE", [water_sample.algae])
lime = DisplayVariable("LIME", water_sample.lime)
@@ -85,45 +95,74 @@ def run_trial(procedure_keys: list):
stims = generate_variable_display([solid, algae, lime, toxin], x_positions)
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)
- stim_answer_box = visual.TextBox2(
- WIN,
- "",
- letterHeight=50,
- pos=(0, -100),
- size=[150, 70],
- editable=True,
- fillColor="white",
- color="black",
- alignment="center",
- )
- stims.append(stim_answer_box)
-
- not_finished = True
- answer = "not answered"
- while not_finished:
- stim_answer_box.hasFocus = True
- for stim in stims:
- stim.draw()
- WIN.flip()
- answer = stim_answer_box.text
- if "\n" in stim_answer_box.text:
- not_finished = False
+ answers = []
+ proc_x = -800
+ proc_y = -100
+ answ_x = 0
+ answ_y = -100
+ y_offset = 80
+ for proc in procedure_keys:
+ p = DisplayProcedure(procedures[proc][1](), procedures[proc][0]())
+ p = generate_procedure_display(p, (proc_x, proc_y))
+ stims.append(p)
+ proc_y -= y_offset
+
+ stim_answer_box = visual.TextBox2(
+ WIN,
+ "",
+ letterHeight=50,
+ pos=(answ_x, answ_y),
+ size=[150, 70],
+ editable=True,
+ fillColor="white",
+ color="black",
+ alignment="center",
+ )
+ stims.append(stim_answer_box)
+ answ_y -= y_offset
+
+ not_finished = True
+ answer = "not answered"
+ while not_finished:
+ stim_answer_box.hasFocus = True
+ for stim in stims:
+ stim.draw()
+ WIN.flip()
+ answer = stim_answer_box.text
+ # TODO: prevent nondigits
+ # answer.replace("\n", "")
+ # if not answer.isdigit():
+ # stim_answer_box.text = ""
+ # answer = ""
+ if "\n" in stim_answer_box.text:
+ not_finished = False
+ answers.append(answer.replace("\n", ""))
event.waitKeys(keyList=["space"])
- return answer
+ 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]
random.shuffle(train_procedures)
+transfer_procedure = train_procedures[-1]
train_procedures = train_procedures[:-1]
train_procedures.append(procedure_keys[-1])
print(train_procedures)
-print(f"Answer: {run_trial(train_procedures)}")
+for _ in range(1):
+ 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])}")