Getting Started for Students
This guide covers the essential setup and functions you’ll use across all AGT labs.
Quick Setup
Install Dependencies
git clone <repository-url>
cd agt_server_new
pip install -r requirements.txt
How Labs Work
Each lab follows the same process:
Understand the Game - Read the lab documentation to learn the game mechanics, state space, and rules
Create Your Agent - Implement the three required methods (
get_action,update,reset) with your strategyTest Locally - Run your agent against built-in opponents to make sure it works correctly
Connect to Server - Submit your agent to compete against other students
Analyze Results - Learn from your performance and improve your strategy
The key is understanding the game structure first, then implementing your own creative strategies!
Common Functions Across All Labs
The Three Required Methods
Every agent must implement these methods:
get_action(observation)
def get_action(self, observation: Dict[str, Any]) -> Any:
# observation: current game state (varies by lab)
# Return: your chosen action (format varies by lab)
return my_action
update(reward, info)
def update(self, reward: float, info: Dict[str, Any]):
super().update(reward, info)
# reward: points earned from last action
# info: additional information (opponent action, etc.)
reset()
def reset(self):
super().reset()
# Clear any game-specific state
self.opponent_history = []
self.my_history = []
Common State Management
class MyAgent(BaseAgent):
def __init__(self, name):
super().__init__(name)
self.opponent_history = []
self.my_history = []
self.round_count = 0
def reset(self):
super().reset()
self.opponent_history = []
self.my_history = []
self.round_count = 0
Running Labs Locally
Test Your Agent
from core.engine import Engine
from core.game.RPSGame import RPSGame
from core.agents.lab01.random_agent import RandomAgent
# Create your agent
my_agent = MyAgent("MyAgent")
opponent = RandomAgent("Random")
# Run test game
engine = Engine(RPSGame(), [my_agent, opponent], rounds=100)
results = engine.run()
print(f"My score: {results[0]}")
print(f"Opponent score: {results[1]}")
Debug Your Agent
def get_action(self, observation):
print(f"Observation: {observation}")
print(f"Opponent history: {self.opponent_history}")
action = self.choose_action(observation)
print(f"Chosen action: {action}")
return action
Connecting to Server
1. Start Server
python server/server.py
2. Connect Your Agent
cd stencils/lab01_stencil
python example_solution.py
Your agent will connect and start competing automatically.
Next Steps
Read the lab documentation to understand the game mechanics
Implement your agent using the patterns above
Test locally before submitting
Connect to server and compete
Learn from results and improve your strategy
Each lab has its own game mechanics and state space. The patterns above work across all labs, but the specific details vary.