71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
from diplomacy import Game
|
|
import json
|
|
|
|
def test_render():
|
|
# Turn 1 State (Standard Start)
|
|
state_t1 = {
|
|
"timestamp": 0,
|
|
"map": "standard",
|
|
"rules": ["NO_PRESS"],
|
|
"status": "active",
|
|
"phase": "S1901M",
|
|
"units": {
|
|
"AUSTRIA": ["A VIE", "A BUD", "F TRI"],
|
|
"ENGLAND": ["F EDI", "F LON", "A LVP"],
|
|
"FRANCE": ["F BRE", "A MAR", "A PAR"],
|
|
"GERMANY": ["A BER", "A MUN", "F KIE"],
|
|
"ITALY": ["F NAP", "A ROM", "A VEN"],
|
|
"RUSSIA": ["A WAR", "A MOS", "F SEV", "F STP/SC"],
|
|
"TURKEY": ["F ANK", "A CON", "A SMY"]
|
|
},
|
|
"scs": {
|
|
"AUSTRIA": ["VIE", "BUD", "TRI"],
|
|
"ENGLAND": ["EDI", "LON", "LVP"],
|
|
"FRANCE": ["BRE", "MAR", "PAR"],
|
|
"GERMANY": ["BER", "MUN", "KIE"],
|
|
"ITALY": ["NAP", "ROM", "VEN"],
|
|
"RUSSIA": ["WAR", "MOS", "SEV", "STP"],
|
|
"TURKEY": ["ANK", "CON", "SMY"]
|
|
}
|
|
}
|
|
|
|
# Turn 10 State (Hypothetical, clearly different)
|
|
state_t10 = state_t1.copy()
|
|
state_t10["phase"] = "S1904M"
|
|
state_t10["units"] = {
|
|
"AUSTRIA": ["A RUM", "A BOH", "F ADR"], # MOVED
|
|
"ENGLAND": ["F NWG", "F WAL", "A EDI"],
|
|
"FRANCE": ["A MUN", "A SPA", "F TUN"],
|
|
"GERMANY": ["A SIL", "A PRU", "F HOL"],
|
|
"ITALY": ["F NAP", "A SER", "A APU"],
|
|
"RUSSIA": ["A WAR", "A MOS", "F SEV", "F NTH"],
|
|
"TURKEY": ["F BLA", "A BUL", "A CON"]
|
|
}
|
|
|
|
game1 = Game()
|
|
game1.set_state(state_t1)
|
|
svg1 = game1.render(output_format='svg')
|
|
|
|
game10 = Game()
|
|
game10.set_state(state_t10)
|
|
svg10 = game10.render(output_format='svg')
|
|
|
|
print(f"SVG1 Length: {len(svg1)}")
|
|
print(f"SVG10 Length: {len(svg10)}")
|
|
|
|
if svg1 == svg10:
|
|
print("SVGs are IDENTICAL (Problem!)")
|
|
else:
|
|
print("SVGs are DIFFERENT (Good)")
|
|
|
|
# Check if 'RUM' is in SVG10 details
|
|
if "RUM" in svg10:
|
|
print("SVG10 contains 'RUM'")
|
|
|
|
# Check if 'VIE' is in SVG10 details
|
|
if "VIE" in svg10:
|
|
print("SVG10 contains 'VIE' (Expected as label)")
|
|
|
|
if __name__ == "__main__":
|
|
test_render()
|