Update Several Logic

This commit is contained in:
bigJIU 2023-02-08 03:38:06 +08:00
parent 928d98b23f
commit 50644250c6
11 changed files with 59 additions and 34 deletions

11
.idea/workspace.xml generated
View File

@ -5,20 +5,13 @@
<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/reps/f_l_sav.rep" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/reps/f_l_sav.rep" 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/Play.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/Play.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$/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/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/GameOver.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameOver.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/GamePlay.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GamePlay.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameQuestion.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameQuestion.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" />
@ -214,6 +207,8 @@
<workItem from="1670662279126" duration="964000" /> <workItem from="1670662279126" duration="964000" />
<workItem from="1670919169632" duration="2232000" /> <workItem from="1670919169632" duration="2232000" />
<workItem from="1671001937679" duration="1407000" /> <workItem from="1671001937679" duration="1407000" />
<workItem from="1671278879840" duration="3791000" />
<workItem from="1675757773553" duration="7165000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -234,7 +229,7 @@
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<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="1671002752224" 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="1675781448695" 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="1668079945407" 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="1668079945407" 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

@ -11,6 +11,7 @@ import engine.core.MarioResult;
import engine.helper.Replay; import engine.helper.Replay;
public class Play { public class Play {
private static MarioGame game;
public static String getLevel(String filepath) { public static String getLevel(String filepath) {
String content = ""; String content = "";
try { try {
@ -46,7 +47,7 @@ public class Play {
// String levelPath = String.format("./levels/group%s/%s.lvl", "0", levelName); // For local // String levelPath = String.format("./levels/group%s/%s.lvl", "0", levelName); // For local
// String repPath = String.format("./reps/%s_sav.rep", levelName); // For local // String repPath = String.format("./reps/%s_sav.rep", levelName); // For local
MarioGame game = new MarioGame(); game = new MarioGame();
game.setLives(lives); game.setLives(lives);
MarioResult tmpResult = game.playGame(new HumanAgent(control),getLevel(levelPath), time, repPath,col); MarioResult tmpResult = game.playGame(new HumanAgent(control),getLevel(levelPath), time, repPath,col);
@ -64,8 +65,11 @@ public class Play {
// String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For local // String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For local
// String repPath = String.format("./files/%s_sav.rep", levelName); // For local // String repPath = String.format("./files/%s_sav.rep", levelName); // For local
MarioGame game = new MarioGame(); game = new MarioGame();
game.setLives(lives); game.setLives(lives);
game.playGame(Replay.getRepAgentFromFile(repPath),getLevel(levelPath), time, repPath,col); game.playGame(Replay.getRepAgentFromFile(repPath),getLevel(levelPath), time, repPath,col);
} }
public static void stopReplay(){
game.stopGame();
}
} }

View File

@ -220,6 +220,9 @@ public class MarioGame {
return new MarioResult(this.world, gameEvents, agentEvents); return new MarioResult(this.world, gameEvents, agentEvents);
} }
public void stopGame(){
this.world.gameStatus = GameStatus.LOSE;
}
public void setLives(int lives) { public void setLives(int lives) {
this.initialLives = lives; this.initialLives = lives;
} }

Binary file not shown.

View File

@ -159,3 +159,10 @@ IP,Style,Frequency,Age,Gender
10.27.169.251,A,A,A,A,B,A,, 10.27.169.251,A,A,A,A,B,A,,
10.27.169.251,A,A,A,A,A,A,, 10.27.169.251,A,A,A,A,A,A,,
10.27.169.251,A,A,D,B,B,A,, 10.27.169.251,A,A,D,B,B,A,,
127.0.0.1,A,A,A,D,F,A,,
127.0.0.1,A,A,A,A,A,A,,
127.0.0.1,A,A,A,A,A,A,,
127.0.0.1,A,A,A,A,A,A,,
127.0.0.1,B,A,A,A,A,A,,
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
159 10.27.169.251,A,A,A,A,B,A,,
160 10.27.169.251,A,A,A,A,A,A,,
161 10.27.169.251,A,A,D,B,B,A,,
162 127.0.0.1,A,A,A,D,F,A,,
163 127.0.0.1,A,A,A,A,A,A,,
164 127.0.0.1,A,A,A,A,A,A,,
165 127.0.0.1,A,A,A,A,A,A,,
166 127.0.0.1,B,A,A,A,A,A,,
167 127.0.0.1,A,A,A,A,A,A,,
168 127.0.0.1,A,A,A,A,A,A,,

31
main.py
View File

@ -101,8 +101,12 @@ def getRadioData():
ipRecent = idm.getRecent(ip) ipRecent = idm.getRecent(ip)
idm.write_csv(annotationPath, [ip, ipRecent[0], ipRecent[1], result["fun"]]) idm.write_csv(annotationPath, [ip, ipRecent[0], ipRecent[1], result["fun"]])
if idm.getTimes(ip):
return redirect(url_for("gameplay2",id=ip))
else:
idm.addTimes(ip)
return redirect(url_for("gameplay",id=ip))
return redirect(url_for('over', stage=1))
@app.route('/gameplay2') @app.route('/gameplay2')
@ -157,18 +161,23 @@ def gameannoresult2(id):
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],
""]) ""])
return redirect(url_for('over', stage=2))
if idm.getTimes(id):
return redirect(url_for("over", id=id))
else:
idm.addTimes(id)
return redirect(url_for("gameplay2", id=id))
@app.route("/gameover/<stage>") @app.route("/gameover")
def over(stage): 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", finish=finish, stage=stage) return render_template("GameOver.html")
def saveFile(path, filename, content): def saveFile(path, filename, content):

File diff suppressed because one or more lines are too long

View File

@ -241,8 +241,9 @@ function Replay(id){
<br><br> <br><br>
<div class="container"> <div class="container">
<h1> <h1>
<i class="icon-heart-empty"></i> What's their "fun" rank? <i class="icon-heart-empty"></i> Please rank the above levels in terms of "fun" (from highest to lowest)
</h1> </h1>
<p>[Please drag and drop the boxes below to your favourite ranking]</p>
<br> <br>
<div class="wrapper"> <div class="wrapper">

View File

@ -162,18 +162,21 @@
<section id="Over"> <section id="Over">
<div class="container"> <div class="container">
<h1> <h1>
<i class="icon-chevron-down"></i> Thank You!!! <i class="icon-chevron-down"></i> Thank You For Playing!!!
</h1> </h1>
<br> <br>
<h3>
Do you want to play another round?
</h3>
<button>Yes</button>
<button>No</button>
<div style="">
<button onclick=" <button onclick="
if('{{stage}}' == '2'){ if('{{stage}}' == '2'){
window.location.href = '/gameplay2'; window.location.href = '/gameplay2';
}else{ }else{
window.location.href = '/again' window.location.href = '/again'
} }
">Keep Playing!</button> ">Keep Playing!</button>
<button id = "Finish" onclick=" <button id = "Finish" onclick="
if('{{stage}}' == '2'){ if('{{stage}}' == '2'){
@ -183,8 +186,8 @@
window.location.href = '/gameplay2'; window.location.href = '/gameplay2';
} }
">Finish!</button> ">Finish!</button>
</div>
</div> </div>
</section> </section>