Merge branch 'main' of https://github.com/BigJIU/MarioWeb
This commit is contained in:
commit
dc6d1cdb61
1
.gitignore
vendored
1
.gitignore
vendored
@ -36,3 +36,4 @@ __pycache__/IDManager.cpython-39.pyc
|
|||||||
*.pyc
|
*.pyc
|
||||||
questionare.csv
|
questionare.csv
|
||||||
log.txt
|
log.txt
|
||||||
|
*.json
|
||||||
|
2
.idea/MarioWeb.iml
generated
2
.idea/MarioWeb.iml
generated
@ -5,7 +5,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="jdk" jdkName="VisMOO" jdkType="Python SDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TemplatesService">
|
<component name="TemplatesService">
|
||||||
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="VisMOO" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -7,5 +7,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="top.jfunc.json.fastjson" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
16
Mario-AI-Interface/levels/group0/lvl121.lvl
Normal file
16
Mario-AI-Interface/levels/group0/lvl121.lvl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------K------------------------------------------------------------------
|
||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------S------------SSSSSSSSSSSSSSSSS---------------------------SS--------------------------------------------------------------------------------
|
||||||
|
--------------------------------------------------------SS--SS--S-----------------------------------------------------------------------------------------g---------------------
|
||||||
|
--------------------------------------------------------SS--SSS-------------------------------------------------------------------------------S-----------%--%%%----------------
|
||||||
|
--------%%%%%%%%-------##-------o-----r-SSSo----------o-----SS--------------------------------------------------------------------------------S-----------|---g-SSS---------SSQo
|
||||||
|
---------||||||-oo----###---------------------------------------------#----------------------------------------y----------------------------------------r-|---|-----------------
|
||||||
|
---------||||||-S-----#TT-TT------------------------------------S----##--TT-TT-----------------o-------------------------------------------------%%%%%%%%%%%%%|-----------------
|
||||||
|
---------||||||-S-----#TT-TT----------------U-----------------------###--TT-TT----------------SS----------K---------------K---##------------------|||||||||||-|-----------------
|
||||||
|
------%%%%%%%%%%------#TT-##-----S--------SSSS--SSS----------------####--#####----------------%%-%%%%-------------2-----------#--------##---------||||||||%%|-|-----------------
|
||||||
|
-------||||||||---TT-####-----------------------------------------#####--##----#--------------||--||-------------------------##----#---##---------|||||||||||-|----------TT-----
|
||||||
|
-------||||||||---TT#####----------------------------------------######--------#--------------||--||---------##-------------###----#---##---------|||||||||||-|----------TT-----
|
||||||
|
-------||||||||---TT#####------------y-k-------k----------------########-------#-k------------||--||---------##------------####----#---##---------|||||||||||-|----------TT-----
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXX--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------X-XXX----------X|--||-------XXXX----X-XXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXX|||XX||-|-XXXXXXXXXXXXXXXX
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXX---XXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------X-XXX----------X|--||------XXXXU----X-XXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXX||XX||-|-XXXXXXXXXXXXXXXX
|
16
Mario-AI-Interface/levels/group0/lvl28.lvl
Normal file
16
Mario-AI-Interface/levels/group0/lvl28.lvl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-------------------------------------------------------------------------------------%------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------|--------------------------------------------------------Q---------------------------------
|
||||||
|
---------------------------------------------------SSSSSSS-SSSSS---------------------|----------------------------------------------------------SSSSSSSSSSSSSSSS----------------
|
||||||
|
-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------oo---SSS----------------------|------------------------------------------------------------------------------------------
|
||||||
|
--------%%%%%%%%-----SSSoooo--2%---------------------SSS----SSS----------------------|r---------------------------SSS-----------------------------------------------------------
|
||||||
|
---------||||||----------------|----------------------------------o-------------S---%%%%%%----------------------------------------------o-----U----------------------o----------
|
||||||
|
---------||||||-----------S-y--|--------------------------------------#--------------||||-------------------------------------------%%%%%%------%-----#-------------------------
|
||||||
|
---------||||||-------------@--|-------------#------------------------#--------------||||-------------SSSS----o----------------------||||-------|-----#-------------------------
|
||||||
|
------%%%%%%%%%%---------------|-------S----##-#S---------------------#--------------||||-----------%%%%%S----%%---------------------||||-------|-----#-------S-----------------
|
||||||
|
-------||||||||----------------|-----------###-#---------TT-----------#--------------||||------------|||------||---------#-----y-----||||-------|-----##--------TT--------------
|
||||||
|
-------||||||||----------------|----------####-#---------TT---------#-#--------------||||------------|||------||---------#-----#-----||||-------|-##--###-------TT--------------
|
||||||
|
-------||||||||--------k-------|---------#####-#---------TT-----#---#-#-------------g||||------------|||--gg--||------g--#-----#-----||||--y----|-##--###----k--TT----g---------
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--XXX-----%%--XXXXXXXXXXXXXXXXXX---|||--XX--||XXXXXXXXXXXXXXXX-----%%||--2XXX-XXXXXXXXX--XXXXXXXXXXXXXXXXXXXXX
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--XXX-----||--XXXXXXXXXXXXXXXXXX---|||--XX--||XXXXXXXXXXXXXXXX-----||||-XXXXX-XXXXXXXXX--XXXXXXXXXXXXXXXXXXXXX
|
16
Mario-AI-Interface/levels/group0/lvl54.lvl
Normal file
16
Mario-AI-Interface/levels/group0/lvl54.lvl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---------------------------------------------------------------------------------------------------------------------------------------------------%%---------------------------
|
||||||
|
---------------------------------------------------------------------------------------------------------------------------------------------------||---------------------------
|
||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------#||---------------------------
|
||||||
|
------------------------------------------------SSSSSSSSSSSSSSSS----------------SSSSSSSSSSSSSSSS-#-----------------------------------------------##||#----------SSSSSSSSSSSSSSSS
|
||||||
|
-------------------------------------------------SS----------------------------------------------------------------------------------------------##k#---------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------#----------------------%%%%---------------------###----------------------------
|
||||||
|
--------%%%%%%%%----------------SS----------So---------#---------------@SS-----------------------------------------------||-----------r--o------------r-----------USSSS---------
|
||||||
|
---------||||||---------------------------------------##-------------------------------------------------ooo-------------||----------%%%%----------###SS--S---------------------
|
||||||
|
---------||||||--------SSSS---------------------S----###----------------------------------S----------------------%%%%%%--||-----------||----------------------------------------
|
||||||
|
---------||||||-----------S---------------------S---####----------------------------------------------------------||||---||---r-------||----------#-----------------------------
|
||||||
|
------%%%%%%%%%%-------SS-S------------------------#####----------2----SS------------SSS----##--------------TT----||||-%%%%%%%%%------||-@S------##-TT-------------So-----------
|
||||||
|
-------||||||||--------------------------TT-------#######----------------------------------###------K--TT---TT----||||--|||||||-------||--------#---TT--------------------------
|
||||||
|
-------||||||||-------------TT-----------TT------########------------------------S--------####---------TT---TT----||||--|||||||%------||------------TT-------------------------#
|
||||||
|
-------||||||||---kk------k-TT--k-----g--TT----g-########-------ggg-----y-ggg------------#####----k----TT-k-TT----||||--||||||||-----y||-----ggg----TT----k---------ggg--------#
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXX--XXXXXX---XX--XXXXXXXXXXXXXXXX-X||||%%%%%%||||XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---XXXXXXXXXXXXX
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXX--XXXXXX---XX-XXXXXXXXXXXXXXXXX-X||||-||||-||||XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---XXXXXXXXXXXXX
|
16
Mario-AI-Interface/levels/group0/lvl72.lvl
Normal file
16
Mario-AI-Interface/levels/group0/lvl72.lvl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
----------------------oo--------------------------------------------------------------------------------------------------------------------------------------------o-----------
|
||||||
|
----------------------------------Q---------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
------------------------------------------------SSSSSSSS-----SS---------------------------o-----------------------------------------------------SSSSSSSSSSSSSSSS----------------
|
||||||
|
------------------------------------------------SSSS----------o--------------------------------------------------------------------------------------SSSSSS-SSS-----------------
|
||||||
|
------------------------o--------------g----------------------S--------------------------------------------------------------------------------------SSSSSS--SS-----------------
|
||||||
|
--------%%%%%%%%------------------QQQQQ-------Q@-------#------------------------------------------------------------------------------------------------SSS--S------------------
|
||||||
|
---------||||||-SoS-S---------------------------------##----------------------------------------------------------------------------------------------------------SSS-----------
|
||||||
|
---------||||||---------------------------------SS---###---------------S------------------------------------------------------------------------------------------SS------------
|
||||||
|
---------||||||---------------------------------S---####--------oooo--SSSSUR--S#----------------------------------------------------------------------o---ooo-----S-------------
|
||||||
|
------%%%%%%%%%%---------TT---TT-------------QQQ---######-------%---%%%-------##-------------------------------------------------------#----TT--------S---SSSSS-----------------
|
||||||
|
-------||||||||----------TT---TT------------------#######-------|----|-------##----------------#--------------------TT-----------------#----TT----------------------TT-TT-------
|
||||||
|
-------||||||||----------TT---TT-----------------########-------S----|------###----------------#--------------------TT-----------------#----TT----------------------TT-TT-------
|
||||||
|
-------||||||||-----##---TT---TT-g---g--------g-#########------------|-----#####---------------#--------------------TT-----------------#----TT-----------k--------k-TT-TT-------
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------X--%%%|----XXXXXX%-%%%%%%-------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-S--XXXXXXXXXXXXXXXXXXXXXXX
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---X--X---|-|----XXXXXXg--||||--------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX----XXXXXXXXXXXXXXXXXXXXXXX
|
16
Mario-AI-Interface/levels/group0/lvl73.lvl
Normal file
16
Mario-AI-Interface/levels/group0/lvl73.lvl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
---------------------------------------------------------------------------------------------------------------------------------------------------K----------------------------
|
||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
----------------------------S---SSSSSSSSSSSSSS--SSSSSSSSSSSSSSS-----------------------------------------------------------------SSSSSSSSSSSSSSSS--------------------------------
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------o-------------------------------------
|
||||||
|
------------------------------------------------------------------------------------------%%----------------------------------------------S-------------------------------------
|
||||||
|
--------%%%%%%%%--------------------------------------------------------------------------||--------------------------r-----------------------------------------o--------o------
|
||||||
|
---------||||||----------oS----------------------------------------------------------oo---||------------------------%%-----------------------------------o----------------------
|
||||||
|
---------||||||---------SSK---K-S-----##-------------------------------------------%%%%%%%||------------#-TT--------||-----------------%%%--------------------------------------
|
||||||
|
---------||||||---------SSS-----------##---------------------------g----------------|||||-||-----------##-TT--------||------------------|-----r---------------------------------
|
||||||
|
------%%%%%%%%%%----------------------#---------------------------------------------|||||-%%----------###-##--TT-QQQ|QSQ@S------%%%%%%%-|-----%%---------------------#----------
|
||||||
|
-------||||||||-------------------TT--##----------------------------------------TT--|||||-||----------###-----TT----|------------|||||--|-----||---------------------#----------
|
||||||
|
-------||||||||-------------------TT-##------------S------SS---------tt-----##--TT--|||||-||----------###-----TT----|------------|||||--|-----||---------------------#---TT-----
|
||||||
|
-------||||||||-------------------TT-###---------k-----#-------------tt----####-TT--|||||-||--------#-###-----TT-gggg--ggg-----k-|||||--|-----||-----K---------------#---TT-----
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX--------XXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXX--||||%-||----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-|%%%%%%%--2--||XXXXXXXXXXXXXXXXXX-XXXXXXXXXXX-X
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX--------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--|||||-||----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXg|-|||||------||XXXXXXXXXXXXXXXXXX-XXXXXXXXXXX-X
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16
Mario-AI-Interface/reps/lvl73.lvl
Normal file
16
Mario-AI-Interface/reps/lvl73.lvl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
---------------------------------------------------------------------------------------------------------------------------------------------------K----------------------------
|
||||||
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
----------------------------S---SSSSSSSSSSSSSS--SSSSSSSSSSSSSSS-----------------------------------------------------------------SSSSSSSSSSSSSSSS--------------------------------
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------o-------------------------------------
|
||||||
|
------------------------------------------------------------------------------------------%%----------------------------------------------S-------------------------------------
|
||||||
|
--------%%%%%%%%--------------------------------------------------------------------------||--------------------------r-----------------------------------------o--------o------
|
||||||
|
---------||||||----------oS----------------------------------------------------------oo---||------------------------%%-----------------------------------o----------------------
|
||||||
|
---------||||||---------SSK---K-S-----##-------------------------------------------%%%%%%%||------------#-TT--------||-----------------%%%--------------------------------------
|
||||||
|
---------||||||---------SSS-----------##---------------------------g----------------|||||-||-----------##-TT--------||------------------|-----r---------------------------------
|
||||||
|
------%%%%%%%%%%----------------------#---------------------------------------------|||||-%%----------###-##--TT-QQQ|QSQ@S------%%%%%%%-|-----%%---------------------#----------
|
||||||
|
-------||||||||-------------------TT--##----------------------------------------TT--|||||-||----------###-----TT----|------------|||||--|-----||---------------------#----------
|
||||||
|
-------||||||||-------------------TT-##------------S------SS---------tt-----##--TT--|||||-||----------###-----TT----|------------|||||--|-----||---------------------#---TT-----
|
||||||
|
-------||||||||-------------------TT-###---------k-----#-------------tt----####-TT--|||||-||--------#-###-----TT-gggg--ggg-----k-|||||--|-----||-----K---------------#---TT-----
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX--------XXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXX--||||%-||----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-|%%%%%%%--2--||XXXXXXXXXXXXXXXXXX-XXXXXXXXXXX-X
|
||||||
|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX--------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--|||||-||----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXg|-|||||------||XXXXXXXXXXXXXXXXXX-XXXXXXXXXXX-X
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import agents.HumanAgent;
|
import agents.HumanAgent;
|
||||||
import agents.ReplayAgent;
|
import agents.ReplayAgent;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import engine.core.MarioAgentEvent;
|
import engine.core.MarioAgentEvent;
|
||||||
import engine.core.MarioGame;
|
import engine.core.MarioGame;
|
||||||
import engine.core.MarioResult;
|
import engine.core.MarioResult;
|
||||||
@ -24,8 +25,10 @@ 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
|
||||||
// game = new MarioGame();
|
game = new MarioGame();
|
||||||
// playJavaGame();
|
//System.out.println(playJavaGame());
|
||||||
|
//replayGameMain("dfd40950-75e7-44fe-8833-371d32e525af_lvl144",10,20,5);
|
||||||
|
playJavaGame();
|
||||||
System.out.println("Java: Play Java Main Function Done");
|
System.out.println("Java: Play Java Main Function Done");
|
||||||
}
|
}
|
||||||
public static boolean initialGame(){
|
public static boolean initialGame(){
|
||||||
@ -37,21 +40,24 @@ public class Play {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] playJavaGame(){
|
public static String playJavaGame(){
|
||||||
|
|
||||||
game.setLives(3);
|
game.setLives(5);
|
||||||
String levelPath = "./levels/group0/lvl1.lvl"; // For local
|
String levelPath = "./levels/group0/lvl73.lvl"; // For local
|
||||||
String repPath = "./reps/f_l_sav.rep"; // For local
|
String repPath = "./reps/dfd40950-75e7-44fe-8833-371d32e525af_lvl73.rep"; // For local
|
||||||
//MarioGame.verbose = true;
|
//MarioGame.verbose = true;
|
||||||
//Play Game
|
//Play Game
|
||||||
MarioResult tmpResult = game.playGame(new HumanAgent(false),getLevel(levelPath), 10, repPath,30);
|
//MarioResult tmpResult = game.playGame(new HumanAgent(false),getLevel(levelPath), 10, repPath,30);
|
||||||
//Replay
|
//Replay
|
||||||
//MarioResult tmpResult = game.playGame(Replay.getRepAgentFromFile(repPath),getLevel(levelPath), 30, repPath,30);
|
MarioResult tmpResult = game.playGame(Replay.getRepAgentFromFile(repPath),getLevel(levelPath), 60, repPath,30);
|
||||||
return Replay.serializeAgentEvents(tmpResult.getAgentEvents());
|
//return Replay.serializeAgentEvents(tmpResult.getAgentEvents());
|
||||||
|
String jsonString = Replay.serializeGameResult(tmpResult);
|
||||||
|
|
||||||
|
|
||||||
|
return jsonString;//Replay.serializeAgentEvents(tmpResult.getAgentEvents());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] playGameMain(String levelName, int lives, boolean control,int time,int col){
|
public static MarioResult playGameMain(String levelName, int lives, boolean control,int time,int col){
|
||||||
|
|
||||||
String levelPath = String.format("/app/levels/%s.lvl", 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 repPath = String.format("/files/%s_sav.rep", levelName); // For web
|
||||||
@ -61,10 +67,12 @@ public class Play {
|
|||||||
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);
|
||||||
|
|
||||||
return Replay.serializeAgentEvents(tmpResult.getAgentEvents());
|
//return Replay.serializeAgentEvents(tmpResult.getAgentEvents());
|
||||||
|
//return Replay.serializeGameResult(tmpResult);
|
||||||
|
return tmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] playGameMain(String levelName){
|
public static MarioResult playGameMain(String levelName){
|
||||||
return playGameMain(levelName, 5, false,30,16);
|
return playGameMain(levelName, 5, false,30,16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,4 +89,15 @@ public class Play {
|
|||||||
public static void stopReplay(){
|
public static void stopReplay(){
|
||||||
game.stopGame();
|
game.stopGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] serializeActionFromJson(String jsonString){
|
||||||
|
MarioResult marioResult= JSON.parseObject(jsonString,MarioResult.class);
|
||||||
|
ArrayList<MarioAgentEvent> events = marioResult.getAgentEvents();
|
||||||
|
byte[] content = new byte[events.size()];
|
||||||
|
for (int i = 0; i < events.size(); i++) {
|
||||||
|
boolean[] action = events.get(i).getActions();
|
||||||
|
content[i] = Replay.serializeAction(action);
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,14 @@ import java.util.ArrayList;
|
|||||||
import engine.helper.EventType;
|
import engine.helper.EventType;
|
||||||
import engine.helper.GameStatus;
|
import engine.helper.GameStatus;
|
||||||
import engine.helper.SpriteType;
|
import engine.helper.SpriteType;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
public class MarioResult {
|
public class MarioResult {
|
||||||
private MarioWorld world;
|
private MarioWorld world;
|
||||||
private ArrayList<MarioEvent> gameEvents;
|
private ArrayList<MarioEvent> gameEvents;
|
||||||
private ArrayList<MarioAgentEvent> agentEvents;
|
private ArrayList<MarioAgentEvent> agentEvents;
|
||||||
|
public MarioResult(){}
|
||||||
/**
|
/**
|
||||||
* Create a mario result object
|
* Create a mario result object
|
||||||
*
|
*
|
||||||
@ -18,6 +20,7 @@ public class MarioResult {
|
|||||||
* @param gameEvents the events that happens in the playthrough of the game
|
* @param gameEvents the events that happens in the playthrough of the game
|
||||||
* @param agentEvents the events that happens in the playthrough of the game
|
* @param agentEvents the events that happens in the playthrough of the game
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public MarioResult(MarioWorld world, ArrayList<MarioEvent> gameEvents, ArrayList<MarioAgentEvent> agentEvents) {
|
public MarioResult(MarioWorld world, ArrayList<MarioEvent> gameEvents, ArrayList<MarioAgentEvent> agentEvents) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.gameEvents = gameEvents;
|
this.gameEvents = gameEvents;
|
||||||
|
@ -43,8 +43,8 @@ public class Assets {
|
|||||||
|
|
||||||
private static Image getImage(GraphicsConfiguration gc, String imageName) throws IOException {
|
private static Image getImage(GraphicsConfiguration gc, String imageName) throws IOException {
|
||||||
//FIXME: web/local
|
//FIXME: web/local
|
||||||
//File file = new File(System.getProperty("user.dir") + "/img/" + imageName); // Local test
|
File file = new File(System.getProperty("user.dir") + "/img/" + imageName); // Local test
|
||||||
File file = new File("/app/img/" + imageName); // For web
|
//File file = new File("/app/img/" + imageName); // For web
|
||||||
BufferedImage source = ImageIO.read(file);
|
BufferedImage source = ImageIO.read(file);
|
||||||
Image image = gc.createCompatibleImage(source.getWidth(), source.getHeight(), Transparency.BITMASK);
|
Image image = gc.createCompatibleImage(source.getWidth(), source.getHeight(), Transparency.BITMASK);
|
||||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
package engine.helper;
|
package engine.helper;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import agents.ReplayAgent;
|
import agents.ReplayAgent;
|
||||||
import engine.core.MarioAgentEvent;
|
import engine.core.MarioAgentEvent;
|
||||||
|
import engine.core.MarioResult;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -34,6 +39,11 @@ public class Replay {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String serializeGameResult(MarioResult marioResult) {
|
||||||
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(marioResult);
|
||||||
|
return jsonObject.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
public static void saveReplay(String filepath, ArrayList<MarioAgentEvent> events) {
|
public static void saveReplay(String filepath, ArrayList<MarioAgentEvent> events) {
|
||||||
try {
|
try {
|
||||||
byte[] content = serializeAgentEvents(events);
|
byte[] content = serializeAgentEvents(events);
|
||||||
@ -61,4 +71,5 @@ public class Replay {
|
|||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
42
localData/dataCompare.py
Normal file
42
localData/dataCompare.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
with open('questionare.csv', newline='') as csvfile:
|
||||||
|
questionRow = csv.reader(csvfile, delimiter=' ', quotechar='|')
|
||||||
|
id_dict_q = {}
|
||||||
|
id_dict_a = {}
|
||||||
|
|
||||||
|
for question in questionRow:
|
||||||
|
questionarray = question[0].split(',')
|
||||||
|
ans = 'Null'
|
||||||
|
if questionarray[3] == 'A':
|
||||||
|
ans = 'r'
|
||||||
|
elif questionarray[3] == 'B':
|
||||||
|
ans = 'k'
|
||||||
|
elif questionarray[3] == 'C':
|
||||||
|
ans = 'c'
|
||||||
|
id_dict_q[questionarray[0]] = ans
|
||||||
|
|
||||||
|
with open('annotation2.csv', newline='') as csvfile:
|
||||||
|
annotationRow = csv.reader(csvfile, delimiter=' ', quotechar='|')
|
||||||
|
|
||||||
|
for annotation in annotationRow:
|
||||||
|
annotationarray = annotation[0].split(',')
|
||||||
|
id_dict_a[annotationarray[0]] = [annotationarray[1], annotationarray[2], annotationarray[3]]
|
||||||
|
|
||||||
|
with open('rank.csv', 'w', newline='') as csvfile:
|
||||||
|
spamwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
||||||
|
for id in id_dict_q.keys():
|
||||||
|
ans = "Null"
|
||||||
|
if id_dict_q[id] == 'c':
|
||||||
|
ans = 'Collector '
|
||||||
|
elif id_dict_q[id] == 'k':
|
||||||
|
ans = 'Killer '
|
||||||
|
elif id_dict_q[id] == 'r':
|
||||||
|
ans = 'Runner '
|
||||||
|
if id in id_dict_a.keys():
|
||||||
|
rank = id_dict_a[id].index(id_dict_q[id])
|
||||||
|
spamwriter.writerow([id, ans, rank+1, id_dict_a[id]])
|
||||||
|
else:
|
||||||
|
spamwriter.writerow([id, ans, 0, 'Null'])
|
48
main.py
48
main.py
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
@ -17,6 +18,7 @@ app = Flask(__name__, static_folder='')
|
|||||||
idm = idManager()
|
idm = idManager()
|
||||||
app.secret_key = 'asdfasdfawefaewvaf'
|
app.secret_key = 'asdfasdfawefaewvaf'
|
||||||
replayDataPath = "reps/"
|
replayDataPath = "reps/"
|
||||||
|
jsonDataPath = "jsons/"
|
||||||
evalDataPath = "evals/"
|
evalDataPath = "evals/"
|
||||||
|
|
||||||
questionarePath = "data/questionare.csv"
|
questionarePath = "data/questionare.csv"
|
||||||
@ -102,8 +104,9 @@ def gameplay(id):
|
|||||||
def getJSONData(id):
|
def getJSONData(id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print("POST Game")
|
print("POST Game")
|
||||||
resultList = list(request.form)[0].split(",")
|
resultList = list(request.form)[0].split("@@@")
|
||||||
saveFile(replayDataPath, id + "_" + resultList[0][:-2], resultList[1:])
|
saveJsonFile(jsonDataPath, id + "_" + resultList[0], resultList[1])
|
||||||
|
saveRepFile(replayDataPath, id + "_" + resultList[0], resultList[1])
|
||||||
return "return!"
|
return "return!"
|
||||||
|
|
||||||
|
|
||||||
@ -156,8 +159,9 @@ def gameplay2(id):
|
|||||||
def getJSONData2(id):
|
def getJSONData2(id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print("POST Game")
|
print("POST Game")
|
||||||
resultList = list(request.form)[0].split(",")
|
resultList = list(request.form)[0].split("@@@")
|
||||||
saveFile(replayDataPath, id+"_" + resultList[0][:-2], resultList[1:])
|
saveJsonFile(jsonDataPath, id + "_" + resultList[0], resultList[1])
|
||||||
|
saveRepFile(replayDataPath, id + "_" + resultList[0], resultList[1])
|
||||||
return "return!"
|
return "return!"
|
||||||
|
|
||||||
|
|
||||||
@ -219,14 +223,42 @@ def over():
|
|||||||
# ""])
|
# ""])
|
||||||
|
|
||||||
# return redirect(url_for("over", id=id))
|
# return redirect(url_for("over", id=id))
|
||||||
def saveFile(path, filename, content):
|
def saveRepFile(path, filename, content):
|
||||||
cp = list(map(int, content))
|
o_dict = json.loads(content)
|
||||||
|
action_dict = o_dict["elementData1"][1:]
|
||||||
|
actionList = []
|
||||||
|
for actions in action_dict:
|
||||||
|
try:
|
||||||
|
alist = actions["actions0"]
|
||||||
|
actionsInput = [alist["0"], alist["1"], alist["2"], alist["3"], alist["4"], alist["5"], alist["6"]]
|
||||||
|
actionList.append(serializeAction(actionsInput))
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
|
||||||
|
cp = list(map(int, actionList))
|
||||||
file_dir = os.path.join(os.getcwd(), path)
|
file_dir = os.path.join(os.getcwd(), path)
|
||||||
file_path = os.path.join(file_dir, filename + ".rep")
|
file_path = os.path.join(file_dir, filename + ".rep")
|
||||||
with open(file_path, 'wb') as f:
|
with open(file_path, 'wb') as f:
|
||||||
f.write(b''.join(struct.pack('B', c) for c in cp))
|
f.write(b''.join(struct.pack('B', c) for c in cp))
|
||||||
|
|
||||||
|
|
||||||
|
def serializeAction(actions):
|
||||||
|
res = 0
|
||||||
|
for i in range(1, 6):
|
||||||
|
if actions[i]:
|
||||||
|
tmp = 1 << (i-1)
|
||||||
|
res += tmp
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def saveJsonFile(path, filename, content):
|
||||||
|
file_dir = os.path.join(os.getcwd(), path)
|
||||||
|
file_path = os.path.join(file_dir, filename + ".json")
|
||||||
|
with open(file_path, 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0', port=80, debug=False)
|
#saveRepFile(replayDataPath, "null_test.rep", testJson)
|
||||||
# app.run()
|
# app.run(host='0.0.0.0', port=80, debug=False)
|
||||||
|
app.run()
|
||||||
|
@ -332,18 +332,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cheerpjCreateDisplay(500, 500, divElement);
|
cheerpjCreateDisplay(500, 500, divElement);
|
||||||
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
||||||
|
|
||||||
GameLoad().then(function () {
|
GameLoad().then(function () {
|
||||||
|
|
||||||
$("#windowshow:visible").hide();
|
$("#windowshow:visible").hide();
|
||||||
{#console.log("Cheerpj Initialize Succeed!", control);#}
|
{#console.log("Cheerpj Initialize Succeed!", control);#}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("loading").style.visibility = 'hidden';
|
document.getElementById("loading").style.visibility = 'hidden';
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -370,9 +364,6 @@
|
|||||||
}else {
|
}else {
|
||||||
$("#top:hidden").show();
|
$("#top:hidden").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -293,15 +293,15 @@ function validateForm() {
|
|||||||
return true; // Allow form submission
|
return true; // Allow form submission
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<form onsubmit="return validateForm()" action="window.location.href = '/question';">
|
|
||||||
|
|
||||||
<input type="checkbox" id="privacyPolicyCheckbox" name="privacyPolicyCheckbox" required>
|
<input type="checkbox" id="privacyPolicyCheckbox" name="privacyPolicyCheckbox" required>
|
||||||
<label for="privacyPolicyCheckbox">I agree to the <a href="/privacy" style="cursor:pointer;" target="_blank">privacy policy</a></label>
|
<label for="privacyPolicyCheckbox">I agree to the <a href="/privacy" style="cursor:pointer;" target="_blank">privacy policy</a></label>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<button class="cirButton" type="submit"><b> Start!</b> </button>
|
<button class="cirButton" type="submit" onclick="
|
||||||
|
if (validateForm()) { window.location.href = '/question'; }
|
||||||
|
"><b> Start!</b> </button>
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,13 +26,19 @@ function PlayLevel(level,control){
|
|||||||
console.log("HTML:Start PlayLevel cjCall")
|
console.log("HTML:Start PlayLevel cjCall")
|
||||||
var returnVal = cjCall("Play", "playGameMain", level, 5, control,30,16);
|
var returnVal = cjCall("Play", "playGameMain", level, 5, control,30,16);
|
||||||
return returnVal.then(function(){
|
return returnVal.then(function(){
|
||||||
|
stringVal = toJSON(returnVal.value['agentEvents2'])
|
||||||
console.log("the return val is ready");
|
console.log("the return val is ready");
|
||||||
console.log(returnVal.value);
|
console.log(stringVal);
|
||||||
PostToServer(window.location.href+"/data",level+returnVal.value);
|
PostToServer(window.location.href+"/data",level+"@@@"+stringVal);
|
||||||
//Array.from()
|
//Array.from()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toJSON(returnVal)
|
||||||
|
{
|
||||||
|
return JSON.stringify(returnVal)
|
||||||
|
}
|
||||||
|
|
||||||
function GameOver(){
|
function GameOver(){
|
||||||
if(alert("Game Over!")){
|
if(alert("Game Over!")){
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user