haive.games.connect4.example¶
Comprehensive examples for the Connect4 game module.
This module provides a complete set of examples demonstrating all aspects of the Connect4 game implementation, from basic gameplay to advanced features like strategic analysis, performance testing, and error handling.
The examples are organized into logical categories: - Basic gameplay examples - Rich UI demonstrations - Strategic analysis showcases - Performance and testing examples - Error handling and debugging - Advanced usage patterns - Tournament and batch processing - Custom configuration examples
Each example includes detailed comments explaining the concepts and can be run independently or as part of the full demonstration suite.
- Usage:
- Run all examples:
python example.py
- Run specific example:
python example.py basic python example.py rich-ui python example.py analysis python example.py performance python example.py error-handling python example.py tournament python example.py custom-ai python example.py async-batch
- Examples provided:
Basic Game - Simple game with minimal configuration
Rich UI Game - Beautiful terminal interface with animations
Strategic Analysis - Deep position analysis and explanations
Performance Testing - Benchmarking and optimization
Error Handling - Robust error management and debugging
Tournament Mode - Multiple games and statistics
Custom AI Configuration - Advanced engine customization
Async Batch Processing - Concurrent game execution
Classes¶
Data class to store game results. |
Functions¶
Example 1: Basic Game - Simple gameplay with minimal configuration. |
|
Example 2: Rich UI Game - Beautiful terminal interface with animations. |
|
Example 3: Strategic Analysis - Deep position analysis and explanations. |
|
Example 4: Performance Testing - Benchmarking and optimization. |
|
Example 5: Error Handling - Robust error management and debugging. |
|
Example 6: Tournament Mode - Multiple games and statistics. |
|
Example 7: Custom AI Configuration - Advanced engine customization. |
|
Example 8: Async Batch Processing - Concurrent game execution. |
|
|
Main function to run all examples or specific ones. |
Module Contents¶
- haive.games.connect4.example.example_1_basic_game()[source]¶
Example 1: Basic Game - Simple gameplay with minimal configuration.
This example demonstrates the simplest way to create and run a Connect4 game. Perfect for quick testing and understanding basic functionality.
- haive.games.connect4.example.example_2_rich_ui_game()[source]¶
Example 2: Rich UI Game - Beautiful terminal interface with animations.
This example showcases the Rich-based UI system with animated board display, AI thinking indicators, and comprehensive game state visualization.
- haive.games.connect4.example.example_3_strategic_analysis()[source]¶
Example 3: Strategic Analysis - Deep position analysis and explanations.
This example demonstrates the strategic analysis capabilities of the Connect4 AI, showing how it evaluates positions, detects threats, and plans moves.
- haive.games.connect4.example.example_4_performance_testing()[source]¶
Example 4: Performance Testing - Benchmarking and optimization.
This example demonstrates performance testing capabilities, measuring game execution speed, memory usage, and providing optimization insights.
- haive.games.connect4.example.example_5_error_handling()[source]¶
Example 5: Error Handling - Robust error management and debugging.
This example demonstrates various error conditions and how the system handles them gracefully with informative error messages.
- haive.games.connect4.example.example_6_tournament_mode()[source]¶
Example 6: Tournament Mode - Multiple games and statistics.
This example demonstrates running multiple games in succession and collecting comprehensive statistics about game patterns and outcomes.
- haive.games.connect4.example.example_7_custom_ai_configuration()[source]¶
Example 7: Custom AI Configuration - Advanced engine customization.
This example demonstrates advanced AI configuration options and how to customize the Connect4 agent for specific use cases.