Lahore, Pakistan
← Back to Coursework

CS110 · CS110 - Programming Fundamentals

Gomoku

A configurable Gomoku strategy game originally developed as a Windows Console application in C++ and recreated as an interactive browser game with two-player and computer-opponent modes.

Overview

Gomoku was originally developed as a Programming Fundamentals coursework project using C++ and the Windows Console API.

The original application supports configurable board dimensions, custom player names and symbols, mouse-based input, turn management, computer play, and horizontal, vertical, and diagonal win detection.

The project was later recreated as a responsive browser game using HTML, CSS, and Vanilla JavaScript while preserving the original gameplay rules and logic.

Original C++ Implementation

The C++ version uses a two-dimensional board and allows the user to configure:

  • Number of rows
  • Number of columns
  • Number of stones required to win
  • Player names
  • Player symbols
  • Human vs Human mode
  • Human vs Computer mode

The Windows Console implementation uses mouse events to select cells and colored output to distinguish players.

Its win-detection system checks:

  • Horizontal lines
  • Vertical lines
  • Left diagonals
  • Right diagonals

Computer Opponent

The computer strategy follows the original coursework approach.

It:

  1. Checks whether it can win immediately
  2. Blocks an immediate opponent victory
  3. Selects the centre position when available
  4. Chooses another valid empty position as a fallback

Browser Recreation

The web version includes:

  • Player vs Computer
  • Two-player local mode
  • Configurable rows and columns
  • Configurable winning count
  • Custom player names
  • Custom player symbols
  • Random starting player
  • Immediate win detection
  • Correct win-before-draw handling
  • Highlighted winning stones
  • Prominent victory and draw messages
  • Restart control
  • Match activity log
  • Responsive layout
  • Keyboard-accessible board cells

Technical Approach

The original C++ board and validation functions were translated into JavaScript arrays and browser event handlers.

The same four win directions are checked after every move.

Temporary move simulation is used by the computer opponent to detect winning and blocking positions before making a move.

Corrections

The preserved corrected C++ version includes conservative fixes for:

  • Invalid board dimensions
  • Invalid winning counts
  • Duplicate or reserved symbols
  • Incorrect draw-before-win behavior
  • Mouse-event validation
  • Human vs Computer player-count handling
  • Cell-display positioning

The original submitted source remains preserved separately.

Repository Structure

The repository includes:

  • cpp/ — corrected C++ coursework source
  • cpp/original/ — original submitted source
  • website root — browser recreation
  • docs/ — fixes and feature-parity documentation

Outcome

The project demonstrates two-dimensional arrays, configurable game state, turn management, move simulation, computer decision-making, win detection, Windows Console interaction, and translation of a console program into a responsive browser experience.