A modern Tic-Tac-Toe implementation built with Node.js, TypeScript, and Socket.io. It features a minimalist design and an innovative Infinity Mode, where older pieces disappear to prevent draws.
- Classic Mode: The traditional 3x3 game experience.
- Infinity Mode: Each player is limited to 3 pieces on the board. Placing a 4th piece causes the oldest one to disappear.
- Matchmaking: Automated queue system segmented by game mode.
- Private Rooms: Create exclusive rooms to play with friends via room ID.
- Dynamic Rematch: Random symbol assignment (X or O) upon rematch to ensure fair starting conditions.
- Minimalist UI: Clean interface focused on usability with JetBrains Mono typography.
- Frontend: HTML5, CSS3, Vanilla JavaScript.
- Backend: Node.js, TypeScript.
- Communication: Real-time messaging via Socket.io.
- Architecture: Strategy Pattern for game logic and centralized Server-Side State Management.
├── 📁 public # Client-side (UI and Assets)
│ ├── 📁 js # Local logic and WebSocket communication
│ ├── 🌐 index.html # Main structure
│ └── 🎨 style.css # Styling (Neo-brutalist approach)
├── 📁 src # Server-side (TypeScript)
│ ├── 📁 core # Business logic and Strategies (Game, Infinity)
│ ├── 📁 socket # Room, Player, and Matchmaking management
│ └── 📄 index.ts # Server entry point
└── ⚙️ tsconfig.json # TypeScript compiler configuration
- Install dependencies:
npm install
- Run development server:
npm run dev
- Access in browser:
http://localhost:3000
The project follows Clean Code principles and Evolutionary Refactoring:
- Early Returns: State validations are handled at the beginning of functions to reduce conditional nesting.
- Strategy Pattern: Move processing and draw-checking logic are isolated into strategy classes, making it easy to add new game modes without modifying the core
Gameclass. - Separation of Concerns:
RoomManagerhandles the room lifecycle, whileMatchmakerfocuses strictly on queue organization.
- Fork the project.
- Create a Branch for your feature (
git checkout -b feature/NewFeature). - Commit your changes (
git commit -m 'Add: Feature description'). - Push to the Branch (
git push origin feature/NewFeature). - Open a Pull Request.
Developed with Node.js and TypeScript.