Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Ziqi Wang 2023-03-30 09:54:08 +08:00
commit b89f682bf2
14 changed files with 98 additions and 73 deletions

3
.gitignore vendored
View File

@ -34,4 +34,5 @@ replay_pid*
__pycache__/IDManager.cpython-39.pyc __pycache__/IDManager.cpython-39.pyc
*.pyc *.pyc
*.pyc *.pyc
questionare.csv questionare.csv
log.txt

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -2,15 +2,15 @@
---------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------SSSS-SSS-----------------------SSSSSSSSSSSSSSSSSS----------------SSSSSSSSSSSSSSSS----------------S--SSSSSS------- -----------------------------------------------SSSS-SSS-----------------------SSSSSSSSSSSSSSSSSS----------------SSSSSSSSSSSSSSSS----------------S--SSSSSS-------
----------o-----t-------------------------------------------------------------------SSSS--S----------------------SSSSSSSSSSSSSSS-------------------------------- ----------o-----t-----------------S-------------------------------------------------SSSS--S----------------------SSSSSSSSSSSSSSS--------------------------------
%--------S------t--------------------------------------------------------------------SS--SSS--------------------SSSSSSSSSSSSSSS--------------------------------- %--------S------t--------------------------------------------------------------------SS--SSS--------------------SSSSSSSSSSSSSSS---------------------------------
|------------------------------o----------SSSSSS--------------------Q--------------S------SS-------------------o------S----KSSS---------------@%--S------------- |------------------------------o----------SSSSSS--------------------Q--------------S------SS-------------------o------S----KSSS---------------@%--S-------------
|-----------------------------------------SSSSS------oo----------------------------------------------%---------------------SS------------------|---------------- |---------------------------------S-------SSSSS------oo----------------------------------------------%---------------------SS------------------|----------------
|--------------------------------------SSSSSSSS-%----%%%%%-%%--------------------------SS------------|-----------------------------------------|-----#---------- |--------------------------------------SSSSSSSS-%----%%%%%-%%--------------------------SS------------|-----------------------------------------|-----#----------
|--------o------------------------S--SS--SSSSS--|-----|||--||--------------------------r-------S-----|------------SSo-ooo---oSSS---------------|----##---------- |--------o------------------------S--SS--SSSSS--|-----|||--||--------------------------r-------S-----|------------SSo-ooo---oSSS---------------|----##----------
|------------------------------S----SSSSSSSSSSS-|-----|||--||-------------------%%%%%%%%%%------QQQ--|-QQ----------SSS%--%%%%%%%---#-----------|---####--##-##-# |------------------------------S----SSSSSSSSSSS-|-----|||--||-------------------%%%%%%%%%%------QQQ--|-QQ----------SSS%--%%%%%%%---#-----------|---####--##-----
|------------------------------t--------S-------|-T---|||--||----------------#---||||||||----#-------|----------------|---|||||----#-----------|--#####--##----# |------------------------------t--------S-------|-T---|||--||----------------#---||||||||----#-------|----------------|---|||||----#-----------|--#####--##-----
|--------------------------tt--t-------SSS%%-SS-|-TT--|||--||----------------#--S|||||||S----#-------tt---------S-----|--S||||S----#-----------|-######--##----# |--------------------------tt--t-------SSS%%-SS-|-TT--|||--||----------------#--S|||||||S----#-------tt---------S-----|--S||||S----#-----------|-######--##-----
|--------k-------g---------tt-kt----------||----|-TT--|||--||----kkg-------###---|||||||---------g---tt------ggg------|---||||-----#-#---------|#######--##----# |--------k-------g---------tt-kt----------||----|-TT--|||--||----kkg-------###---|||||||---------g---tt------ggg------|---||||-----#-#---------|#######--##-----
XX-------XXXXXXXXXXXXXXXXXXXXXXXS--%------%%----|XXXX-|||--||---XXXXXXXXXXXXXXXX%|%%%%%%%-------XXXXXXXXXXXXXXXX-%%%%%%%%%%%||--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X XX-------XXXXXXXXXXXXXXXXXXXXXXXS--%------%%----|XXXX-|||--||---XXXXXXXXXXXXXXXX%|%%%%%%%-------XXXXXXXXXXXXXXXX-%%%%%%%%%%%||--XXXXXXXXXXXXXXXXXXXXXXXXXXXX----
XX-------XXXXXXXXXXXXXXXXXXXXXXX---|------||----|XXXX-|||--||---XXXXXXXXXXXXXXXXg|-|||||--------XXXXXXXXXXXXXXXXg-|||||||||-||--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X XX-------XXXXXXXXXXXXXXXXXXXXXXX---|------||----|XXXX-|||--||---XXXXXXXXXXXXXXXXg|-|||||--------XXXXXXXXXXXXXXXXg-|||||||||-||--XXXXXXXXXXXXXXXXXXXXXXXXXXXX----

Binary file not shown.

View File

@ -24,8 +24,7 @@ public class Play {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
//FIXME: Debug Use //FIXME: Debug Use
//playGameMain("lvl1"); // game = new MarioGame();
// initialGame();
// playJavaGame(); // playJavaGame();
System.out.println("Java: Play Java Main Function Done"); System.out.println("Java: Play Java Main Function Done");
} }

View File

@ -144,6 +144,7 @@ public class MarioGame extends KeyAdapter{
} }
private MarioResult gameLoop(String level, int timer, int marioState, boolean visual, int fps, String resultPath, int col) { private MarioResult gameLoop(String level, int timer, int marioState, boolean visual, int fps, String resultPath, int col) {
this.world = new MarioWorld(this.killEvents); this.world = new MarioWorld(this.killEvents);
this.world.visuals = visual; this.world.visuals = visual;
this.world.initializeLevel(level, 1000 * timer); this.world.initializeLevel(level, 1000 * timer);
@ -153,7 +154,8 @@ public class MarioGame extends KeyAdapter{
this.world.lives = this.initialLives; this.world.lives = this.initialLives;
this.world.mario.isLarge = marioState > 0; this.world.mario.isLarge = marioState > 0;
this.world.mario.isFire = marioState > 1; this.world.mario.isFire = marioState > 1;
this.world.update(new boolean[MarioActions.numberOfActions()]);
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
//initialize graphics //initialize graphics
@ -221,6 +223,7 @@ public class MarioGame extends KeyAdapter{
// update world // update world
this.world.update(actions); this.world.update(actions);
//System.out.println((int) this.world.mario.y / 16);
gameEvents.addAll(this.world.lastFrameEvents); gameEvents.addAll(this.world.lastFrameEvents);
agentEvents.add(new MarioAgentEvent(actions, this.world.mario.x, agentEvents.add(new MarioAgentEvent(actions, this.world.mario.x,
this.world.mario.y, (this.world.mario.isLarge ? 1 : 0) + (this.world.mario.isFire ? 1 : 0), this.world.mario.y, (this.world.mario.isLarge ? 1 : 0) + (this.world.mario.isFire ? 1 : 0),

View File

@ -234,16 +234,22 @@ public class MarioWorld {
public void revive() { public void revive() {
int newTileX = (int) this.mario.x / 16; int newTileX = (int) this.mario.x / 16;
int newTileY = (int) this.mario.y / 16; int newTileY = (int) this.mario.y / 16;
int direction = 1;
try { try {
l: while (true) { l: while (true) {
//System.out.println(newTileX); if(newTileX<this.level.tileWidth){
for (int y = this.level.tileHeight - 2; y >= 8; y--) { //for (int y = this.level.tileHeight-2; y >= 8; y--) {
if (this.level.standable(newTileX, y)) { for (int y = 0; y <= this.level.tileHeight-2; y++) {
newTileY = y; if (this.level.standable(newTileX, y)) {
break l; newTileY = y;
break l;
}
} }
newTileX+=direction;
}else{
direction = -1;
newTileX = (int) this.mario.x / 16;
} }
newTileX++;
} }
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
this.lose(); this.lose();

View File

@ -6,10 +6,16 @@ import uuid
from IDManager import idManager from IDManager import idManager
from flask import Flask, render_template, request, redirect, url_for, session from flask import Flask, render_template, request, redirect, url_for, session
import logging
# 设置logging模块
logging.basicConfig(filename='log.txt', level=logging.DEBUG)
# 将print输出重定向到logging模块
print = logging.getLogger().info
app = Flask(__name__, static_folder='') app = Flask(__name__, static_folder='')
idm = idManager() idm = idManager()
app.secret_key = 'fkdjsafjdkfdlkjfadskjfadskljdsfklj' app.secret_key = 'asdfasdfawefaewvaf'
replayDataPath = "reps/" replayDataPath = "reps/"
evalDataPath = "evals/" evalDataPath = "evals/"
@ -25,6 +31,7 @@ def getId():
@app.route('/') @app.route('/')
def gamewelcome(): def gamewelcome():
ip = getId()
# return redirect(url_for('gameplay', id=request.remote_addr)) # return redirect(url_for('gameplay', id=request.remote_addr))
return render_template('GameWelcome.html') return render_template('GameWelcome.html')

View File

@ -179,7 +179,7 @@
</h1> </h1>
<br> <br>
<h3 id="question"> <h3 id="question">
Do you want to play another round? Do you want to play again from the second phase?
</h3> </h3>
<br> <br>
<button onclick="window.location.href = '/gameplay2';" class="cirButton">Yes</button> <button onclick="window.location.href = '/gameplay2';" class="cirButton">Yes</button>

View File

@ -294,18 +294,18 @@
</p> </p>
<p> <p>
<h4>3. Which player type represents you the best in Super Mario Bros?</h4> <h4>3. Which following selection represents you the best in Super Mario Bros?</h4>
<label> <label>
<input type="radio" class="option-input radio" name="gamestyle" value="A"> <input type="radio" class="option-input radio" name="gamestyle" value="A">
Runner: try to complete a level as fast as possible by running and jumping Trying to complete a level as fast as possible by running and jumping
</label> </label>
<label> <label>
<input type="radio" class="option-input radio" name="gamestyle" value="B"> <input type="radio" class="option-input radio" name="gamestyle" value="B">
Killer: prefer killing all the monsters in a level Prefer killing all the monsters in a level
</label> </label>
<label> <label>
<input type="radio" class="option-input radio" name="gamestyle" value="C"> <input type="radio" class="option-input radio" name="gamestyle" value="C">
Collector: attempt to collect all the coins in a level Attempt to collect all the coins in a level
</label> </label>
<label> <label>
<input type="radio" class="option-input radio" name="gamestyle" value="D"> <input type="radio" class="option-input radio" name="gamestyle" value="D">
@ -340,21 +340,10 @@
<p> <p>
<h4>5. What is your age?</h4> <h4>5. What is your age?</h4>
<label> <label>
<input type="radio" class="option-input radio" name="age" value="A"> <input type="radio" class="option-input radio" name="age" value="">
Below 20 <input type="number" value="" step="1" placeholder="Input your age">
</label>
<label>
<input type="radio" class="option-input radio" name="age" value="B">
20-39
</label>
<label>
<input type="radio" class="option-input radio" name="age" value="C">
40-59
</label>
<label>
<input type="radio" class="option-input radio" name="age" value="D">
Over 60
</label> </label>
<label> <label>
<input type="radio" class="option-input radio" name="age" value="E"> <input type="radio" class="option-input radio" name="age" value="E">
Prefer not to say Prefer not to say
@ -375,9 +364,23 @@
<input type="radio" class="option-input radio" name="gender" value="C"> <input type="radio" class="option-input radio" name="gender" value="C">
Prefer not to say Prefer not to say
</label> </label>
<script>
function renew( ){
$("input[name='gender']").val($("input[type='text']").val())
$("input[name='age']").val($("input[type='number']").val())
}
</script>
<label> <label>
<input type="radio" class="option-input radio" name="gender" value="C"> <input type="radio" class="option-input radio" name="gender" value=" ">
Not listed Other:
<input type="text" value="">
</label> </label>
</p> </p>
@ -397,7 +400,7 @@
<br> <br>
<p><b><input type="submit" value="Submit" class="cirButton" <p><b><input type="submit" value="Submit" class="cirButton"
style="font-weight: 700; font-size: large; width: 60%;" /></b></p> style="font-weight: 700; font-size: large; width: 60%;" onclick ="renew()" /></b></p>
</form> </form>
</div> </div>
@ -457,4 +460,4 @@
</body> </body>
</html> </html>

View File

@ -212,19 +212,24 @@
</nav> </nav>
<section style="background-color: rgba(255,255,255,0.5);"> <section style="background-color: rgb(255, 255, 255);">
<div class="container" style="font-weight: 600; <div class="container" style="font-weight: 600
background-color: rgba(255,255,255,0.7);"> ;">
<div class="row clearfix"> <div class="row clearfix" >
<!-- <style=" background-color: rgba(255,255,255);height: 130vh;
margin-top: -90px;"> -->
<div class="col-md-12"> <div class="col-md-12" style=" background-color: rgba(255,255,255);" >
<div align="center"> <div align="center">
<h3>Super Mario Bros Tutorial</h3> <h3>Super Mario Bros Tutorial</h3>
Before proceeding to the main part of the experiment please familiarize yourself with the game.<br> <p > Before proceeding to the main part of the experiment please familiarize yourself with the game.<br>
You may proceed to the next phase of this survey once you are ready! You may proceed to the next phase of this survey once you are ready!</p>
<br>
<b onclick="replay()" style="cursor: pointer;">Click <u style="color:blue; ">ME</u> to show the instruction page again.</b>
<p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p> <p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p>
</div> </div>
@ -240,7 +245,7 @@
</div> </div>
</div> </div>
<div class="col-md-6" align="center" style="visibility: hidden;" id="next"> <div class="col-md-6" align="center" style="visibility: hidden;" id="next">
<br> <br>
@ -283,31 +288,32 @@
<h3>Play Game</h3> <h3>Play Game</h3>
</button> </button>
</div> </div>
<div id="countdown" <div id="countdown"
style="z-index:999; position:absolute; left:50px; bottom: 20px; color: #ffffff; font-size: xx-large; background-color: rgba(0, 0, 0, 0.3);"> style="z-index:999; position:absolute; left:50px; bottom: 20px; color: #ffffff; font-size: xx-large; ">
</div> </div>
<img style=" height: 90vh;bottom: 3.5vh; left: 0vw; <img style=" height: 90vh;bottom: 3.5vh; left: 0vw;
position: absolute;z-index: 900; visibility: visible; width: 100%;" src="../templates/Web/pic.png" position: absolute;z-index: 900; visibility: visible; width: 100%;" src="../templates/Web/pic.png"
id="windowshow"> id="windowshow">
<script> <script>
function countdown() { function countdown() {
var count = 10; // 设置倒计时秒数 // var count = 10; // 设置倒计时秒数
var timer = setInterval(function () { // var timer = setInterval(function () {
count--; // count--;
if (count <= 0) { // if (count <= 0) {
clearInterval(timer); // clearInterval(timer);
$("#countdown").hide(); // $("#countdown").hide();
$("#windowshow:visible").hide(); // 倒计时结束后隐藏倒计时容器 // $("#windowshow:visible").hide(); // 倒计时结束后隐藏倒计时容器
} else { // } else {
$("#countdown").html("This instruction will close in " + count + "s. <br>Or click to close."); // 更新倒计时容器内容 $("#countdown").html("Click to close."); // 更新倒计时容器内容
$("#windowshow").click(function () { $("#windowshow").click(function () {
$("#windowshow").hide(); $("#windowshow").hide();
$("#countdown").hide(); $("#countdown").hide();
}); });}
} // }
}, 1000); // }, 1000);
} // }
$(document).ready(function () { $(document).ready(function () {
countdown(); countdown();
@ -365,7 +371,6 @@
</div> </div>
<div id="mask" onclick="replay()"></div>
<script> <script>
function replay() { function replay() {
@ -383,7 +388,7 @@
<!-- Footer mx-auto --> <!-- Footer mx-auto -->
<footer class="py-5 bg-dark"> <footer class="py-5 bg-dark">
<div class="container"> <div class="container">
<div class="row clearfix"> <div class="row clearfix" >
<!-- <div class="col-md-2 column"> <!-- <div class="col-md-2 column">
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;"> <img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
</div> --> </div> -->
@ -412,4 +417,4 @@
</body> </body>
</html> </html>

View File

@ -272,9 +272,10 @@
<li> This experiment has <b>three phases</b>. <li> This experiment has <b>three phases</b>.
<ol style="list-style-type: lower-roman;"> <ol style="list-style-type: lower-roman;">
<li>First you must answer <b>a questionnaire</b>. </li> <li>First you must answer <b>a questionnaire</b>. </li>
<li>Then you will complete a <b>short game tutorial</b>, play<b> 2 levels</b> of the game and answer a simple <li>Then you will complete a <b>short game tutorial</b>, play<b> 2 levels</b> of the game and answer a
question. You can <b>repeats</b> this phase as you like. </li> simple question. You will play<b> another 2 levels</b>. </li>
<li>Finally you will play <b>3 levels</b> and answer a simple question.</li> <li>Finally you will play <b>3 levels</b> and answer a simple question.</li>
<li>You can also replay the second phase after finishing the whole process.</li>
</ol> </ol>
<li>In total, the experiment takes approximately <b>15 minutes</b> to complete.</li> <li>In total, the experiment takes approximately <b>15 minutes</b> to complete.</li>
<li> Have Fun! <li> Have Fun!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 KiB

After

Width:  |  Height:  |  Size: 336 KiB