Skip to content

smy-THU/connect4-OCaml

Repository files navigation

Web-Based Gravity Connect-4 Game

OCaml ReScript Dream

🔭 Overview 🔭

This repo implements a web-based Gravity Connect-4 with OCaml backend and ReScript frontend, communicating via Dream.

What is Gravity Connect-4?

  • Whoever connects 4 pieces in a row, column, or diagonal wins the game
  • In Gravity Connect-4, pieces fall to the lowest available spot in the column

🛠️ Usage 🛠️

dune clean && dune build
dune test && bisect-ppx-report html # optional
cd src
npm install
npm run start

then visit http://localhost:8080 to play the game!

✨ Features ✨

🎮 3 Levels of Agent Difficulty to Test Your Skills

🧩 Classic Gameplay + 2 Exciting New Variants!

  • Traditional Mode: Relive the nostalgic experience you love!
  • Random Blocker Mode: Adds unpredictability with randomly placed blockers.
  • Reward Mode: Reach the special reward spot to place an extra blocker – strategy at its finest!

🤝 Choose Who Goes First!

  • You First: Take control of the game and strategize your way to victory.
  • Agent First: Bring your A-game against our powerful AI opponents.

📏 Customizable Board Sizes (6x6 to 12x12)

  • Compact Boards: Perfect for quick, casual games.
  • Larger Boards: Explore endless strategies and more thrilling challenges!

🌟 Your Perfect Blend of Strategy, Fun, and Competition Awaits! 🌟

Game Theory Library

In "./src/lib", there are 3 general functors (minimax, alpha_beta and mcts) implementing 3 different algorithms for games involving 2 competitive players.

They can be allpied to any Game compatible with Game Type and get the agent for that game.

Command Line executables

In "./src", there are several executables to play the connect4 game with agent. For example, you can use

dune exec ./src/play_bonus_mcts.exe

to execute the command line game for BONUS playmode versus an agent based on MCTS.

Besides, you can use

dune exec ./src/pvp_bonus.ml

to execute the pvp game mode.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published