-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnback.py
80 lines (69 loc) · 2.65 KB
/
nback.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
# -----------------------------------------------------------------------------------------
# The idea of the game is to test out the concept of turning the n-back scheme [1] into a
# point based game. It is usually pretty boring (because it is difficult) but by including
# a scoring system and the ability to earn points for any number of n-back means that it
# becomes accessible.
#
# It might also be possible to put it online and gather enough data to write a scientific
# article on it.
#
# [1] http://en.wikipedia.org/wiki/N-back
# -----------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------
# Code structure:
# Read an input file that determines the variables of the game
# Loop present_stimuli times:
# Randomly generate the stimuli and keep a record of it (up to 10-back?)
# Present the stimuli
# Ask for a response 0 (not seen before), 1 (1-back), 2 (2-back), etc...
# Change the score based upon response and record response
# If you have enough lives left you can do it again (You lose a life for every mistake you make)
# Give the final score and a breakdown of the responses
#
#
# -----------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------
# INPUTS TYPE DESCRIPTION
#
# verbose int Use 0 for low verbosity or 1 for high verbosity
#
# present_stimuli int The number of stimuli to be presented to the user.
#
# type_stimulus str The type of stimuli to be presented to the user (currently the
# only working option is 'letters').
#
# num_stimuli int The maximum number of stimuli that will be used.
#
# max_nback int The maximum nback to be stored and scored.
#
#
# -----------------------------------------------------------------------------------------
import json
import os
from nback_game import *
spec = {
"verbose":1,
"num_high_scores": 10,
"highscorefile":"highscores.txt",
"max_nback": 5,
"type_stimulus": "random",
"present_stimuli": 10,
"num_stimuli": 5,
"max_name_length":10,
"max_score":1000000,
"num_lives":3,
"gamename":"NBACK",
"max_level":5
}
# Read input file
inputfile='game_spec.txt'
with open(inputfile,'r') as f:
spec = json.load(f)
want_to_play = 0
# level always starts at 1
level=1
while want_to_play==0:
# Play game
os.system("clear")
want_to_play = nback_game(level,spec)