Update json output & PartII calculator

This commit is contained in:
bigJIU 2023-04-10 20:33:36 +08:00
parent c3d4ef4d00
commit 9fcc338dda
17 changed files with 160 additions and 17 deletions

View 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

View 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

View 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

View 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

View 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.

View 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

View File

@ -25,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();
//System.out.println(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(){
@ -40,14 +42,14 @@ public class Play {
public static String 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); String jsonString = Replay.serializeGameResult(tmpResult);

View File

@ -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();

42
localData/dataCompare.py Normal file
View 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'])

15
main.py
View File

@ -231,7 +231,8 @@ def saveRepFile(path, filename, content):
alist = actions["actions0"] alist = actions["actions0"]
actionsInput = [alist["0"], alist["1"], alist["2"], alist["3"], alist["4"], alist["5"], alist["6"]] actionsInput = [alist["0"], alist["1"], alist["2"], alist["3"], alist["4"], alist["5"], alist["6"]]
actionList.append(serializeAction(actionsInput)) actionList.append(serializeAction(actionsInput))
except Exception: continue except Exception:
continue
cp = list(map(int, actionList)) cp = list(map(int, actionList))
file_dir = os.path.join(os.getcwd(), path) file_dir = os.path.join(os.getcwd(), path)
@ -242,12 +243,13 @@ def saveRepFile(path, filename, content):
def serializeAction(actions): def serializeAction(actions):
res = 0 res = 0
for i in range(5): for i in range(1, 6):
if not actions[i]: if actions[i]:
tmp = 1 << i tmp = 1 << (i-1)
res += tmp res += tmp
return res return res
def saveJsonFile(path, filename, content): def saveJsonFile(path, filename, content):
file_dir = os.path.join(os.getcwd(), path) file_dir = os.path.join(os.getcwd(), path)
file_path = os.path.join(file_dir, filename + ".json") file_path = os.path.join(file_dir, filename + ".json")
@ -256,5 +258,6 @@ def saveJsonFile(path, filename, 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()

View File

@ -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>