This is a small experimental COBOL project I built to learn a little bit about COBOL. The goal was simple: see if COBOL could support basic interactive console behavior—specifically, moving an asterisk around the screen using the W/A/S/D keys.
It uses raw ANSI escape sequences for cursor control and a small C helper to handle non-blocking keyboard input (so the user doesn't have to press Enter). The original version got stuck in a classic AI rehash loop—ChatGPT kept giving plausible but ineffective tweaks. I revisited it later using the five Sens-AI habits (Context, Research, Problem Framing, Refining, and Critical Thinking), and that broke the loop and got everything working.
Make sure you have:
- A terminal that supports ANSI escape codes
cobc(from GNU COBOL)gcc
# Compile the C helper to capture raw keyboard input (without pressing enter)
gcc -fPIC -shared -o libgetch.so getch.c
# Compile and link the COBOL program with the C object file
cobc -x -o move-asterisk-raw move-asterisk-raw.cob -L. -lgetch
# Run the resulting binary
./move-asterisk-rawThe program should clear the screen and allow you to move the asterisk using the W, A, S, and D keys—without needing to hit Enter.
