Spaces:
Build error
Build error
Kaushik Rajan
commited on
Commit
·
2701231
1
Parent(s):
5e02c64
Clean up test files and update execution plan
Browse files- test_games.py +0 -82
test_games.py
DELETED
|
@@ -1,82 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
Test script for game environments.
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
import sys
|
| 7 |
-
import os
|
| 8 |
-
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
|
| 9 |
-
|
| 10 |
-
from games import TicTacToeEnv, KuhnPokerEnv, create_tictactoe_env, create_kuhn_poker_env
|
| 11 |
-
from games.game_utils import get_available_games, get_game_info, play_random_game
|
| 12 |
-
|
| 13 |
-
def test_tictactoe():
|
| 14 |
-
"""Test TicTacToe environment."""
|
| 15 |
-
print("Testing TicTacToe...")
|
| 16 |
-
env = create_tictactoe_env()
|
| 17 |
-
obs, info = env.reset()
|
| 18 |
-
print(f"Initial observation shape: {obs.shape}")
|
| 19 |
-
print(f"Action space: {env.action_space}")
|
| 20 |
-
print(f"Observation space: {env.observation_space}")
|
| 21 |
-
|
| 22 |
-
# Test a few moves
|
| 23 |
-
action = 0
|
| 24 |
-
obs, reward, terminated, truncated, info = env.step(action)
|
| 25 |
-
print(f"After move {action}: reward={reward}, terminated={terminated}")
|
| 26 |
-
|
| 27 |
-
env.close()
|
| 28 |
-
print("TicTacToe test passed!\n")
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
def test_kuhn_poker():
|
| 32 |
-
"""Test Kuhn Poker environment."""
|
| 33 |
-
print("Testing Kuhn Poker...")
|
| 34 |
-
env = create_kuhn_poker_env()
|
| 35 |
-
obs, info = env.reset()
|
| 36 |
-
print(f"Initial observation: {obs}")
|
| 37 |
-
print(f"Action space: {env.action_space}")
|
| 38 |
-
print(f"Observation space: {env.observation_space}")
|
| 39 |
-
|
| 40 |
-
# Test a move
|
| 41 |
-
action = 0 # Check/Call
|
| 42 |
-
obs, reward, terminated, truncated, info = env.step(action)
|
| 43 |
-
print(f"After action {action}: reward={reward}, terminated={terminated}")
|
| 44 |
-
|
| 45 |
-
env.close()
|
| 46 |
-
print("Kuhn Poker test passed!\n")
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def test_game_utils():
|
| 50 |
-
"""Test game utility functions."""
|
| 51 |
-
print("Testing game utilities...")
|
| 52 |
-
|
| 53 |
-
# Test available games
|
| 54 |
-
games = get_available_games()
|
| 55 |
-
print(f"Available games: {games}")
|
| 56 |
-
|
| 57 |
-
# Test game info
|
| 58 |
-
for game_name in games:
|
| 59 |
-
info = get_game_info(game_name)
|
| 60 |
-
print(f"{game_name} info: {info['description']}")
|
| 61 |
-
|
| 62 |
-
print("Game utilities test passed!\n")
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
def main():
|
| 66 |
-
"""Run all tests."""
|
| 67 |
-
print("Running game environment tests...\n")
|
| 68 |
-
|
| 69 |
-
try:
|
| 70 |
-
test_tictactoe()
|
| 71 |
-
test_kuhn_poker()
|
| 72 |
-
test_game_utils()
|
| 73 |
-
print("All tests passed! ✅")
|
| 74 |
-
except Exception as e:
|
| 75 |
-
print(f"Test failed: {e}")
|
| 76 |
-
return 1
|
| 77 |
-
|
| 78 |
-
return 0
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
if __name__ == "__main__":
|
| 82 |
-
sys.exit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|