diff --git a/.gitignore b/.gitignore index 4ad2cbe..05da908 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ hs_err_pid* replay_pid* *.xml +.idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b4303a9..ec6fdc0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,11 +3,8 @@ - - - - + @@ -109,6 +108,6 @@ - + \ No newline at end of file diff --git a/Mario-AI-Interface.jar.js b/Mario-AI-Interface.jar.js index 388a9a4..ecb689c 100644 --- a/Mario-AI-Interface.jar.js +++ b/Mario-AI-Interface.jar.js @@ -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);} \ No newline at end of file +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);} \ No newline at end of file diff --git a/Mario-AI-Interface/reps/1.txt b/Mario-AI-Interface/reps/1.txt new file mode 100644 index 0000000..43bef96 --- /dev/null +++ b/Mario-AI-Interface/reps/1.txt @@ -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 \ No newline at end of file diff --git a/Mario-AI-Interface/reps/t.txt b/Mario-AI-Interface/reps/t.txt new file mode 100644 index 0000000..f6c18b4 --- /dev/null +++ b/Mario-AI-Interface/reps/t.txt @@ -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 \ No newline at end of file diff --git a/Mario-AI-Interface/src/Play.java b/Mario-AI-Interface/src/Play.java index b8dd9cb..5bf2c1d 100644 --- a/Mario-AI-Interface/src/Play.java +++ b/Mario-AI-Interface/src/Play.java @@ -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 diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc index 69cade3..c593cf3 100644 Binary files a/__pycache__/main.cpython-39.pyc and b/__pycache__/main.cpython-39.pyc differ diff --git a/evals/eval.txt b/evals/eval.txt new file mode 100644 index 0000000..0709265 --- /dev/null +++ b/evals/eval.txt @@ -0,0 +1 @@ +2-1 \ No newline at end of file diff --git a/main.py b/main.py index be6e3a5..cfcc7dc 100644 --- a/main.py +++ b/main.py @@ -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 diff --git a/reps/1.txt b/reps/1.txt new file mode 100644 index 0000000..0052a08 --- /dev/null +++ b/reps/1.txt @@ -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 \ No newline at end of file diff --git a/reps/2.txt b/reps/2.txt new file mode 100644 index 0000000..c84ad50 --- /dev/null +++ b/reps/2.txt @@ -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 \ No newline at end of file diff --git a/templates/eval.html b/templates/eval.html new file mode 100644 index 0000000..dd10f83 --- /dev/null +++ b/templates/eval.html @@ -0,0 +1,186 @@ + + + + + + + + +
+
+
+
+
+ + + + +
+
+

Game 1

+ +
+
+ +
+

Game 2

+ +
+
+ + + + + + + + + + +
+
+ +
+ Fun + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + + + + +
+ + + + + + \ No newline at end of file diff --git a/templates/play.html b/templates/play.html index 8de9ecb..09aca2b 100644 --- a/templates/play.html +++ b/templates/play.html @@ -5,71 +5,97 @@ CheerpJ test + +
+

Mario Game User Test

+
+
+ +
+
-
{{ py2htmlstr }} + -
- -
- + + + \ No newline at end of file