from diplomacy import Game def test_nmr(): game = Game() # France does nothing # England moves game.set_orders("ENGLAND", ["F LON - ENG", "A LVP - WAL", "F EDI - NTH"]) print("Processing Spring 1901...") game.process() # Check France france = game.get_power("FRANCE") print(f"France Civil Disorder Status: {france.civil_disorder}") print(f"France Units: {france.units}") # France orders in the previous phase (Spring 1901) # The game object stores history? # game.get_orders(power_name) gets *current* phase orders (empty) # We can inspect the map or units to see if they moved? # But France didn't move. # Let's verify they are still at starting positions print(f"France Units after process: {france.units}") assert 'A PAR' in france.units assert 'F BRE' in france.units assert 'A MAR' in france.units # Also Check if we can find the 'H' orders in history if available # game.order_history is a thing? # From dir(game) in previous turn: 'order_history' # keys of order_history are timestamps or phase names? # Let's print keys # print(f"Order History Keys: {game.order_history.keys()}") # It might be keyed by phase name 'SPRING 1901 MOVEMENT' # Test 2: Auto-dsiband in Adjustment Phase print("\nTesting Auto-Disband...") # Create a situation where France loses a center and must disband # We can force set units and centers g2 = Game() g2.set_units("FRANCE", ["A BUR", "A PAR"]) # 2 units g2.set_centers("FRANCE", ["PAR"]) # 1 center (needs to remove 1) # Phase needs to be adjustment? Or just process? # Game starts at Spring 1901. We need to set phase to Winter 1901? # Or just manipulate state to be in adjustment? # Easiest way: force phase from diplomacy.utils.game_phase_data import GamePhaseData g2.phase = "WINTER 1901 ADJUSTMENTS" # We must ensure the game knows it's adjustment phase data structure # Actually just processing might not work if we brute force phase string? # Better to correct way: # Let's just use a map where we can skip to adjustments or manually set it up correct. # brute forcing might break internal state. # Alternative: # 1. France holds # 2. Enemy takes a center # 3. Fall ends # 4. France must disband # Let's try brute forcing phase + clear cache if possible, but let's try the cleaner way # Set Units/Centers then process? # The game checks phase validity. # Let's try: g3 = Game() g3.set_units("FRANCE", ["A PAR", "A MAR"]) g3.set_centers("FRANCE", ["PAR"]) # Lost MAR g3.phase = "WINTER 1901 ADJUSTMENTS" # We might need to ensure 'A MAR' is considered a unit. print("Processing Adjustment Phase (No Orders for France)...") g3.process() print(f"France Units after adjustment: {g3.get_units('FRANCE')}") # A MAR is further from PAR than A PAR? # Distance PAR-PAR = 0. # Distance MAR-PAR = 1. # So A MAR should be disbanded. if __name__ == "__main__": test_nmr()