Skip to content

akshit404-exe/vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

♟️ Twixt Game (C Implementation)

A terminal-based implementation of the Twixt board game built in C. This project simulates a two-player strategy game where players create links between points to form a winning path across the board.


🎮 Game Overview

  • Two players: Red and Blue
  • Played on a 24 × 24 grid
  • Players take turns placing pieces
  • Automatic links are formed between valid positions
  • Links cannot intersect (core rule of Twixt)

🧠 Objective

  • 🔴 Red wins by connecting TOP → BOTTOM
  • 🔵 Blue wins by connecting LEFT → RIGHT

🚀 Features

🎯 Core Gameplay

  • Turn-based two-player system
  • Real-time board updates
  • Input validation for moves
  • Automatic link creation

🔗 Link System

  • Knight-move based linking (like chess)
  • Prevents crossing links using geometry
  • Highlights linked nodes

🧩 Win Detection

  • Graph traversal using DFS
  • Detects continuous path for victory
  • Efficient checking using visited matrix

🎨 Visual Output

  • Grid-based board display
  • Colored output for players
  • Highlighted linked connections

🛠️ Tech Stack

  • Language: C

  • Concepts Used:

    • Graph traversal (DFS)
    • Linked Lists
    • Geometry (line intersection)
    • Modular programming
    • Dynamic memory allocation

📂 Project Structure

Twixt/
│── Board_withmain.c / .h   # Game loop & board logic
│── Links.c / .h            # Link creation & intersection logic
│── Win_Win.c / .h          # Win detection (DFS traversal)
│── Makefile                # Build configuration

⚙️ How It Works

  • The board is initialized with empty cells
  • Each move updates the board and stores history
  • Valid links are created based on knight-move distance
  • Link intersections are prevented using cross-product logic
  • Win condition is checked using DFS traversal across links

▶️ How to Run

1. Compile using Makefile

make

2. Run the game

./twixt

🎮 How to Play

  1. Run the program
  2. Enter moves in format:
row column

Example:

5 12
  1. Players alternate turns automatically

💡 Key Highlights

  • Implements real Twixt game rules
  • Uses geometry to prevent illegal links
  • Applies graph theory (DFS) for win detection
  • Efficient memory usage with linked structures

📈 Future Improvements

  • Improve UI with better visuals
  • Multiplayer over network
  • Save/load game feature

This project is open-source and available under the MIT License.

About

This is a simplified version of Twixt written in C that runs in CLI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors