Skip to content

Latest commit

 

History

History
75 lines (52 loc) · 2.39 KB

README.md

File metadata and controls

75 lines (52 loc) · 2.39 KB

TicTacToeTalk

A console TicTacToe game in Logtalk (3.36.0 or later), which you play against the computer.

workflow

This repo workflow automatically runs (on commit events) tests, publishes a code coverage report, and makes available as build artifacts the TAP report, the code coverage report, the API documentation, the source code diagrams, and the SWI-Prolog 8.1.x QLF files and saved state with the precompiled game.

How to play

Launch Logtalk and load the game:

?- {loader}.

Then you have a choice of difficulties:

?- game(easy)::play.

or

?- game(hard)::play.

or you can play against another human:

?- game('2p')::play.

In an easy game the computer makes random moves. In the hard game it uses a smart strategy to actively try and win, but not so smart that it's impossible to win!

Running the precompiled version (SWI-Prolog 8.1.x only)

Go to the commits list, click on the green check mark of the latest successful commit, and then click on details. On the build report page, click on the artifacts list and download both logtalk.qlf and application.qlf files. Uncompress the files, start SWI-Prolog, and load the files:

?- [logtalk, application].
...
true

After, use the queries in the section above to start the game.

Portability

Due to the use of non-ASCII characters to draw the board, the current version requires a backend that supports UTF-8 encoding. The game can currently be played on CxProlog, SICStus Prolog, SWI-Prolog, and YAP.

Design

We've tried to keep this a relatively simple but comprehensive example. So for the OO we're only using objects, parametric objects, and a couple of extensions.

A high-level view of the pre-development design (before any code!):

object model

The implementation generated by Logtalk from the source code:

inheritance_diagram

We've also made an effort to include documentation and unit tests to demonstrate the utility of the Logtalk ecosystem, hence the workflow badge and information above.