Course:CPSC312-2023-TicTacToe2

From UBC Wiki

Authors: Rad, Tanay

What is the problem?

Tic Tac Toe is a very famous game and requires a very small setup to play. A game board and two symbols, X and O. The game board contains of 9 positions for each symbol. We will be implementing this game using pro log. It looked difficult in the beginning to visualise a game on prolog, but as we started to create the game and setup the board it made us understand how logical prolog programming is. We were easily able to understand each other's code, meaning that code interpretability was very good. The game can also be played in many ways, with a computer or with a friend.

What is the something extra?

We are going to implement the classic game of Tic Tac Toe, where we will add features to play with a computer or with another player. And for the version where you can play with the computer, we have added difficulty levels. To make the hard level actually hard, we added obstacles to the game to confuse the player. The obstacle basically is a random object added to one of the empty positions and that particular spot becomes unplayable for both the computer and the user.

What did we learn from doing this?

We started off thinking that coding a game might be difficult in prolog. Our previous project was pong and we heavily relied on making a nice GUI for the game which was possible on haskell but sounded risky on prolog. We chose a different and basic board game like TicTacToe, and we saw how easy it was to implement the basic structure of the game. The code were longer but easier to understand. We found ourselves rewriting a lot of similar lines for definition of a predicate but it made it easier to interpret. It was easier than haskell to implement a normal game but using visual libraries to make a GUI for the game looked very challenging.

Prolog wasn't very friendly with creating a GUI for a I/O system. We managed to display the game board in prolog to make it interpretable, so that was challenging in Prolog compared to haskell.

In the context of adding functionalities, we found it very easy to create a menu and give user choices and play the game accordingly. It was easy to add more functionality to the game.

Links to code etc.

https://github.students.cs.ubc.ca/ralmuall/312_TicTacToe_Project.git

References:

https://courses.cs.washington.edu/courses/cse341/03sp/slides/PrologEx/tictactoe.pl.txt