Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
c03c6dac91
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
|
||||||
|
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
main.py
|
@ -98,6 +98,8 @@ class idManager():
|
|||||||
def setTimes(self, ip):
|
def setTimes(self, ip):
|
||||||
self.ip_time[ip] = 0
|
self.ip_time[ip] = 0
|
||||||
|
|
||||||
|
# 1 For next step
|
||||||
|
# 0 For not next step
|
||||||
def getTimes(self, ip):
|
def getTimes(self, ip):
|
||||||
|
|
||||||
if ip not in self.ip_time.keys():
|
if ip not in self.ip_time.keys():
|
||||||
|
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'])
|
85
main.py
85
main.py
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
@ -17,18 +18,22 @@ 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"
|
||||||
annotationPath = "data/annotation.csv"
|
annotationPath = "data/annotation.csv"
|
||||||
annotationPath2 = "data/annotation2.csv"
|
annotationPath2 = "data/annotation2.csv"
|
||||||
|
feedbackPath = "data/feedback.csv"
|
||||||
|
|
||||||
#id=idm.getId(request.remote_addr)
|
|
||||||
|
# id=idm.getId(request.remote_addr)
|
||||||
def getId():
|
def getId():
|
||||||
if 'name' not in session:
|
if 'name' not in session:
|
||||||
session['name'] = str(uuid.uuid4())
|
session['name'] = str(uuid.uuid4())
|
||||||
return session['name']
|
return session['name']
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def gamewelcome():
|
def gamewelcome():
|
||||||
ip = getId()
|
ip = getId()
|
||||||
@ -41,6 +46,11 @@ def gamequestion():
|
|||||||
return render_template('GameQuestion.html')
|
return render_template('GameQuestion.html')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/privacy')
|
||||||
|
def privacypage():
|
||||||
|
return render_template('Privacy.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/result', methods=['POST', 'GET'])
|
@app.route('/result', methods=['POST', 'GET'])
|
||||||
def gamepreplay():
|
def gamepreplay():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@ -55,8 +65,8 @@ def gamepreplay():
|
|||||||
result.get("playedp"),
|
result.get("playedp"),
|
||||||
result.get("gamestyle"),
|
result.get("gamestyle"),
|
||||||
result.get("frequency"),
|
result.get("frequency"),
|
||||||
result.get("age")+result.get("myAge"),
|
result.get("age") + result.get("myAge"),
|
||||||
result.get("gender")+result.get("myGender"),
|
result.get("gender") + result.get("myGender"),
|
||||||
""])
|
""])
|
||||||
idm.setControl(cid, result.get("control"))
|
idm.setControl(cid, result.get("control"))
|
||||||
print(result.get("gamestyle"))
|
print(result.get("gamestyle"))
|
||||||
@ -67,7 +77,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),maxT=idm.tutorialMax,
|
return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),
|
||||||
|
maxT=idm.tutorialMax,
|
||||||
control=idm.getControl(id))
|
control=idm.getControl(id))
|
||||||
|
|
||||||
|
|
||||||
@ -85,6 +96,7 @@ def gametutorialdata(id):
|
|||||||
def gameplay(id):
|
def gameplay(id):
|
||||||
gamelevels = idm.getLevels(id)
|
gamelevels = idm.getLevels(id)
|
||||||
return render_template('GamePlay.html', gamelevels=gamelevels, control=idm.getControl(id), levelNum=2,
|
return render_template('GamePlay.html', gamelevels=gamelevels, control=idm.getControl(id), levelNum=2,
|
||||||
|
times=idm.getTimes(id),
|
||||||
jump="/annotation")
|
jump="/annotation")
|
||||||
|
|
||||||
|
|
||||||
@ -92,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!"
|
||||||
|
|
||||||
|
|
||||||
@ -146,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!"
|
||||||
|
|
||||||
|
|
||||||
@ -174,11 +188,8 @@ def gameanno2(id):
|
|||||||
def gameannoresult2(id):
|
def gameannoresult2(id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print("result: " + id)
|
print("result: " + id)
|
||||||
|
|
||||||
resultList = list(request.form)[0].split(",")
|
resultList = list(request.form)[0].split(",")
|
||||||
levelList = idm.getRecent(getId())
|
levelList = idm.getRecent(getId())
|
||||||
|
|
||||||
|
|
||||||
idm.write_csv(annotationPath2,
|
idm.write_csv(annotationPath2,
|
||||||
[getId(), resultList[0], resultList[1], resultList[2], levelList[0], levelList[1],
|
[getId(), resultList[0], resultList[1], resultList[2], levelList[0], levelList[1],
|
||||||
levelList[2],
|
levelList[2],
|
||||||
@ -191,21 +202,63 @@ def gameannoresult2(id):
|
|||||||
return redirect(url_for("gameplay2", id=id))
|
return redirect(url_for("gameplay2", id=id))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/gameover")
|
@app.route("/gameover", methods=['POST', 'GET'])
|
||||||
def over():
|
def over():
|
||||||
finish = idm.getTimes(getId())
|
finish = idm.getTimes(getId())
|
||||||
|
if request.method == 'POST':
|
||||||
|
resultList = list(request.form)[0].split(",")
|
||||||
|
idm.write_csv(feedbackPath,
|
||||||
|
[getId(), resultList[0],
|
||||||
|
""])
|
||||||
|
|
||||||
return render_template("GameOver.html", finish=1, stage=1)
|
return render_template("GameOver.html", finish=1, stage=1)
|
||||||
|
|
||||||
|
|
||||||
def saveFile(path, filename, content):
|
# @app.route('/feedback', methods=['POST'])
|
||||||
cp = list(map(int, content))
|
# def overa():
|
||||||
|
# if request.method == 'POST':
|
||||||
|
# resultList = list(request.form)[0].split(",")
|
||||||
|
# idm.write_csv(feedbackPath,
|
||||||
|
# [getId(), resultList[0],
|
||||||
|
# ""])
|
||||||
|
|
||||||
|
# return redirect(url_for("over", id=id))
|
||||||
|
def saveRepFile(path, filename, 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()
|
||||||
|
218
newMain.py
Normal file
218
newMain.py
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
import struct
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from IDManager import idManager
|
||||||
|
|
||||||
|
from flask import Flask, render_template, request, redirect, url_for, session
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# 设置logging模块
|
||||||
|
logging.basicConfig(filename='log.txt', level=logging.DEBUG)
|
||||||
|
# 将print输出重定向到logging模块
|
||||||
|
print = logging.getLogger().info
|
||||||
|
|
||||||
|
app = Flask(__name__, static_folder='')
|
||||||
|
idm = idManager()
|
||||||
|
app.secret_key = 'asdfasdfawefaewvaf'
|
||||||
|
replayDataPath = "reps/"
|
||||||
|
evalDataPath = "evals/"
|
||||||
|
|
||||||
|
questionarePath = "data/questionare.csv"
|
||||||
|
annotationPath = "data/annotation.csv"
|
||||||
|
annotationPath2 = "data/annotation2.csv"
|
||||||
|
|
||||||
|
|
||||||
|
# id=idm.getId(request.remote_addr)
|
||||||
|
def getId():
|
||||||
|
if 'name' not in session:
|
||||||
|
session['name'] = str(uuid.uuid4())
|
||||||
|
return session['name']
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def gameinit():
|
||||||
|
index = getId()
|
||||||
|
cid = idm.iniId(index)
|
||||||
|
return redirect(url_for('Main.html', id=index))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/<id>')
|
||||||
|
def gamewelcome(index):
|
||||||
|
return render_template('Main.html', id=index)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/question')
|
||||||
|
def gamequestion():
|
||||||
|
return render_template('GameQuestion.html')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/result', methods=['POST', 'GET'])
|
||||||
|
def gamepreplay():
|
||||||
|
if request.method == 'POST':
|
||||||
|
result = request.form
|
||||||
|
# ip = request.remote_addr
|
||||||
|
ip = getId()
|
||||||
|
cid = idm.iniId(ip)
|
||||||
|
# Save the result to questionare
|
||||||
|
idm.write_csv(questionarePath,
|
||||||
|
[cid,
|
||||||
|
result.get("playeds"),
|
||||||
|
result.get("playedp"),
|
||||||
|
result.get("gamestyle"),
|
||||||
|
result.get("frequency"),
|
||||||
|
result.get("age") + result.get("myAge"),
|
||||||
|
result.get("gender") + result.get("myGender"),
|
||||||
|
""])
|
||||||
|
idm.setControl(cid, result.get("control"))
|
||||||
|
print(result.get("gamestyle"))
|
||||||
|
return redirect(url_for('gametutorial', id=cid))
|
||||||
|
# debug use:
|
||||||
|
# return redirect(url_for('gameanno2', id=cid))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gametutorial/<id>')
|
||||||
|
def gametutorial(id):
|
||||||
|
return render_template('GameTutorial.html', tutorial=idm.addTutorial(id), next=idm.hasNextTutorial(id),
|
||||||
|
maxT=idm.tutorialMax,
|
||||||
|
control=idm.getControl(id))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/again')
|
||||||
|
def gamepreplayAgain():
|
||||||
|
return redirect(url_for('gameplay', id=getId()))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gametutorial/<id>/data')
|
||||||
|
def gametutorialdata(id):
|
||||||
|
return redirect(url_for('gameplay', id=id))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gameplay/<id>')
|
||||||
|
def gameplay(id):
|
||||||
|
gamelevels = idm.getLevels(id)
|
||||||
|
return render_template('GamePlay.html', gamelevels=gamelevels, control=idm.getControl(id), levelNum=2,
|
||||||
|
jump="/annotation")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gameplay/<id>/data', methods=['POST'])
|
||||||
|
def getJSONData(id):
|
||||||
|
if request.method == 'POST':
|
||||||
|
print("POST Game")
|
||||||
|
resultList = list(request.form)[0].split(",")
|
||||||
|
saveFile(replayDataPath, id + resultList[0][:-2], resultList[1:])
|
||||||
|
return "return!"
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/annotation')
|
||||||
|
def gamepreanno():
|
||||||
|
return redirect(url_for('gameanno', id=getId()))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/annotation/<id>')
|
||||||
|
def gameanno(id):
|
||||||
|
if (id != "radioresult"):
|
||||||
|
print("anno " + id)
|
||||||
|
gamelevels = idm.getRecent(id)
|
||||||
|
|
||||||
|
level1 = "lvl" + str(gamelevels[0])
|
||||||
|
level2 = "lvl" + str(gamelevels[1])
|
||||||
|
return render_template('GameAnnotation.html', level1=level1, level2=level2)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/annotation/radioresult', methods=['POST'])
|
||||||
|
def getRadioData():
|
||||||
|
ip = getId()
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
print("POST Eval")
|
||||||
|
result = request.form
|
||||||
|
ipRecent = idm.getRecent(ip)
|
||||||
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gameplay2')
|
||||||
|
def gamepreplay2():
|
||||||
|
return redirect(url_for('gameplay2', id=getId()))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gameplay2/<id>')
|
||||||
|
def gameplay2(id):
|
||||||
|
gamelevels = idm.getTypeLevels(id)
|
||||||
|
return render_template('GamePlay.html', gamelevels=gamelevels, control=idm.getControl(id), levelNum=3,
|
||||||
|
jump="/annotation2")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gameplay2/<id>/data', methods=['POST'])
|
||||||
|
def getJSONData2(id):
|
||||||
|
if request.method == 'POST':
|
||||||
|
print("POST Game")
|
||||||
|
resultList = list(request.form)[0].split(",")
|
||||||
|
saveFile(replayDataPath, id + resultList[0][:-2], resultList[1:])
|
||||||
|
return "return!"
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/annotation2')
|
||||||
|
def gamepreanno2():
|
||||||
|
return redirect(url_for('gameanno2', id=getId()))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/annotation2/<id>')
|
||||||
|
def gameanno2(id):
|
||||||
|
if id != "result":
|
||||||
|
print("anno " + id)
|
||||||
|
gamelevels = idm.getRecent(id)
|
||||||
|
# gamelevels = idm.getTypeLevels(id)
|
||||||
|
level1 = gamelevels[0]
|
||||||
|
level2 = gamelevels[1]
|
||||||
|
level3 = gamelevels[2]
|
||||||
|
return render_template('GameAnnotation2.html', level1=level1, level2=level2, level3=level3)
|
||||||
|
else:
|
||||||
|
print(id)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/annotation2/<id>/result', methods=['POST'])
|
||||||
|
def gameannoresult2(id):
|
||||||
|
if request.method == 'POST':
|
||||||
|
print("result: " + id)
|
||||||
|
|
||||||
|
resultList = list(request.form)[0].split(",")
|
||||||
|
levelList = idm.getRecent(getId())
|
||||||
|
|
||||||
|
idm.write_csv(annotationPath2,
|
||||||
|
[getId(), resultList[0], resultList[1], resultList[2], levelList[0], levelList[1],
|
||||||
|
levelList[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")
|
||||||
|
def over():
|
||||||
|
finish = idm.getTimes(getId())
|
||||||
|
|
||||||
|
return render_template("GameOver.html", finish=1, stage=1)
|
||||||
|
|
||||||
|
|
||||||
|
def saveFile(path, filename, content):
|
||||||
|
cp = list(map(int, content))
|
||||||
|
file_dir = os.path.join(os.getcwd(), path)
|
||||||
|
file_path = os.path.join(file_dir, filename + ".rep")
|
||||||
|
with open(file_path, 'wb') as f:
|
||||||
|
f.write(b''.join(struct.pack('B', c) for c in cp))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=80, debug=False)
|
||||||
|
# app.run()
|
@ -429,8 +429,8 @@
|
|||||||
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="col-md-10 column">
|
<div class="col-md-10 column">
|
||||||
<br><br>
|
<div class="col-xl-3 justify-content-center" style="margin: auto" align="center"><a href="/privacy" style="cursor:pointer; color: white;" target="_blank">Privacy Policy</a> </div>
|
||||||
<p class="m-0 text-center text-white">Copyright © Jialin Liu</p>
|
<div class="col-xl-3 justify-content-center text-white" style="margin: auto" align="center">Copyright © Jialin Liu</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -396,8 +396,8 @@
|
|||||||
<div class="row clearfix">
|
<div class="row clearfix">
|
||||||
|
|
||||||
<div class="col-md-10 column">
|
<div class="col-md-10 column">
|
||||||
<br><br>
|
<div class="col-xl-3 justify-content-center" style="margin: auto" align="center"><a href="/privacy" style="cursor:pointer; color: white;" target="_blank">Privacy Policy</a> </div>
|
||||||
<p class="m-0 text-center text-white">Copyright © Jialin Liu</p>
|
<div class="col-xl-3 justify-content-center text-white" style="margin: auto" align="center">Copyright © Jialin Liu</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<script
|
<script
|
||||||
id="allow-copy_script">(function t() { var t = !1; document.addEventListener("allow_copy", (function (n) { t = n.detail.unlock })); var n = ["copy", "cut", "contextmenu", "selectstart", "mousedown", "mouseup", "mousemove", "keydown", "keypress", "keyup"], e = function (n) { t && (n.stopPropagation(), n.stopImmediatePropagation && n.stopImmediatePropagation()) }; n.forEach((function (t) { document.documentElement.addEventListener(t, e, { capture: !0 }) })) })()</script>
|
id="allow-copy_script">(function t() { var t = !1; document.addEventListener("allow_copy", (function (n) { t = n.detail.unlock })); var n = ["copy", "cut", "contextmenu", "selectstart", "mousedown", "mouseup", "mousemove", "keydown", "keypress", "keyup"], e = function (n) { t && (n.stopPropagation(), n.stopImmediatePropagation && n.stopImmediatePropagation()) }; n.forEach((function (t) { document.documentElement.addEventListener(t, e, { capture: !0 }) })) })()</script>
|
||||||
|
<script src="../templates/Web/jquery.min.js"></script>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
|
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
|
||||||
@ -173,7 +173,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<section id="Over">
|
<section id="Over">
|
||||||
<div class="container">
|
<div class="container col-xl-7 align-content-center" style="margin: auto">
|
||||||
<h1>
|
<h1>
|
||||||
<i class="icon-chevron-down"></i> Thank You For Playing!!!
|
<i class="icon-chevron-down"></i> Thank You For Playing!!!
|
||||||
</h1>
|
</h1>
|
||||||
@ -186,6 +186,23 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<button id="hideButton" class="cirButton">No</button>
|
<button id="hideButton" class="cirButton">No</button>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<form id="ajaxform">
|
||||||
|
<h3>Do you have any feedback?</h3>
|
||||||
|
<br>
|
||||||
|
<textarea
|
||||||
|
id="message"
|
||||||
|
cols="60"
|
||||||
|
rows="10"
|
||||||
|
placeholder="Enter your message"
|
||||||
|
|
||||||
|
></textarea>
|
||||||
|
<br><br>
|
||||||
|
<input type="submit" value="Submit" class="cirButton" onclick="submit_it()">
|
||||||
|
</form>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("hideButton").addEventListener("click", function () {
|
document.getElementById("hideButton").addEventListener("click", function () {
|
||||||
var buttons = document.getElementsByTagName("button");
|
var buttons = document.getElementsByTagName("button");
|
||||||
@ -201,14 +218,47 @@
|
|||||||
// var newWindow = window.open("", "_self");
|
// var newWindow = window.open("", "_self");
|
||||||
// newWindow.close();
|
// newWindow.close();
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
function submit_it() {
|
||||||
|
$("#ajaxform").hide()
|
||||||
|
$("#ajaxform").submit(function(e)
|
||||||
|
{
|
||||||
|
|
||||||
|
var postData = JSON.stringify($("#message").val());
|
||||||
|
{#var formURL = $(this).attr("action");#}
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
url : "gameover",
|
||||||
|
type: "POST",
|
||||||
|
data : postData,
|
||||||
|
success:function(data)
|
||||||
|
{
|
||||||
|
|
||||||
|
//data: return data from server
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
e.preventDefault(); //STOP default action
|
||||||
|
{#e.unbind(); //unbind. to stop multiple form submit.#}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-xl-8" style="margin:auto;">
|
||||||
|
<img src="../templates/Web/sustc.png" height="200">
|
||||||
|
<img src="../templates/Web/Malta.png" height="200">
|
||||||
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<div class="col-xl-7 justify-content-between align-content-center" style="margin: auto">This page is created by <a href="https://github.com/BigJIU" target="_blank">Haocheng Du</a>, <a href="https://doveliyuchen.github.io" target="_blank">Yuchen Li</a>; game content is generated by <b>AI </b>designed by<a href="https://github.com/PneuC" target="_blank"> Ziqi Wang</a>.<br> This project is supported by <a href="http://www.liujialin.tech/" target="_blank">Dr. Liu</a> and <a href="https://yannakakis.net/" target="_blank">Prof. Yannakakis</a>.</div>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Footer mx-auto -->
|
<!-- Footer mx-auto -->
|
||||||
@ -217,8 +267,8 @@
|
|||||||
<div class="row clearfix">
|
<div class="row clearfix">
|
||||||
|
|
||||||
<div class="col-md-10 column">
|
<div class="col-md-10 column">
|
||||||
<br><br>
|
<div class="col-xl-3 justify-content-center" style="margin: auto" align="center"><a href="/privacy" style="cursor:pointer; color: white;" target="_blank">Privacy Policy</a> </div>
|
||||||
<p class="m-0 text-center text-white">Copyright © Jialin Liu</p>
|
<div class="col-xl-3 justify-content-center text-white" style="margin: auto" align="center">Copyright © Jialin Liu</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -227,7 +277,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<!-- Bootstrap core JavaScript -->
|
<!-- Bootstrap core JavaScript -->
|
||||||
<script src="../templates/Web/jquery.min.js"></script>
|
|
||||||
<script src="../templates/Web/bootstrap.bundle.min.js"></script>
|
<script src="../templates/Web/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
<!-- Plugin JavaScript -->
|
<!-- Plugin JavaScript -->
|
||||||
|
@ -187,6 +187,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<h3 id="Head">Level A</h3>
|
<h3 id="Head">Level A</h3>
|
||||||
|
<p id="leftLevel">There are 7 levels left</p>
|
||||||
<p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p>
|
<p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p>
|
||||||
</div>
|
</div>
|
||||||
<div align="center" id="GameWindow">
|
<div align="center" id="GameWindow">
|
||||||
@ -201,6 +202,7 @@
|
|||||||
cheerpjInit();
|
cheerpjInit();
|
||||||
var divElement = document.getElementById("GameWindow");
|
var divElement = document.getElementById("GameWindow");
|
||||||
var title = document.getElementById("Head");
|
var title = document.getElementById("Head");
|
||||||
|
var leftLevel = document.getElementById("leftLevel")
|
||||||
var levelNum = Number("{{levelNum}}")
|
var levelNum = Number("{{levelNum}}")
|
||||||
var levels = getLevels("{{gamelevels}}", levelNum);
|
var levels = getLevels("{{gamelevels}}", levelNum);
|
||||||
var levelNames = ["Level A", "Level B", "Level C", "Level D"];
|
var levelNames = ["Level A", "Level B", "Level C", "Level D"];
|
||||||
@ -215,8 +217,19 @@
|
|||||||
console.log("GameLoad Initialize Succeed!");
|
console.log("GameLoad Initialize Succeed!");
|
||||||
document.getElementById("loading").style.visibility = 'hidden';
|
document.getElementById("loading").style.visibility = 'hidden';
|
||||||
})
|
})
|
||||||
|
leftNum = 0;
|
||||||
|
|
||||||
|
if(levelNum === 3) {leftNum = 2}
|
||||||
|
else {
|
||||||
|
if ("{{times}}"==1){
|
||||||
|
leftNum = 4;
|
||||||
|
}else{
|
||||||
|
leftNum = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
leftLevel.innerText = leftNum +" levels left."
|
||||||
|
leftNum--;
|
||||||
for (i = 0; i < levelNum - 1; i++) {
|
for (i = 0; i < levelNum - 1; i++) {
|
||||||
console.log("Play level: %s", levels[i])
|
console.log("Play level: %s", levels[i])
|
||||||
PlayLevel(levels[i], control)
|
PlayLevel(levels[i], control)
|
||||||
@ -225,6 +238,8 @@
|
|||||||
console.log(i)
|
console.log(i)
|
||||||
var index = levelNames.indexOf(title.innerText);
|
var index = levelNames.indexOf(title.innerText);
|
||||||
title.innerText = levelNames[index + 1];
|
title.innerText = levelNames[index + 1];
|
||||||
|
leftLevel.innerText = leftNum +" levels left."
|
||||||
|
leftNum--;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +250,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function LeftNum(times, level){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,23 +312,6 @@
|
|||||||
None of above
|
None of above
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<script>
|
|
||||||
function renew( ){
|
|
||||||
if ($("input[name='gender']").val()=="D"){
|
|
||||||
$("input[name='gender']").val($("input[type='text']").val())
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $("input[name='age']").val()=="A"){
|
|
||||||
$("input[name='age']").val($("input[type='number']").val())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<h4>4. How often do you play games?</h4>
|
<h4>4. How often do you play games?</h4>
|
||||||
<label>
|
<label>
|
||||||
@ -357,8 +340,8 @@
|
|||||||
<h4>5. What is your age?</h4>
|
<h4>5. What is your age?</h4>
|
||||||
<label>
|
<label>
|
||||||
|
|
||||||
<input type="radio" class="option-input radio" name="age" value= "A">
|
<input type="radio" class="option-input radio" name="age" value="A">
|
||||||
<input type="number" value="" step="1" placeholder="Input your age">
|
<input type="number" name="myAge" value="" step="1" placeholder="Input your age">
|
||||||
|
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@ -403,16 +386,6 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<script>
|
|
||||||
function renew( ){
|
|
||||||
|
|
||||||
$("input[name='gender']").val($("input[type='text']").val())
|
|
||||||
$("input[name='age']").val($("input[type='number']").val())
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<p><b><input type="submit" value="Submit" class="cirButton"
|
<p><b><input type="submit" value="Submit" class="cirButton"
|
||||||
style="font-weight: 700; font-size: large; width: 60%;" onclick ="" /></b></p>
|
style="font-weight: 700; font-size: large; width: 60%;" onclick ="" /></b></p>
|
||||||
@ -436,7 +409,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
|
||||||
<!-- Footer mx-auto -->
|
<!-- Footer mx-auto -->
|
||||||
@ -447,8 +421,8 @@
|
|||||||
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="col-md-10 column">
|
<div class="col-md-10 column">
|
||||||
<br><br>
|
<div class="col-xl-3 justify-content-center" style="margin: auto" align="center"><a href="/privacy" style="cursor:pointer; color: white;" target="_blank">Privacy Policy</a> </div>
|
||||||
<p class="m-0 text-center text-white">Copyright © Jialin Liu</p>
|
<div class="col-xl-3 justify-content-center text-white" style="margin: auto" align="center">Copyright © Jialin Liu</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -217,18 +217,19 @@
|
|||||||
<div class="container" style="font-weight: 600
|
<div class="container" style="font-weight: 600
|
||||||
;">
|
;">
|
||||||
|
|
||||||
<div class="row clearfix" >
|
<div class="row clearfix">
|
||||||
<!-- <style=" background-color: rgba(255,255,255);height: 130vh;
|
<!-- <style=" background-color: rgba(255,255,255);height: 130vh;
|
||||||
margin-top: -90px;"> -->
|
margin-top: -90px;"> -->
|
||||||
|
|
||||||
<div class="col-md-12" style=" background-color: rgba(255,255,255);" >
|
<div class="col-md-12" style=" background-color: rgba(255,255,255);">
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<h3>Super Mario Bros Tutorial</h3>
|
<h3>Super Mario Bros Tutorial</h3>
|
||||||
<p > Before proceeding to the main part of the experiment please familiarize yourself with the game.<br>
|
<p> Before proceeding to the main part of the experiment please familiarize yourself with the game.<br>
|
||||||
You may proceed to the next phase of this survey once you are ready!</p>
|
You may proceed to the next phase of this survey once you are ready!</p>
|
||||||
|
|
||||||
<b onclick="replay()" style="cursor: pointer;">Click <u style="color:blue; ">ME</u> to show the instruction page again.</b>
|
<b onclick="replay()" style="cursor: pointer;">Click <u style="color:blue; ">ME</u> to show the instruction
|
||||||
|
page again.</b>
|
||||||
|
|
||||||
<p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p>
|
<p class="alert">If the game is not responding to your keyboard, please click on the game screen.</p>
|
||||||
</div>
|
</div>
|
||||||
@ -254,7 +255,7 @@
|
|||||||
document.getElementById("game").style.visibility = "hidden";
|
document.getElementById("game").style.visibility = "hidden";
|
||||||
document.getElementById("next").style.visibility = "hidden";
|
document.getElementById("next").style.visibility = "hidden";
|
||||||
|
|
||||||
|
var control = ("{{control}}" == "1");
|
||||||
//var divElement = document.getElementById("GameWindow");
|
//var divElement = document.getElementById("GameWindow");
|
||||||
tutorialId = tutorialId+1
|
tutorialId = tutorialId+1
|
||||||
var level = "t"+tutorialId;
|
var level = "t"+tutorialId;
|
||||||
@ -266,7 +267,7 @@
|
|||||||
document.getElementById("loading").style.visibility = "hidden";
|
document.getElementById("loading").style.visibility = "hidden";
|
||||||
$("#mask").hide();
|
$("#mask").hide();
|
||||||
})
|
})
|
||||||
var control = ("{{control}}" == "1");
|
|
||||||
|
|
||||||
PlayLevel(level,control)
|
PlayLevel(level,control)
|
||||||
.then(function (){
|
.then(function (){
|
||||||
@ -289,59 +290,58 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="countdown"
|
|
||||||
style="z-index:999; position:absolute; left:50px; bottom: 20px; color: #ffffff; font-size: xx-large; ">
|
<img style=" height: 90vh;bottom: 3.5vh; left: 1vw;
|
||||||
</div>
|
position: absolute;z-index: 900; visibility: visible; width: 99%;" src="../templates/Web/pic.png"
|
||||||
<img style=" height: 90vh;bottom: 3.5vh; left: 0vw;
|
|
||||||
position: absolute;z-index: 900; visibility: visible; width: 100%;" src="../templates/Web/pic.png"
|
|
||||||
id="windowshow">
|
id="windowshow">
|
||||||
|
<img style=" height: 90vh;bottom: 3.5vh; left: 1vw;
|
||||||
|
position: absolute;z-index: 902; visibility: visible; width: 99%;" src="../templates/Web/top.png" id="top">
|
||||||
|
<img style=" height: 90vh;bottom: 3.5vh; left: 1vw;
|
||||||
|
position: absolute;z-index: 902; visibility: visible; width: 99%;" src="../templates/Web/bot.png" id="bot">
|
||||||
<script>
|
<script>
|
||||||
function countdown() {
|
|
||||||
// var count = 10; // 设置倒计时秒数
|
|
||||||
// var timer = setInterval(function () {
|
|
||||||
// count--;
|
|
||||||
// if (count <= 0) {
|
|
||||||
// clearInterval(timer);
|
|
||||||
// $("#countdown").hide();
|
|
||||||
// $("#windowshow:visible").hide(); // 倒计时结束后隐藏倒计时容器
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
$("#countdown").html("Click to close."); // 更新倒计时容器内容
|
|
||||||
$("#windowshow").click(function () {
|
|
||||||
$("#windowshow").hide();
|
|
||||||
$("#countdown").hide();
|
|
||||||
});}
|
|
||||||
// }
|
|
||||||
// }, 1000);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
countdown();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
//Init Cheerpj Framework
|
|
||||||
cheerpjInit();
|
cheerpjInit();
|
||||||
|
|
||||||
|
|
||||||
var divElement = document.getElementById("GameWindow");
|
var divElement = document.getElementById("GameWindow");
|
||||||
var tutorialId = parseInt("{{tutorial}}")
|
var tutorialId = parseInt("{{tutorial}}")
|
||||||
var level = "t" + "{{tutorial}}";
|
var level = "t" + "{{tutorial}}";
|
||||||
var img = document.getElementById("windowshow");
|
var img = document.getElementById("windowshow");
|
||||||
|
var control = ("{{control}}" == "1");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (control) {
|
||||||
|
$("#top:visible").hide();
|
||||||
|
console.log("1")
|
||||||
|
} else {
|
||||||
|
$("#bot:visible").hide();
|
||||||
|
console.log("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#windowshow").click(function () {
|
||||||
|
$("#windowshow:visible").hide();
|
||||||
|
|
||||||
|
});
|
||||||
|
$("#bot").click(function () {
|
||||||
|
|
||||||
|
$("#bot:visible").hide();
|
||||||
|
|
||||||
|
});
|
||||||
|
$("#top").click(function () {
|
||||||
|
$("#top:visible").hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
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 () {
|
||||||
console.log("Cheerpj Initialize Succeed!");
|
|
||||||
|
|
||||||
$("#windowshow:visible").hide();
|
$("#windowshow:visible").hide();
|
||||||
$("#countdown").hide();
|
{#console.log("Cheerpj Initialize Succeed!", control);#}
|
||||||
document.getElementById("loading").style.visibility = 'hidden';
|
document.getElementById("loading").style.visibility = 'hidden';
|
||||||
})
|
})
|
||||||
|
|
||||||
var control = ("{{control}}" == "1");
|
|
||||||
|
|
||||||
PlayLevel(level, control)
|
PlayLevel(level, control)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
@ -350,9 +350,21 @@
|
|||||||
document.getElementById("next").style.visibility = "visible";
|
document.getElementById("next").style.visibility = "visible";
|
||||||
}
|
}
|
||||||
document.getElementById("game").style.visibility = "visible";
|
document.getElementById("game").style.visibility = "visible";
|
||||||
|
|
||||||
|
|
||||||
$("#mask").hide();
|
$("#mask").hide();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
function replay() {
|
||||||
|
|
||||||
|
$("#windowshow:hidden").show();
|
||||||
|
if(control){
|
||||||
|
$("#bot:hidden").show();
|
||||||
|
|
||||||
|
}else {
|
||||||
|
$("#top:hidden").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
@ -366,19 +378,11 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <p>more icon-more</p> -->
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function replay() {
|
|
||||||
|
|
||||||
$("#windowshow:hidden").show();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
@ -388,7 +392,7 @@
|
|||||||
<!-- Footer mx-auto -->
|
<!-- Footer mx-auto -->
|
||||||
<footer class="py-5 bg-dark">
|
<footer class="py-5 bg-dark">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row clearfix" >
|
<div class="row clearfix">
|
||||||
<!-- <div class="col-md-2 column">
|
<!-- <div class="col-md-2 column">
|
||||||
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
||||||
</div> -->
|
</div> -->
|
||||||
|
@ -107,10 +107,10 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
{#label {#}
|
||||||
display: block;
|
{# display: block;#}
|
||||||
line-height: 100px;
|
{# line-height: 100px;#}
|
||||||
}
|
|
||||||
|
|
||||||
.option-input {
|
.option-input {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
@ -281,14 +281,36 @@
|
|||||||
<li> Have Fun!
|
<li> Have Fun!
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br>
|
||||||
|
<script>
|
||||||
|
function validateForm() {
|
||||||
|
// Check if the checkbox is checked
|
||||||
|
var checkbox = document.getElementById('privacyPolicyCheckbox');
|
||||||
|
if (!checkbox.checked) {
|
||||||
|
alert('Please agree to the privacy policy');
|
||||||
|
return false; // Prevent form submission
|
||||||
|
}
|
||||||
|
return true; // Allow form submission
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button class="cirButton" type="submit" onclick="
|
||||||
|
if (validateForm()) { window.location.href = '/question'; }
|
||||||
|
"><b> Start!</b> </button>
|
||||||
|
|
||||||
<button onclick="window.location.href = '/question';" class="cirButton"><b> Start!</b> </button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<div class="col-xl-7 justify-content-between align-content-center" style="margin: auto">This page is created by <a href="https://github.com/BigJIU" target="_blank">Haocheng Du</a>, <a href="https://doveliyuchen.github.io" target="_blank">Yuchen Li</a>; game content is generated by <b>AI </b>designed by<a href="https://github.com/PneuC" target="_blank"> Ziqi Wang</a>.<br> This project is supported by <a href="http://www.liujialin.tech/" target="_blank">Dr. Liu</a> and <a href="https://yannakakis.net/" target="_blank">Prof. Yannakakis</a>.</div>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<!-- Footer mx-auto -->
|
<!-- Footer mx-auto -->
|
||||||
<footer class="py-5 bg-dark">
|
<footer class="py-5 bg-dark">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -297,8 +319,8 @@
|
|||||||
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
<img class="img-fluid" alt="" src="../templates/Web/Wechat.png" style="width: 100px;">
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="col-md-10 column">
|
<div class="col-md-10 column">
|
||||||
<br><br>
|
<div class="col-xl-3 justify-content-center" style="margin: auto" align="center"><a href="/privacy" style="cursor:pointer; color: white;" target="_blank">Privacy Policy</a> </div>
|
||||||
<p class="m-0 text-center text-white">Copyright © Jialin Liu</p>
|
<div class="col-xl-3 justify-content-center text-white" style="margin: auto" align="center">Copyright © Jialin Liu</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
1199
templates/Main.html
1199
templates/Main.html
File diff suppressed because one or more lines are too long
184
templates/Privacy.html
Normal file
184
templates/Privacy.html
Normal file
File diff suppressed because one or more lines are too long
BIN
templates/Web/Malta.png
Normal file
BIN
templates/Web/Malta.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 112 KiB |
BIN
templates/Web/bot.png
Normal file
BIN
templates/Web/bot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
Before Width: | Height: | Size: 336 KiB After Width: | Height: | Size: 318 KiB |
BIN
templates/Web/top.png
Normal file
BIN
templates/Web/top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
@ -11,17 +11,7 @@ function getValue(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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)); //设置为发送给服务器数据
|
|
||||||
// }
|
|
||||||
function PostToServer(url,data) {
|
function PostToServer(url,data) {
|
||||||
if(url == null){
|
if(url == null){
|
||||||
$.post(window.location.href, data);
|
$.post(window.location.href, data);
|
||||||
@ -36,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!")){
|
||||||
|
|
||||||
@ -59,9 +55,6 @@ function PlayLevel(level,control){
|
|||||||
alert(obj[i].value);
|
alert(obj[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// var radio = document.getElementsByName("gameRadio");
|
|
||||||
// var addressID = $("input[name='sex']:checked").val();
|
|
||||||
// alert(addressID)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user