Skip to content

Sasivarnasarma/ThreeMensMorris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Three Men's Morris (C++ & SFML)

๐Ÿงฉ A classic implementation of the ancient board game Three Men's Morris using C++ and the SFML graphics library. This is a two-player turn-based strategy game featuring placement, movement, and win detection via prime-number logic.

Note
This project was created as part of a University programming assignment.
When I started, I had no experience with SFML and only limited knowledge of C++ (and to be honest, I'm still learning!).
So the code might be a bit rough or unconventional in places.
If you spot anything that could be improved or have suggestions, feel free to open a pull request โ€” contributions are very welcome! ๐Ÿ˜Š

๐Ÿ•น๏ธ Game Preview

Click Me
Screen Shot 1
Start Menu
Screen Shot 2
Instructions Page
Screen Shot 3
About Page
Screen Shot 4
Playing Page
Screen Shot 5
Win Page A
Screen Shot 6
Win Page B

โœจ Features

  • ๐ŸŽฎ Two-player local game (Player A vs Player B)
  • ๐Ÿง  Efficient win detection using prime multiplication
  • ๐Ÿงฉ Smooth transitions between game phases: Start, Placement, Movement, and Win
  • ๐Ÿงผ Clean UI using custom textures and SFML
  • ๐Ÿ“ฆ Logs game activity to game.log
  • ๐Ÿ’ก Simple mouse-driven controls
  • ๐ŸŽจ Organized assets and modular code structure

๐Ÿ”ข Win Detection via Prime Multiplication

To detect if a player has aligned 3 tokens in a winning pattern, this project uses unique prime numbers assigned to each board slot:

| 0 | 1 | 2 | --> | 13 | 03 | 23 |

| 3 | 4 | 5 | --> | 17 | 11 | 05 |

| 6 | 7 | 8 | --> | 29 | 07 | 19 |

  • Each winning combination (row, column, or diagonal) has a unique product of its three primes.
  • A player's placed token primes are multiplied together.
  • If the player's total prime product is divisible by any winning combo product, they win.

โœ… This allows efficient win checking using basic arithmetic instead of nested loops or complex checks.


๐Ÿ”ง Installation & Run

๐Ÿ–ฅ๏ธ Option 1: Download Precompiled Executable

You can download a ready-to-run version of the game (including the required .dll files and assets) from the: โžก๏ธ GitHub Releases Page ๐Ÿ“ฆ The ZIP archive includes:

  • ThreeMensMorris.exe
  • required .dll files
  • assets/ folder (with images and UI textures) ๐Ÿ“‚ Just unzip and run .exe file!

๐Ÿ› ๏ธ Option 2: Build from Source

๐Ÿ“‹ Prerequisites

๐Ÿ–ฅ๏ธ Build Instructions

git  clone  https://github.com/Sasivarnasarma/ThreeMensMorris
cd  ThreeMensMorris
# Compile with g++ directly
g++  main.cpp  icon.res  -o  ThreeMensMorris  -lsfml-graphics  -lsfml-window  -lsfml-system  -mwindows

OR Compile via Visual Studio or MinGW with SFML linked

๐ŸชŸ Run Instructions

  • Place the compiled .exe file in the root project folder
  • Make sure the following are in place:
    • The assets/ folder (with all images, fonts, etc.) is in the same directory as the .exe
    • All required .dll files (e.g., sfml-graphics.dll, sfml-window.dll, etc.) are also in the same directory as the .exe

โ–ถ๏ธ How to Play

Controls: Mouse-only interface.

๐ŸŽฏ Objective

Get three of your tokens in a row โ€” horizontally, vertically, or diagonally โ€” before your opponent does.

โš™๏ธ Game Phases

๐ŸŸข Phase 1: Placement

  • Players take turns placing their 3 tokens on any empty circle on the board.
  • Once all tokens are placed, the game transitions to the movement phase.

๐Ÿ” Phase 2: Movement

  • On your turn, select one of your tokens.
  • Move it to an adjacent empty circle (no jumping allowed).
  • Use strategy to block your opponent and align your own tokens.

๐Ÿ† Winning the Game

  • The first player to form a straight line of three tokens โ€” horizontally, vertically, or diagonally โ€” wins!

๐Ÿ’ป Technologies Used

  • C++ โ€“ for implementing game logic, win detection, and event handling.
  • SFML (Simple and Fast Multimedia Library) โ€“ for graphics rendering, window control, and interaction.
  • draw.io โ€“ for planning UI layout, board design, and creating mockups
    โžค All design templates are included in the assets_drawio/ folder.

๐Ÿง  About the Project

This game was created as part of a university project, combining classic board game rules with modern graphics programming. The goal was to build a complete and playable graphical game using clean, efficient, and modular C++ code with SFML.

๐Ÿค Contributing

Contributions are welcome! If youโ€™d like to:

  • Add new features (AI opponent, sound effects, online multiplayer)
  • Improve the UI or UX
  • Fix bugs or optimize performance
  • Improve documentation Feel free to fork the repo and open a pull request

โญ Support

If you find this project helpful or fun, please consider giving it a Star โญ on GitHub โ€” it really helps the project grow, reach more people, and motivates me to keep improving it!

๐Ÿ“œ License

This project is licensed under the MIT License.

Made with โค๏ธ by Sasivarnasarma

About

๐Ÿงฉ A C++ implementation of Three Men's Morris using SFML โ€” features interactive gameplay, smooth animations, and win detection using prime number logic.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages