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

This commit is contained in:
Ziqi Wang 2022-10-30 21:22:03 +08:00
commit 3a0d15b8ea
13 changed files with 297 additions and 62 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@
hs_err_pid*
replay_pid*
*.xml
.idea/workspace.xml

9
.idea/workspace.xml generated
View File

@ -3,11 +3,8 @@
<component name="ChangeListManager">
<list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment="">
<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.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/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/helper/Assets.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/helper/Assets.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/eval.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/eval.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/play.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/play.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -91,6 +88,8 @@
<workItem from="1666269906002" duration="7106000" />
<workItem from="1666331056069" duration="7259000" />
<workItem from="1666340478319" duration="84000" />
<workItem from="1666700018091" duration="3635000" />
<workItem from="1666752468427" duration="1563000" />
</task>
<servers />
</component>
@ -109,6 +108,6 @@
</option>
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1666345159743" 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_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1666752985850" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
</component>
</project>

View File

@ -200,4 +200,4 @@ function _c4F26engine7sprites5ShellC2E0(r,q,o,n,m,l,p){var c=null;var a=new crea
function N4Play(){N4java4lang6Object.call(this);}
N4Play.cl=cheerpjCL;
function N4PlayX(a){a.f=N4PlayX;if(cheerpjSafeInitGuard('N4Play')) return;var q=a.q=N4Play.prototype=Object.create(N4java4lang6Object.prototype);q.constructor=N4Play;N4PlayG=1;cheerpjSafeInitFinish('N4Play');}
function _d4pYPlayC2E0(d,p){_n4VYObjectC2E0(d,p);}function _d4_ZPlay8getLevelE1(h,p){var e=null,d=null,c=null;var a={p:p,pc:0,f:_d4_ZPlay8getLevelE1,h:h,e:null,d:null,c:null};a.pc=0;;a.e=e=cheerpjInternString("");a.d=d=new N4java4lang6String();a.c=c=["[Ljava/lang/String;"];for(var i=1;i<=0;i=i+1|0)c[i|0]=null;;a.pc=12;;if((N4java3nio4file5PathsG|0)==0){cjG(a);};a.pc=13;a.c=c=_h4VaSkWorJxGSqKNcmDiDBqm5vd(h,c,a);a.pc=1;;a.pc=15;;if((N4java3nio4file5FilesG|0)==0){cjG(a);};a.pc=16;c=_h4VaSkWoCJxGSqK_HSqivBhramOTSSHnri5Pxd(c,a);a.pc=2;;a.pc=18;_t4VacmSx9n(d,c,a);a.pc=3;;return d;}function ed4_ZPlay8getLevelE1(a,b){a.f=ed4_ZPlay8getLevelE1;var h=a.h,e=a.e,d=a.d,c=a.c;var pc=a.pc;a.pc=4;;a.d=d=b;if((pc>=3&&pc<22)&&self.hasOwnProperty("N4java2io11IOException")&&(b instanceof N4java2io11IOException)|0){a.pc=5;;return e;}else{a.pc=6;;a.pc=-1;return;}}function _d4_YPlay4mainE2(d,p){d[1];d[2];}function _d4p1Play12playGameMainE3(l,k,p){var e=null,c=null,d=null,g=null;var a={p:p,pc:0,f:_d4p1Play12playGameMainE3,k:k,e:null,c:null,d:null,g:null};e=cheerpjInternString("/app/levels/group%s/%s.txt");c=["[Ljava/lang/Object;"];for(var i=1;i<=2;i=i+1|0)c[i|0]=null;;c[1]=l;c[2]=k;a.pc=-281;a.e=e=_t4VY6formatE78(e,c,a);c=cheerpjInternString("/files/%s_sav.rep");d=["[Ljava/lang/Object;"];for(var i=1;i<=1;i=i+1|0)d[i|0]=null;;d[1]=k;a.pc=-434;a.c=c=_t4VY6formatE78(c,d,a);a.pc=-473;;if((N6engine4core9MarioGameG|0)==0){cjG(a);};a.d=d=new N6engine4core9MarioGame();a.pc=-565;_c4V26engine4core9MarioGameC2E0(d,a);a.pc=-612;;if((N6agents10HumanAgentG|0)==0){cjG(a);};a.g=g=new N6agents10HumanAgent();a.pc=-698;_c4Vaw0SbrZKunDifdqJgrmiGac7rd(g,a);a.pc=-744;e=_d4_ZPlay8getLevelE1(e,a);a.pc=-782;e=d.v11(d,g,e,200,c,a);a.pc=-815;a.e=e=e.v16(e,a);a.pc=-842;;if((N6engine6helper6ReplayG|0)==0){cjG(a);};return _c4F76engine6helper6Replay20serializeAgentEventsE2(e,p);}function _d4V1Play14replayGameMainE4(l,k,p){var e=null,c=null,d=null,g=null;var a={p:p,pc:0,f:_d4V1Play14replayGameMainE4,k:k,e:null,c:null,d:null,g:null};e=cheerpjInternString("/app/levels/group%s/%s.txt");c=["[Ljava/lang/Object;"];for(var i=1;i<=2;i=i+1|0)c[i|0]=null;;c[1]=l;c[2]=k;a.pc=-285;a.e=e=_t4VY6formatE78(e,c,a);c=cheerpjInternString("/files/%s_sav.rep");d=["[Ljava/lang/Object;"];for(var i=1;i<=1;i=i+1|0)d[i|0]=null;;d[1]=k;a.pc=-438;a.c=c=_t4VY6formatE78(c,d,a);a.pc=-477;;if((N6engine4core9MarioGameG|0)==0){cjG(a);};a.d=d=new N6engine4core9MarioGame();a.pc=-569;_c4V26engine4core9MarioGameC2E0(d,a);a.pc=-616;;if((N6engine6helper6ReplayG|0)==0){cjG(a);};a.pc=-671;a.g=g=_c4p76engine6helper6Replay19getRepAgentFromFileE1(c,a);a.pc=-742;e=_d4_ZPlay8getLevelE1(e,a);d.v11(d,g,e,200,c,p);}
function _d4pYPlayC2E0(d,p){_n4VYObjectC2E0(d,p);}function _d4_ZPlay8getLevelE1(h,p){var e=null,d=null,c=null;var a={p:p,pc:0,f:_d4_ZPlay8getLevelE1,h:h,e:null,d:null,c:null};a.pc=0;;a.e=e=cheerpjInternString("");a.d=d=new N4java4lang6String();a.c=c=["[Ljava/lang/String;"];for(var i=1;i<=0;i=i+1|0)c[i|0]=null;;a.pc=12;;if((N4java3nio4file5PathsG|0)==0){cjG(a);};a.pc=13;a.c=c=_h4VaSkWorJxGSqKNcmDiDBqm5vd(h,c,a);a.pc=1;;a.pc=15;;if((N4java3nio4file5FilesG|0)==0){cjG(a);};a.pc=16;c=_h4VaSkWoCJxGSqK_HSqivBhramOTSSHnri5Pxd(c,a);a.pc=2;;a.pc=18;_t4VacmSx9n(d,c,a);a.pc=3;;return d;}function ed4_ZPlay8getLevelE1(a,b){a.f=ed4_ZPlay8getLevelE1;var h=a.h,e=a.e,d=a.d,c=a.c;var pc=a.pc;a.pc=4;;a.d=d=b;if((pc>=3&&pc<22)&&self.hasOwnProperty("N4java2io11IOException")&&(b instanceof N4java2io11IOException)|0){a.pc=5;;return e;}else{a.pc=6;;a.pc=-1;return;}}function _d4_YPlay4mainE2(d,p){d[1];d[2];}function _d4p1Play12playGameMainE3(l,k,p){var e=null,d=null,c=null,g=null;var a={p:p,pc:0,f:_d4p1Play12playGameMainE3,k:k,e:null,d:null,c:null,g:null};e=cheerpjInternString("/app/levels/%s.lvl");d=["[Ljava/lang/Object;"];for(var i=1;i<=1;i=i+1|0)d[i|0]=null;;d[1]=k;a.pc=-266;a.e=e=_t4VY6formatE78(e,d,a);d=cheerpjInternString("/files/%s_sav.rep");c=["[Ljava/lang/Object;"];for(var i=1;i<=1;i=i+1|0)c[i|0]=null;;c[1]=k;a.pc=-419;a.d=d=_t4VY6formatE78(d,c,a);a.pc=-458;;if((N6engine4core9MarioGameG|0)==0){cjG(a);};a.c=c=new N6engine4core9MarioGame();a.pc=-550;_c4V26engine4core9MarioGameC2E0(c,a);a.pc=-597;;if((N6agents10HumanAgentG|0)==0){cjG(a);};a.g=g=new N6agents10HumanAgent();a.pc=-683;_c4Vaw0SbrZKunDifdqJgrmiGac7rd(g,a);a.pc=-729;e=_d4_ZPlay8getLevelE1(e,a);a.pc=-767;e=c.v11(c,g,e,200,d,a);a.pc=-800;a.e=e=e.v16(e,a);a.pc=-827;;if((N6engine6helper6ReplayG|0)==0){cjG(a);};return _c4F76engine6helper6Replay20serializeAgentEventsE2(e,p);}function _d4V1Play14replayGameMainE4(l,k,p){var e=null,c=null,d=null,g=null;var a={p:p,pc:0,f:_d4V1Play14replayGameMainE4,k:k,e:null,c:null,d:null,g:null};e=cheerpjInternString("/app/levels/%s.lvl");c=["[Ljava/lang/Object;"];for(var i=1;i<=1;i=i+1|0)c[i|0]=null;;c[1]=k;a.pc=-270;a.e=e=_t4VY6formatE78(e,c,a);c=cheerpjInternString("/files/%s_sav.rep");d=["[Ljava/lang/Object;"];for(var i=1;i<=1;i=i+1|0)d[i|0]=null;;d[1]=k;a.pc=-423;a.c=c=_t4VY6formatE78(c,d,a);a.pc=-462;;if((N6engine4core9MarioGameG|0)==0){cjG(a);};a.d=d=new N6engine4core9MarioGame();a.pc=-554;_c4V26engine4core9MarioGameC2E0(d,a);a.pc=-601;;if((N6engine6helper6ReplayG|0)==0){cjG(a);};a.pc=-656;a.g=g=_c4p76engine6helper6Replay19getRepAgentFromFileE1(c,a);a.pc=-727;e=_d4_ZPlay8getLevelE1(e,a);d.v11(d,g,e,200,c,p);}

View File

@ -0,0 +1 @@
test2,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18

View File

@ -0,0 +1 @@
test2,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,18,18,18,18,18,2,2,2,2,2,2,2,18,18,18,18,18,18,18,2,2,2,2,2,2,2,16,16,16,16,18,18,18,2,2,2,2,2,2,2,2,2,0,0,16,16,18,18,18,18,18,18,18,18,2,2,2,2,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,2,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,2,2,2

View File

@ -39,7 +39,7 @@ public class Play {
public static byte[] playGameMain(String groupID, String levelName){
String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For web
String levelPath = String.format("/app/levels/%s.lvl", levelName); // For web
String repPath = String.format("/files/%s_sav.rep", levelName); // For web
MarioGame game = new MarioGame();
@ -49,7 +49,7 @@ public class Play {
}
public static void replayGameMain(String groupID, String levelName){
String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For web
String levelPath = String.format("/app/levels/%s.lvl", levelName); // For web
String repPath = String.format("/files/%s_sav.rep", levelName); // For web
// String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For local

Binary file not shown.

1
evals/eval.txt Normal file
View File

@ -0,0 +1 @@
2-1

32
main.py
View File

@ -1,8 +1,11 @@
import os
from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__, static_folder='')
bufferJson = ['']
replayDataPath = "reps/"
evalDataPath = "evals/"
@app.route('/')
def index():
@ -10,18 +13,33 @@ def index():
return render_template('play.html', py2htmlstr=py2htmlstr)
@app.route('/datapage')
def datapage():
return bufferJson
@app.route('/eval')
def eval():
return render_template('eval.html')
@app.route('/', methods=['POST'])
def getData():
def getJSONData():
if request.method == 'POST':
print("POST")
print("POST Game")
print(request.json)
return redirect(url_for('datapage'))
saveFile(replayDataPath, request.json[4], request.json)
return "Catch JSON Data"
@app.route('/eval', methods=['POST'])
def getRadioData():
if request.method == 'POST':
print("POST Eval")
print(request.json)
saveFile(evalDataPath,"eval",request.json[0]+request.json[1]+request.json[2])
return "catch Radio"
def saveFile(path,filename,content):
file_dir = os.path.join(os.getcwd(), path)
file_path = os.path.join(file_dir, filename+".txt")
f = open(file_path, "w", encoding="utf8")
f.write(content)
f.close()
if __name__ == '__main__':
app.debug = True

1
reps/1.txt Normal file
View File

@ -0,0 +1 @@
test1,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2

1
reps/2.txt Normal file
View File

@ -0,0 +1 @@
test2,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,18,18,18,18,0,0,0,0,0,0,0,0,0,0,0,18,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,18,18,18,18,18,2,2,2,2,2,2,2,2,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,2,1

186
templates/eval.html Normal file
View File

@ -0,0 +1,186 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
.popwindow {
width:500px;
height:550px;
border:3px solid #ff928e;
visibility: hidden;
position: absolute;
z-index: 999;
opacity: 1;
overflow: hidden;
background-color: white;
text-align: center;
margin-top: 10%;
margin-left: 35%;
border-radius: 10px;
}
.leftInfoBlock{
margin-top: 20px;
height: 180px;
background: #f1a087;
}
.leftInfo {
width: 90%;
top: 20px;
position:absolute;
background: #f7a2a2;
}
.rightQuery{
width: 10%;
left: 90%;
height: 400px;
top: 20px;
position:absolute;
background: #a19cee;
}
.circleButton{
align-items: center;
border-radius:50%;
border: none
}
.pararadio{
height: 20%;
}
</style>
</head>
<div id="replayWindow" class="popwindow">
<div id="replayWindowGame">
</div>
<div align="center"><button onClick="closeReplayWindow()">Close Window</button></div>
</div>
<body>
<div class = "leftInfo">
<div class = "leftInfoBlock">
<h3 align = "center"> Game 1</h3>
<img src="../levels/test1.png" width="100%" >
<div align="center"><button onClick="Replay('test1')">Replay Game1</button></div>
</div>
<div class = "leftInfoBlock">
<h3 align = "center"> Game 2</h3>
<img src="../levels/test2.png" width="100%" >
<div align="center"><button onClick="Replay('test2')">Replay Game2</button></div>
</div>
<script>
//The Funtions
function closeReplayWindow(){
var replayWindow=document.getElementById("replayWindow");
replayWindow.style.visibility = 'hidden';
}
function Replay(id){
var replayWindow=document.getElementById("replayWindow");
replayWindow.style.visibility = 'visible';
cjCall("Play", "replayGameMain", id, id);
}
function getValue(){
var radio = document.getElementsByName("gameRadio");
for (i=0; i<radio.length; i++) {
if (radio[i].checked) {
alert(radio[i].value)
}
}
}
function PostToServer(data) {
var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
httpRequest.open("POST",""); //调用AddDataToServer
httpRequest.setRequestHeader("Content-Type", "application/json"); //设置请求头信息
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
//alert('添加成功');
}
}
httpRequest.send(JSON.stringify(data)); //设置为发送给服务器数据
}
window.onload=function(){
closeReplayWindow();
}
</script>
<script>
cheerpjInit();
var divElement = document.getElementById("replayWindowGame");
cheerpjCreateDisplay(500,500,divElement);
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
closeReplayWindow();
</script>
</div>
<div class = "rightQuery">
<!-- <button class = "circleButton" style = "width: 100px; height: 100px;"></button>
<button class = "circleButton" style = "width: 60px; height: 60px;"></button>
<button class = "circleButton" style = "width: 40px; height: 40px;"></button>
<button class = "circleButton" style = "width: 60px; height: 60px;"></button>
<button class = "circleButton" style = "width: 100px; height: 100px;"></button> -->
<fieldset style="height: 100%;" >
<legend align="center" height = 30px >Fun</legend>
<div class = "pararadio">
<input type="radio" value="1-2" name="fun">
<label for="gameRadio">Game1 Better</label>
</div>
<div class = "pararadio">
<input type="radio" value="1-1" name="fun">
<label for="gameRadio">Game1 Good</label>
</div>
<div class = "pararadio">
<input type="radio" value="0-0" name="fun">
<label for="gameRadio">Equal</label>
</div>
<div class = "pararadio">
<input type="radio" value="2-1" name="fun">
<label for="gameRadio">Game2 Good</label>
</div>
<div class = "pararadio">
<input type="radio" value="2-2" name="fun">
<label for="gameRadio">Game2 Better</label>
</div>
</fieldset>
<script>
function getRadioValue(){
var obj = document.getElementsByName("fun");
for(var i=0; i<obj.length; i ++){
if(obj[i].checked){
PostToServer(obj[i].value);
alert(obj[i].value);
}
}
// var radio = document.getElementsByName("gameRadio");
// var addressID = $("input[name='sex']:checked").val();
// alert(addressID)
}
</script>
<button onclick="getRadioValue()"> Submit </button>
</div>
</body>
</html>

View File

@ -5,71 +5,97 @@
<title>CheerpJ test</title>
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
<script>
window.onload = function () {
//The Funtions
function PlayLevel(group, level){
var returnVal = cjCall("Play", "playGameMain", group, level);
return returnVal.then(function(){
console.log("the return val is ready");
console.log(returnVal.value);
PostToServer(level,returnVal.value);
});
}
function Replay(){
cjCall("Play", "replayGameMain", "test2", "test2");
};
function GameOver(){
if(alert("Game Over!")){
}
function PostToServer(data) {
}
function PostToServer(level, data) {
var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
httpRequest.open("POST",""); //调用AddDataToServer
httpRequest.setRequestHeader("Content-Type", "application/json"); //设置请求头信息
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
alert('添加成功');
//alert('添加成功');
}
}
console.log(typeof Array.from(data));
console.log(Array.from(data));
httpRequest.send(JSON.stringify(Array.from(data))); //设置为发送给服务器数据
//httpRequest.send((""+data));
httpRequest.send(JSON.stringify(level+","+Array.from(data))); //设置为发送给服务器数据
}
</script>
</head>
<body>
<div align="center">
<h1>Mario Game User Test</h1>
</div>
<div align="center" id = "GameWindow">
</div>
<div align="center"><button onClick="Replay()">Replay Game</button></div>
</body>
<br />{{ py2htmlstr }}
<script>
//Init Cheerpj Framework
cheerpjInit();
cheerpjCreateDisplay(800,600);
/*
function cheerpjCreateDisplay(w, h, oldElem)
{
// Create a div element that will contain all Java Windows
var element = document.createElement("div");
cjDisplay = element;
element.id="cheerpjDisplay";
if(oldElem && w<0 && h<0)
{
// Compute the sizes from the parent
element.style.width="100%";
element.style.height="100%";
}
else
{
element.style.width=w+"px";
element.style.height=h+"px";
}
element.classList.add("cheerpjLoading");
element.classList.add("bordered");
if(oldElem)
oldElem.appendChild(element);
else
document.body.appendChild(element);
cheerpjSetStatus(cjStatus, element);
return element;
}*/
var divElement = document.getElementById("GameWindow");
cheerpjCreateDisplay(500,500,divElement);
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
console.log("done");
console.log("Cheerpj Initialize Succeed!");
//cheerpjRunJar("/app/Mario-AI-Interface.jar");
var returnVal = cjCall("Play", "playGameMain", "0", "f_l");
returnVal.then(function(){
console.log("the return val is ready");
console.log(returnVal.value);
PostToServer(returnVal.value);
});
//.then(function(){console.log(" over2 ");});
//.catch((e) => {});
//console.log(returnVal);
// cheerpjRunJar("/app/Mario-AI-Interface.jar");
// var actionSequenceInBytes = cjCall("MarioProxy", "play", "0", "f_l", "0");
PlayLevel("test1", "test1")
.then(function (){alert("Game Over!")})
.then(PlayLevel("test2", "test2")
.then(function (){
alert("Go to Evaluation Window")
window.location.href = window.location.href + "\eval"
}));
</script>
<form>
<input type="button" id="replayButton" value="Replay">
</form>
<script>
var button = document.getElementById("replayButton");
button.onclick = function(){
//alert("WTF?")
cjCall("Play", "replayGameMain", "0", "f_l");
};
</script>
</html>