Fixed Engine Bug, Update Features

This commit is contained in:
bigJIU 2023-02-28 15:13:42 +08:00
parent 79c49034c5
commit f7be38c963
13 changed files with 54 additions and 48 deletions

14
.idea/workspace.xml generated
View File

@ -5,17 +5,16 @@
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface.jar" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface.jar" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Mario-AI-Interface.jar" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface.jar.js" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface.jar.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Mario-AI-Interface.jar.js" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface.jar.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/Play.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/Play.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/HumanAgent.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/HumanAgent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/ReplayAgent.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/ReplayAgent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioGame.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioGame.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioGame.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioGame.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioWorld.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioWorld.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/helper/MarioActions.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/helper/MarioActions.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/annotation.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/annotation.csv" afterDir="false" /> <change beforePath="$PROJECT_DIR$/data/annotation.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/annotation.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/questionare.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/questionare.csv" afterDir="false" /> <change beforePath="$PROJECT_DIR$/data/questionare.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/questionare.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameAnnotation.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameAnnotation2.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation2.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/GameAnnotation2.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation2.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GamePlay.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GamePlay.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/GameOver.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameOver.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameTutorial.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameTutorial.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/GameWelcome.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameWelcome.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/data.js" beforeDir="false" afterPath="$PROJECT_DIR$/templates/data.js" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -219,6 +218,7 @@
<workItem from="1676991343098" duration="1013000" /> <workItem from="1676991343098" duration="1013000" />
<workItem from="1677221941122" duration="2329000" /> <workItem from="1677221941122" duration="2329000" />
<workItem from="1677303698061" duration="6278000" /> <workItem from="1677303698061" duration="6278000" />
<workItem from="1677563906178" duration="4152000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -240,6 +240,6 @@
<SUITE FILE_PATH="coverage/MarioWeb$MarioWeb.coverage" NAME="MarioWeb Coverage Results" MODIFIED="1669305478201" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" /> <SUITE FILE_PATH="coverage/MarioWeb$MarioWeb.coverage" NAME="MarioWeb Coverage Results" MODIFIED="1669305478201" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
<SUITE FILE_PATH="coverage/MarioWeb$test.coverage" NAME="test Coverage Results" MODIFIED="1668079935841" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/MarioWeb$test.coverage" NAME="test Coverage Results" MODIFIED="1668079935841" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1677224605926" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1677224605926" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py___1_.coverage" NAME="Flask (main.py) (1) Coverage Results" MODIFIED="1677309921250" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" /> <SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py___1_.coverage" NAME="Flask (main.py) (1) Coverage Results" MODIFIED="1677566663144" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
</component> </component>
</project> </project>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ public class HumanAgent extends KeyAdapter implements MarioAgent {
return actions.clone(); return actions.clone();
}else{ }else{
System.out.println("return true"); System.out.println("return true");
return new boolean[]{true, false, true, true, true}; return new boolean[]{true, false, true, true, true, true};
} }
} }

View File

@ -33,11 +33,11 @@ public class ReplayAgent extends KeyAdapter implements MarioAgent {
public boolean[] getActions(MarioForwardModel model, MarioTimer timer) { public boolean[] getActions(MarioForwardModel model, MarioTimer timer) {
if(!isPressed){ if(!isPressed){
if (p >= actions.length) if (p >= actions.length)
return new boolean[5]; return new boolean[6];
return this.actions[p++]; return this.actions[p++];
}else{ }else{
System.out.println("return true"); System.out.println("return true");
return new boolean[]{true, true, false, true, true}; return new boolean[]{false, true, true, true, true, true};
} }
} }

View File

@ -197,16 +197,16 @@ public class MarioGame extends KeyAdapter{
replayBreak = true; replayBreak = true;
} }
// Mid Break & Cheat Mode // Mid Break & Cheat Mode
if(actions[0]&&actions[1]){ if(actions[0]&&!actions[1]&&actions[2]&&actions[3]&&actions[4]&&actions[5]){
this.world.lose();
replayBreak = true;
//break;
}
if(actions[0]&&actions[2]){
this.world.lose(); this.world.lose();
cheatBreak = true; cheatBreak = true;
//break; //break;
} }
if(!actions[0]&&actions[1]&&actions[2]&&actions[3]&&actions[4]&&actions[5]){
this.world.lose();
replayBreak = true;
//break;
}
// update world // update world
this.world.update(actions); this.world.update(actions);
@ -257,8 +257,6 @@ public class MarioGame extends KeyAdapter{
stopGame(); stopGame();
System.out.println("Pressed mg"); System.out.println("Pressed mg");
} }
} }
} }
public void setLives(int lives) { public void setLives(int lives) {

View File

@ -5,7 +5,8 @@ public enum MarioActions {
RIGHT(1, "Right"), RIGHT(1, "Right"),
DOWN(2, "Down"), DOWN(2, "Down"),
SPEED(3, "Speed"), SPEED(3, "Speed"),
JUMP(4, "Jump"); JUMP(4, "Jump"),
DONE(5,"Done");
private int value; private int value;
private String name; private String name;

View File

@ -27,3 +27,5 @@ IP,A-ID,B-ID,Anno,
127.0.0.1,75,17,N, 127.0.0.1,75,17,N,
127.0.0.1,69,73,N, 127.0.0.1,69,73,N,
127.0.0.1,31,125,N, 127.0.0.1,31,125,N,
127.0.0.1,56,57,N,
127.0.0.1,200,144,N,

1 IP A-ID B-ID Anno
27 127.0.0.1 75 17 N
28 127.0.0.1 69 73 N
29 127.0.0.1 31 125 N
30 127.0.0.1 56 57 N
31 127.0.0.1 200 144 N

View File

@ -195,3 +195,8 @@ IP,Style,Frequency,Age,Gender
127.0.0.1,C,A,D,B,E,A,, 127.0.0.1,C,A,D,B,E,A,,
127.0.0.1,C,A,A,A,G,A,, 127.0.0.1,C,A,A,A,G,A,,
127.0.0.1,C,A,B,B,A,A,, 127.0.0.1,C,A,B,B,A,A,,
127.0.0.1,A,A,A,A,A,A,,
127.0.0.1,C,A,D,A,E,A,,
127.0.0.1,A,A,A,E,B,C,,
127.0.0.1,A,A,A,A,A,A,,
127.0.0.1,A,A,A,A,A,A,,

1 IP,Style,Frequency,Age,Gender
195 127.0.0.1,C,A,D,B,E,A,,
196 127.0.0.1,C,A,A,A,G,A,,
197 127.0.0.1,C,A,B,B,A,A,,
198 127.0.0.1,A,A,A,A,A,A,,
199 127.0.0.1,C,A,D,A,E,A,,
200 127.0.0.1,A,A,A,E,B,C,,
201 127.0.0.1,A,A,A,A,A,A,,
202 127.0.0.1,A,A,A,A,A,A,,

14
main.py
View File

@ -22,6 +22,7 @@ def gamewelcome():
# 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')
@app.route('/question') @app.route('/question')
def gamequestion(): def gamequestion():
return render_template('GameQuestion.html') return render_template('GameQuestion.html')
@ -51,7 +52,8 @@ def gamepreplay():
@app.route('/gametutorial/<id>') @app.route('/gametutorial/<id>')
def gametutorial(id): def gametutorial(id):
return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),control=idm.getControl(id)) return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),
control=idm.getControl(id))
@app.route('/again') @app.route('/again')
@ -71,7 +73,6 @@ def gameplay(id):
jump="/annotation") jump="/annotation")
@app.route('/gameplay/<id>/data', methods=['POST']) @app.route('/gameplay/<id>/data', methods=['POST'])
def getJSONData(id): def getJSONData(id):
if request.method == 'POST': if request.method == 'POST':
@ -87,7 +88,6 @@ def gamepreanno():
return redirect(url_for('gameanno', id=request.remote_addr)) return redirect(url_for('gameanno', id=request.remote_addr))
@app.route('/annotation/<id>') @app.route('/annotation/<id>')
def gameanno(id): def gameanno(id):
if (id != "radioresult"): if (id != "radioresult"):
@ -117,7 +117,6 @@ def getRadioData():
return redirect(url_for("gameplay", id=ip)) return redirect(url_for("gameplay", id=ip))
@app.route('/gameplay2') @app.route('/gameplay2')
def gamepreplay2(): def gamepreplay2():
return redirect(url_for('gameplay2', id=request.remote_addr)) return redirect(url_for('gameplay2', id=request.remote_addr))
@ -168,7 +167,8 @@ def gameannoresult2(id):
print(resultList) print(resultList)
idm.write_csv(annotationPath2, idm.write_csv(annotationPath2,
[request.remote_addr, resultList[0], resultList[1], resultList[2], levelList[0], levelList[1], levelList[2], [request.remote_addr, resultList[0], resultList[1], resultList[2], levelList[0], levelList[1],
levelList[2],
""]) ""])
if idm.getTimes(id): if idm.getTimes(id):
@ -180,13 +180,13 @@ def gameannoresult2(id):
@app.route("/gameover") @app.route("/gameover")
def over(): def over():
# finish = idm.getTimes(request.remote_addr) finish = idm.getTimes(request.remote_addr)
# print("finish %d",finish) # print("finish %d",finish)
# if finish: # if finish:
# idm.setTimes(request.remote_addr) # idm.setTimes(request.remote_addr)
# else: # else:
# idm.addTimes(request.remote_addr) # idm.addTimes(request.remote_addr)
return render_template("GameOver.html") return render_template("GameOver.html", finish=1, stage=1)
def saveFile(path, filename, content): def saveFile(path, filename, content):

View File

@ -33,7 +33,7 @@
.popwindow { .popwindow {
width:500px; width:500px;
height:550px; height:580px;
border:3px solid #ff928e; border:3px solid #ff928e;
visibility: hidden; visibility: hidden;
position: absolute; position: absolute;

View File

@ -171,8 +171,8 @@
<h3> <h3>
Do you want to play another round? Do you want to play another round?
</h3> </h3>
<button>Yes</button> <button onclick="window.location.href = '/gameplay2';">Yes</button>
<button>No</button> <button onclick="window.location.href = 'about:blank';">No</button>
<div style=""> <div style="">
<button onclick=" <button onclick="
if('{{stage}}' == '2'){ if('{{stage}}' == '2'){
@ -180,16 +180,15 @@
}else{ }else{
window.location.href = '/again' window.location.href = '/again'
} }
">Keep Playing!</button> " style="visibility: hidden">Keep Playing!</button>
<button id = "Finish" onclick=" <button id = "Finish" onclick="
if('{{stage}}' == '2'){ if('{{stage}}' == '2'){
window.location.href = 'about:blank'; window.location.href = 'about:blank';
window.close(); window.close();
}else{ }else{
window.location.href = '/gameplay2'; window.location.href = '/gameplay2';
} }
">Finish!</button> " style="visibility: hidden">Finish!</button>
</div> </div>
</div> </div>
</section> </section>

View File

@ -224,7 +224,7 @@
justify-content: center; justify-content: center;
min-width: fit-content; min-width: fit-content;
"> ">
<img src="../img/welcome.png" > <img src="../img/frameworkAD.gif" >
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
@ -238,7 +238,8 @@
<ul> <ul>
<li> This experiment consists of two phases, In each phase you will first be asked to play a number of Super Mario Bros games <li> This experiment consists of two phases, In each phase you will first be asked to play a number of Super Mario Bros games
and then will be asked some questions about the levels you just played. and then will be asked some questions about the levels you just played.
<li> It takes about <b>15 minutes in total</b> to complete the experiment.<br>
<li> You will play <b>the tutorial level and 2 + 2 + 3 = 7 levels</b> of game during the experiment. It takes about <b>15 minutes in total</b> to complete the experiment.<br>
<li> Have Fun! <li> Have Fun!
</ul> </ul>