Files
clutch/tests/test_advanced_inference.py
2026-02-05 23:26:03 +08:00

54 lines
1.7 KiB
Python

import requests
import json
# URL of the local inference service
url = "http://127.0.0.1:5000/predict"
# Scenario: 2v2 Clutch
# T side: 2 players, low cash, AK47s
# CT side: 2 players, high cash, M4A1s + Defuser
# Spatial: T grouped (spread low), CT spread out (spread high)
payload = {
"game_time": 90.0,
"is_bomb_planted": 1,
"site": 401, # Example site ID
"players": [
# T Players (Team 2)
{
"team_num": 2, "is_alive": True, "health": 100,
"X": -1000, "Y": 2000, "Z": 0,
"active_weapon_name": "ak47", "balance": 1500, "armor_value": 100, "has_helmet": True,
"rating": 1.05
},
{
"team_num": 2, "is_alive": True, "health": 100,
"X": -1050, "Y": 2050, "Z": 0,
"active_weapon_name": "ak47", "balance": 2000, "armor_value": 100, "has_helmet": True,
"rating": 0.95
},
# CT Players (Team 3)
{
"team_num": 3, "is_alive": True, "health": 100,
"X": 0, "Y": 0, "Z": 0,
"active_weapon_name": "m4a1", "balance": 5000, "armor_value": 100, "has_helmet": True, "has_defuser": True,
"rating": 1.10
},
{
"team_num": 3, "is_alive": True, "health": 100,
"X": -2000, "Y": 3000, "Z": 0,
"active_weapon_name": "awp", "balance": 4750, "armor_value": 100, "has_helmet": True,
"rating": 1.20
}
]
}
print(f"Sending payload to {url}...")
try:
response = requests.post(url, json=payload)
print(f"Status Code: {response.status_code}")
print("Response JSON:")
print(json.dumps(response.json(), indent=2))
except Exception as e:
print(f"Request failed: {e}")