https://github.com/sysprog21/kxo
A Tic-Tac-Toe Game Engine implemented as Linux kernel module
https://github.com/sysprog21/kxo
Last synced: about 1 month ago
JSON representation
A Tic-Tac-Toe Game Engine implemented as Linux kernel module
- Host: GitHub
- URL: https://github.com/sysprog21/kxo
- Owner: sysprog21
- License: mit
- Created: 2025-03-09T09:04:20.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-04-30T07:39:54.000Z (about 1 month ago)
- Last Synced: 2025-05-08T23:53:48.962Z (about 1 month ago)
- Language: C
- Size: 57.6 KB
- Stars: 7
- Watchers: 1
- Forks: 74
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kxo: A Tic-Tac-Toe Game Engine implemented as Linux kernel module
## Introduction
`kxo` is a Linux kernel module that implements the [tic-tac-toe game](https://en.wikipedia.org/wiki/Tic-tac-toe)
(aka XO Game) as kernel threads.
This educational module demonstrates several essential Linux kernel programming concepts:
- Circular buffer implementation
- Mutex lock synchronization
- IRQ handling
- SoftIRQ processing
- Tasklet scheduling
- Workqueue management
- Kernel thread creation and executionThe module supports multiple AI algorithms for game strategy, allowing kernel threads to compete against each other in tic-tac-toe matches.
`kxo` implements two advanced algorithms for tic-tac-toe gameplay:
- Monte Carlo Tree Search (MCTS): A probabilistic algorithm that uses random sampling to evaluate moves and determine optimal game strategies
- Negamax Algorithm: A depth-first minimax variant that efficiently evaluates game positions by alternating between maximizing and minimizing players## Build and Run
After the source code is downloaded, go into the directory and do as the following
```
$ make
```Make sure the kernel object file (`kxo.ko`) is built correctly, then you can insert the kernel module
```
$ sudo insmod kxo.ko
````kxo` provides an interface for userspace interaction through the companion tool `xo-user`.
This utility offers the following functionality:
- Display the current status of the `kxo` module (loaded/unloaded)
- Real-time visualization of the tic-tac-toe game board
- Control commands:
- `Ctrl + P`: Toggle pause/resume of the game board display
- `Ctrl + Q`: Terminate all tic-tac-toe games running in kernel spaceSimply run the command below after the kernel module is loaded:
```
$ sudo ./xo-user
```To unload the kernel module, use the command:
```
$ sudo rmmod kxo
```## License
`kxo` is released under the MIT license. Use of this source code is governed
by a MIT-style license that can be found in the LICENSE file.