Skip to content

A graphical Tic-Tac-Toe game using Bevy (a data-driven game engine built in Rust).

License

Notifications You must be signed in to change notification settings

Lymah123/bevy-tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

CI Security Audit Latest Release

๐ŸŽฎ Download & Play

Download for Windows Download for macOS Download for Linux

Download the executable for your platform - no installation required!


Bevy Tic-Tac-Toe

Tic-Tac-Toe Gameplay

Tic-Tac-Toe built in Rust with the Bevy game engine. Features AI opponent using Minimax, responsive UI, and a modular ECS-based design.

Table of Contents

Features

  • โœ… Human vs AI gameplay with intelligent opponent
  • ๐Ÿง  Minimax algorithm with alpha-beta pruning for unbeatable AI
  • ๐ŸŽฎ Responsive mouse controls - click any cell to play
  • ๐Ÿ—๏ธ Modern ECS architecture using Bevy game engine
  • ๐Ÿ”„ Automatic turn management and game flow
  • ๐Ÿ“ฑ Cross-platform support (Windows, macOS, Linux)
  • ๐Ÿงช Comprehensive unit tests for AI logic
  • โšก High performance - native Rust speed

Quick Start

Option 1: Download Executable (Recommended)

  1. Download for your platform using the buttons above
  2. Run the executable - double-click to play
  3. No installation needed - runs immediately

Option 2: Build from Source

git clone https://github.com/Lymah123/bevy-tic-tac-toe
cd bevy-tic-tac-toe
cargo run --release

Development Setup

Local Development

# Clone and setup
git clone https://github.com/Lymah123/bevy-tic-tac-toe
cd bevy-tic-tac-toe

# Install dependencies
cargo fetch

# Run in development mode (with debug info)
cargo run

# Run with optimizations
cargo run --release

Testing

# Run all tests
cargo test

# Run specific test module
cargo test ai_logic

# Run tests with output
cargo test -- --nocapture

# Test with coverage (requires cargo-tarpaulin)
cargo tarpaulin --out html

Code Quality

# Format code
cargo fmt

# Lint and suggestions
cargo clippy

# Check for improvements
cargo clippy -- -W clippy::pedantic

# Audit dependencies
cargo audit

Architecture

This game follows the ECS (Entity-Component-System) architecture using Bevy.

Layer Purpose
Components Describe game entities (e.g., Cell, Marker)
Systems Logic handlers (input, AI, rendering, gameplay)
Resources Global state (game mode, board, statistics)
Events Decoupled messaging (player move, game over)
AI Logic Pure minimax functions (no Bevy dependency)
src/
โ”œโ”€โ”€ main.rs              # App setup and system registration
โ”œโ”€โ”€ components.rs        # ECS components (BoardPosition, CellMark)
โ”œโ”€โ”€ resources.rs         # Global state (BoardState, GameMode)
โ”œโ”€โ”€ events.rs           # Event definitions (PlayerMove, GameOver)
โ”œโ”€โ”€ types.rs            # Game enums and data structures
โ”œโ”€โ”€ config.rs           # Game constants and configuration
โ”œโ”€โ”€ ai_logic.rs         # Pure AI algorithms (testable)
โ””โ”€โ”€ systems/
    โ”œโ”€โ”€ setup.rs        # Game initialization
    โ”œโ”€โ”€ input.rs        # Mouse input handling
    โ”œโ”€โ”€ gameplay.rs     # Core game logic
    โ”œโ”€โ”€ ai.rs          # AI integration
    โ””โ”€โ”€ ui.rs          # User interface

AI Logic

The AI supports three difficulty levels:

  • ๐ŸŸข Easy: Random valid moves
  • ๐ŸŸก Medium: Minimax with depth limit
  • ๐Ÿ”ด Hard: Full-depth Minimax with alpha-beta pruning

The AI is implemented in a pure Rust module (ai_logic.rs) so it can be unit tested independently of Bevy.

Contributing

Contributions are welcome! Please feel free to submit issues, fork the repository, and create pull requests.

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Standards

  • Follow Rust conventions and use cargo fmt
  • Add unit tests for new functionality
  • Update documentation for API changes
  • Ensure no clippy warnings in your code

Performance

  • Download Size: ~15MB executable
  • Startup Time: < 1 second on modern hardware
  • Memory Usage: ~50MB RAM typical
  • Frame Rate: 60 FPS consistent
  • No Dependencies: Self-contained executable

Tech Stack

Core Technologies

  • Rust - Systems programming language
  • Bevy Engine - Data-driven game engine

Dependencies

[dependencies]
bevy = "0.11"           # Main game engine

Architecture Patterns

  • ECS (Entity-Component-System) - Bevy's core architecture
  • Event-Driven Design - Decoupled system communication
  • Resource Management - Global state handling
  • System Scheduling - Ordered execution pipelines

Acknowledgments

Usage

How to Play

  1. Download and run the executable for your platform
  2. Make your move - Click any empty cell (you play as X)
  3. AI responds - The AI automatically places O
  4. Win conditions - Get 3 in a row (horizontal, vertical, or diagonal)

System Requirements

  • Windows: Windows 10+ (64-bit)
  • macOS: macOS 10.12+ (64-bit)
  • Linux: Most modern distributions (64-bit)
  • RAM: 50MB minimum
  • Storage: 15MB disk space

Controls

Action Input
Place mark Left mouse click on empty cell
Restart game R key (if implemented)
Exit game Alt + F4 / Cmd + Q

Future Plans

  • Mode selector screen with in-game menu
  • Sound effects and visual effects
  • Mobile-friendly UI (larger touch zones)
  • Undo/Redo move history
  • Export match statistics to file

License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License Summary

  • โœ… Commercial use allowed
  • โœ… Modification allowed
  • โœ… Distribution allowed
  • โœ… Private use allowed
  • โŒ No warranty provided

Built with โค๏ธ in Rust

If you found this project useful, please consider giving it a โญ!

About

A graphical Tic-Tac-Toe game using Bevy (a data-driven game engine built in Rust).

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  
  •  

Packages

No packages published