Skip to content

Repository files navigation

Kotlin Tic-Tac-Toe

A small Tic-Tac-Toe library written in Kotlin, with an example console-based application.

The core game engine is fully testable and reusable in any Kotlin application.

Features

  • UI-Agnostic Core: The TicTacToe engine has zero dependencies on the UI or println.
  • Immutable State: The Board class is immutable. Moves create a new board state, making state management predictable and safe.
  • Extensible AI: A simple PlayerStrategy interface allows for custom AI. A RandomStrategy is provided as an example.
  • Fully Tested: The core library logic is validated by a suite of unit tests.

Project Structure

  • lib/src/main/kotlin/org/jetbrains/kotlinx/tictactoe/TicTacToe.kt: The core game library. It contains all logic for the board, players, and game state.
  • app/src/main/kotlin/org/jetbrains/kotlinx/tictactoe/main.kt: A simple, playable console application that uses the TicTacToe library.
  • lib/src/test/kotlin/org/jetbrains/kotlinx/tictactoe/TicTacToeTests.kt: A set of unit tests for the TicTacToe library.
  • TicTacToe.ipynb (Kotlin Notebook)
    • An interactive notebook at the project root that provides a live demo of the :lib module and its features.

How to Run the Console App

Run the main.kt file and follow console prompts.

How to Use the Library

To use the game engine in your own application, you only need TicTacToe.kt. You can then import it and control the game flow.

Running Tests

Tests are located in TicTacToeTests.kt.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages