All Projects → ShaunLawrie → TicTacTOBOL

ShaunLawrie / TicTacTOBOL

Licence: MIT license
A basic "game" in COBOL for learning

Programming Languages

COBOL
34 projects

Labels

Tic Tac TOBOL

This is just a version of Tic Tac Toe in COBOL. It's not a great language for this type of thing but I wanted to learn something 😜

For instructions on how to build and run this see How to Play at the bottom of the readme.

I started by reading this on tutorialspoint.com and hacking together bits and pieces 'til it worked, I didn't copy a version of this game from anywhere so it's a bit spaghetti because it was just how I understood the game to work.

Using a file to define win conditions wasn't a very efficient way to do it but I wanted to do some basic file operations to see how it worked. Using REDEFINE and breaking the functionality into more paragraphs could massively simplify this version.

Another version of Tic Tac Toe is at this blog post on torquingwetstrainers which is a lot easier to read than mine as it doesn't use a full screen display, colors or a computer opponent.

You can compile COBOL in freeform with cobc -free which relaxes the old punchcard column enforcement so you don't have to start every line with at least 7 spaces to leave room for the punchcard margin but I wrote mine in the old format.

Example

Example Game cool-retro-term was used for this ^

Features

  • A terrible opponent that just picks random available squares
  • ASCII graphics

Future Enhancements

  • Blockchain
  • AI
  • Raytracing
  • Webscale

How to Play

Online

Here's a version that kind of works but you have to make all the move choices ahead of time in the STDIN tab. I quickly hacked together a version that works without a real terminal display or file operations so I could run it online http://tpcg.io/28wFoKOu.
Before you click "execute" paste some input into the STDIN tab e.g.

a1
a2
a3
b1
b2
b3
c1
c2
c3

Locally

This one uses a proper terminal display output and looks more like the gif above.

  1. Install a cobol compiler
    sudo apt install open-cobol
  2. Compile the COBOL file
    cobc -W -x -o TicTacTOBOL TicTacTOBOL.cbl
  3. Run the executable
    ./TicTacTOBOL
  4. Play the game
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].