A Linux driver for a character device which can be used to play Tic-tac-toe.
Disclaimer: I make no guarantees about the soundness of the driver code. Use with caution (i.e. only in a virtual machine).
Clone this repository, cd
to it, then run make
.
After building the module, run insmod tictactoe.ko
as root to load it.
After loading the module, player X can write grid coordinates
(ranging from 1 to 3, format XY
) to /dev/tictactoe
to make their first move:
# echo 12 > /dev/tictactoe
After player X has made their move, player O can do the same:
# echo 22 > /dev/tictactoe
To inspect the current state of the game, simply read from /dev/tictactoe
:
# cat /dev/tictactoe
#####
# X #
# O #
# #
#####
It's X's turn!
Alternatively, you can watch
the file in a separate terminal for automatic
updating:
# watch -n 0.5 cat /dev/tictactoe
To start a new game, write reset
to /dev/tictactoe
:
# echo reset > /dev/tictactoe
Run rmmod tictactoe
as root to unload the module.