diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 51d561a..1b2be68 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,617 +2,21 @@ - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + @@ -732,7 +139,22 @@ + + + @@ -803,7 +229,7 @@ - + \ No newline at end of file diff --git a/Flask/.idea/.gitignore b/Flask/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/Flask/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/Flask/.idea/Flask.iml b/Flask/.idea/Flask.iml deleted file mode 100644 index d0876a7..0000000 --- a/Flask/.idea/Flask.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/IDManager.py b/IDManager.py index 8594f1e..8d7d543 100644 --- a/IDManager.py +++ b/IDManager.py @@ -6,7 +6,7 @@ class idManager(): levelNum = 200 typeNum = 100 - timeMin = 1 + timeMin = 0 tutorialMax = 3 ip_dic = {} ip_recent = {} @@ -18,6 +18,7 @@ class idManager(): def __int__(self): self.levelNum = 200 self.typeNum = 100 + self.timeMin = 0 def getLevels(self, ip): if ip not in self.ip_dic.keys(): @@ -85,14 +86,14 @@ class idManager(): self.ip_time[ip] = 0 def getTimes(self, ip): - print(self.ip_time[ip]) + if ip not in self.ip_time.keys(): - return 0 + self.ip_time[ip] = 0 + + if self.ip_time[ip] >= self.timeMin: + return 1 else: - if self.ip_time[ip] >= self.timeMin: - return 1 - else: - return 0 + return 0 def addTimes(self, ip): if ip not in self.ip_time.keys(): diff --git a/__pycache__/IDManager.cpython-39.pyc b/__pycache__/IDManager.cpython-39.pyc index f776f45..75fde18 100644 Binary files a/__pycache__/IDManager.cpython-39.pyc and b/__pycache__/IDManager.cpython-39.pyc differ diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc index b2fc011..3757539 100644 Binary files a/__pycache__/main.cpython-39.pyc and b/__pycache__/main.cpython-39.pyc differ diff --git a/data/annotation.csv b/data/annotation.csv index 36809cb..3fef98b 100644 --- a/data/annotation.csv +++ b/data/annotation.csv @@ -4,3 +4,18 @@ IP,A-ID,B-ID,Anno, 127.0.0.1,193,112,E, 127.0.0.1,153,200,B, 127.0.0.1,187,192,N, +10.27.169.251,12,169,N, +10.27.169.251,85,63,B, +10.27.169.251,131,179,E, +10.27.169.251,2,59,E, +10.27.169.251,163,78,E, +10.27.169.251,77,174,E, +10.27.169.251,186,108,A, +10.27.169.251,122,155,E, +10.27.169.251,32,148,A, +127.0.0.1,166,46,N, +127.0.0.1,54,167,N, +127.0.0.1,26,49,B, +127.0.0.1,38,154,N, +127.0.0.1,168,74,B, +127.0.0.1,82,101,N, diff --git a/data/questionare.csv b/data/questionare.csv index 0f0c707..fa07f69 100644 --- a/data/questionare.csv +++ b/data/questionare.csv @@ -115,3 +115,39 @@ IP,Style,Frequency,Age,Gender 10.27.169.251,,,,,, 10.27.169.251,,,,,, 10.27.169.251,,,,,, +10.27.169.251,A,D,B,A,, +10.27.169.251,A,D,B,A,, +10.27.169.251,A,E,B,A,, +10.27.169.251,,,,,, +10.27.169.251,,,,,, +10.27.169.251,,,,,, +10.27.169.251,A,D,B,A,, +10.27.169.251,A,D,B,A,, +10.27.169.251,,,,,, +10.27.169.251,D,,,,, +10.27.169.251,,,,,, +10.27.169.251,,,,,, +10.27.169.251,A,A,A,A,, +10.27.169.251,A,A,,,,,, +10.27.169.251,A,B,A,D,D,B,, +10.27.169.251,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +127.0.0.1,,,,,,,, +10.27.169.251,,,,,,,, +10.27.169.251,A,A,C,B,B,A,, +127.0.0.1,A,A,A,E,A,A,, +127.0.0.1,A,A,A,B,B,A,, +127.0.0.1,A,A,A,A,C,A,, +127.0.0.1,C,A,A,E,B,A,, +127.0.0.1,C,A,C,D,F,A,, +127.0.0.1,A,A,D,A,C,A,, +127.0.0.1,B,A,C,A,A,A,, +127.0.0.1,C,A,B,E,B,A,, +127.0.0.1,A,A,A,E,E,A,, diff --git a/img/welcome.png b/img/welcome.png new file mode 100644 index 0000000..2717ffd Binary files /dev/null and b/img/welcome.png differ diff --git a/main.py b/main.py index 1576462..296060f 100644 --- a/main.py +++ b/main.py @@ -14,9 +14,14 @@ evalDataPath = "evals/" questionarePath = "data/questionare.csv" annotationPath = "data/annotation.csv" +annotationPath2 = "data/annotation2.csv" @app.route('/') +def gamewelcome(): + return render_template('GameWelcome.html') + +@app.route('/question') def gamequestion(): return render_template('GameQuestion.html') @@ -28,18 +33,18 @@ def gamepreplay(): ip = request.remote_addr # Save the result to questionare idm.write_csv(questionarePath, - [ip, result.get("gamestyle"), result.get("frequency"), result.get("age"), result.get("gender"), + [ip,result.get("playeds"),result.get("playedp"), result.get("gamestyle"), result.get("frequency"), result.get("age"), result.get("gender"), ""]) idm.setControl(ip, result.get("control")) print(result.get("gamestyle")) - # return redirect(url_for('gametutorial', id=ip)) + return redirect(url_for('gametutorial', id=ip)) # debug use: - return redirect(url_for('gameanno2', id=ip)) + #return redirect(url_for('gameplay2', id=ip)) @app.route('/gametutorial/') def gametutorial(id): - return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id)) + return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),control=idm.getControl(id)) @app.route('/again') @@ -79,6 +84,7 @@ def gameanno(id): if (id != "radioresult"): print("anno " + id) gamelevels = idm.getRecent(id) + level1 = "lvl" + str(gamelevels[0]) level2 = "lvl" + str(gamelevels[1]) return render_template('GameAnnotation.html', level1=level1, level2=level2) @@ -94,15 +100,14 @@ def getRadioData(): print(result) ipRecent = idm.getRecent(ip) idm.write_csv(annotationPath, [ip, ipRecent[0], ipRecent[1], result["fun"]]) - idm.addTimes(ip) - finish = idm.getTimes(ip) - - return render_template("GameOver.html", finish=finish, stage=2) -@app.route("/gameover/") -def over(stage): - return render_template("GameOver.html", finish=1, stage=stage) + return redirect(url_for('over', stage=1)) + + +@app.route('/gameplay2') +def gamepreplay2(): + return redirect(url_for('gameplay2', id=request.remote_addr)) @app.route('/gameplay2/') @@ -124,15 +129,15 @@ def getJSONData2(id): @app.route('/annotation2') def gamepreanno2(): - return redirect(url_for('gameanno', id=request.remote_addr)) + return redirect(url_for('gameanno2', id=request.remote_addr)) @app.route('/annotation2/') def gameanno2(id): if id != "result": print("anno " + id) - # gamelevels = idm.getRecent(id) - gamelevels = idm.getTypeLevels(id) + gamelevels = idm.getRecent(id) + # gamelevels = idm.getTypeLevels(id) level1 = gamelevels[0] level2 = gamelevels[1] level3 = gamelevels[2] @@ -146,9 +151,24 @@ def gameannoresult2(id): if request.method == 'POST': print("result! " + id) resultList = list(request.form)[0].split(",") + levelList = idm.getRecent(request.remote_addr) print(resultList) - return redirect(url_for('over',stage=2)) + idm.write_csv(annotationPath2, + [request.remote_addr, resultList[0], resultList[1], resultList[2], levelList[0], levelList[1], levelList[2], + ""]) + return redirect(url_for('over', stage=2)) + + +@app.route("/gameover/") +def over(stage): + finish = idm.getTimes(request.remote_addr) + print("finish %d",finish) + if finish: + idm.setTimes(request.remote_addr) + else: + idm.addTimes(request.remote_addr) + return render_template("GameOver.html", finish=finish, stage=stage) def saveFile(path, filename, content): diff --git a/templates/GameAnnotation.html b/templates/GameAnnotation.html index 8980bac..7ef1b8f 100644 --- a/templates/GameAnnotation.html +++ b/templates/GameAnnotation.html @@ -236,16 +236,16 @@ function Replay(id){
- +{# #}
-

Level A Review

+

Level A

Drag Picture To Move

@@ -258,7 +258,7 @@ function Replay(id){
-

Level B Review

+

Level B

Drag Picture To Move

@@ -272,13 +272,35 @@ function Replay(id){
+ + + +

- Annotation Questions + Which level was more fun to play?


-
+
diff --git a/templates/GameAnnotation2.html b/templates/GameAnnotation2.html index 29619c8..573a01a 100644 --- a/templates/GameAnnotation2.html +++ b/templates/GameAnnotation2.html @@ -198,7 +198,7 @@ function Replay(id){
-

Collector Review

+

Level A

Drag Picture To Move

@@ -211,7 +211,7 @@ function Replay(id){
-

Killer Review

+

Level B

Drag Picture To Move

@@ -224,7 +224,7 @@ function Replay(id){
-

Runner Review

+

Level C

Drag Picture To Move

@@ -247,15 +247,15 @@ function Replay(id){
- Collector Level + Level A
- Killer Level + Level B
- Runner Level + Level C
diff --git a/templates/GameOver.html b/templates/GameOver.html index 29e6613..a6e3285 100644 --- a/templates/GameOver.html +++ b/templates/GameOver.html @@ -143,11 +143,18 @@ @@ -158,13 +165,23 @@ Thank You!!!
- + diff --git a/templates/GamePlay.html b/templates/GamePlay.html index fb3d8eb..ed75cc3 100644 --- a/templates/GamePlay.html +++ b/templates/GamePlay.html @@ -98,11 +98,11 @@
- +{# #}
@@ -110,7 +110,7 @@
-

Mario Game User Test

+
@@ -120,8 +120,10 @@ //Init Cheerpj Framework cheerpjInit(); var divElement = document.getElementById("GameWindow"); + var title = document.getElementById("Head"); var levelNum = Number("{{levelNum}}") var levels = getLevels("{{gamelevels}}",levelNum); + var levelNames = ["Level A","Level B","Level C","Level D"]; cheerpjCreateDisplay(500,500,divElement); cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l"); @@ -132,10 +134,13 @@ for (i = 0; i < levelNum-1; i++) { console.log("Play level: %s",levels[i]) PlayLevel(levels[i],control) - .then(function (){alert("Game Over!")}); + .then(function (){alert("Game Over!")}) + .then(function (){ + console.log(i) + var index = levelNames.indexOf(title.innerText); + title.innerText = levelNames[index+1];}); } - console.log("Play level: %s",levels[levelNum-1]) PlayLevel(levels[levelNum-1],control) .then(function (){ alert("Go to Evaluation Window") @@ -144,6 +149,10 @@ + + + +

diff --git a/templates/GameQuestion.html b/templates/GameQuestion.html index 1f5704c..f420ec5 100644 --- a/templates/GameQuestion.html +++ b/templates/GameQuestion.html @@ -191,18 +191,70 @@
+

- Questionare + Questionnaire


- -

Which do you prefer in Super Mario Bros?

+ + +

Have you played Super Mario Bros before?

+ + + +

+ +

Do you played platform games like Super Mario Bros?

+ + + +

+ +

What is your prefered acion in Super Mario Bros?

-W +

How frequently do you play game?

-

Your age?

+

What is your age?

-

Your gender?

+

What is your gender?

-

You would like to play in?

+

How would you like to play?

diff --git a/templates/GameTutorial.html b/templates/GameTutorial.html index c6c630e..27364de 100644 --- a/templates/GameTutorial.html +++ b/templates/GameTutorial.html @@ -117,23 +117,24 @@
- +{# #}
-

Mario Game Tutorial

+

Super Mario Bros Tutorial

- Further description of Tutorial can be done here
- Use the way of Play That you selected + Before proceeding to the main part of the experiment please familiarize yourself with the game.
+ You may proceed to the next phase of this survey once you are ready! +

@@ -147,13 +148,13 @@
+ ">

Repeat Tutorial

+ + + + + + + + AI and Games + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+

+

Purpose Of the Experiment

+

+ The Experiment is designed for participants to annotate the performance of the Super Mario Bros' levels that generated by computer. +

+
+

Procedure Of the Experiment

+

+ + The Experiment is consist of two Phase, which you need to do them two times in an experiment.
+ Each Phase contains several Super Mario Bros levels to play and a annotation page to evaluate those levels you just played.
+ Enjoy your Time! +

+ +

+ + +
+ + +
+
+ + +
+ + + + + + + +
+
+
+ +
+

+

Copyright © Jialin Liu

+ +
+ +
+
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/data.js b/templates/data.js index b0b9340..970b91a 100644 --- a/templates/data.js +++ b/templates/data.js @@ -30,6 +30,7 @@ function PostToServer(url,data) { } } function PlayLevel(level,control){ + var returnVal = cjCall("Play", "playGameMain", level, 5, control); return returnVal.then(function(){ console.log("the return val is ready");