Understanding the Reward System
The reward system is a crucial component of reinforcement learning in Casino of Life. This guide explains how to create, customize, and optimize reward functions for your AI agents.
Reward System Basics
In reinforcement learning, rewards guide the agent toward desired behaviors. Casino of Life provides a flexible and modular reward system that allows you to precisely define what constitutes "success" for your fighting game AI.
Built-in Reward Evaluators
Casino of Life comes with several pre-built reward evaluators:
BasicRewardEvaluator
Handles fundamental fighting game metrics:
from casino_of_life.reward_evaluators import BasicRewardEvaluator
basic_reward = BasicRewardEvaluator(
health_reward=1.0, # Reward for maintaining health
damage_penalty=-1.0, # Penalty for taking damage
hit_reward=0.5, # Reward for landing hits
block_reward=0.2, # Reward for successful blocks
move_penalty=-0.01 # Small penalty to discourage button mashing
)StageCompleteRewardEvaluator
Provides rewards for level progression:
SpecialMoveRewardEvaluator
Encourages the use of specific techniques:
Combining Reward Evaluators
Multiple reward evaluators can be combined using the MultiObjectiveRewardEvaluator:
Creating Custom Reward Evaluators
You can create custom reward evaluators by extending the BaseRewardEvaluator class:
Managing Reward Evaluators
Use the RewardEvaluatorManager to organize and switch between different reward systems:
Reward Scaling and Balancing
Proper scaling of rewards is essential for effective learning:
Best Practices for Reward Design
Start simple: Begin with basic health/damage rewards before adding complexity
Balance immediate vs. delayed rewards: Mix short-term feedback with long-term goals
Avoid reward hacking: Test for unintended behaviors that might exploit your reward system
Normalize reward scales: Keep different reward components on similar scales
Introduce curriculum learning: Gradually increase the complexity of the reward system as the agent improves
By mastering the reward system in Casino of Life, you can create sophisticated AI agents with complex, nuanced behaviors that reflect your intended fighting game strategies.
Last updated