GithubHelp home page GithubHelp logo

adi-g15 / ludo-the_game Goto Github PK

View Code? Open in Web Editor NEW
25.0 6.0 16.0 3.85 MB

An implementation of the famous board game Ludo, using C++

License: MIT License

C++ 67.60% CMake 0.30% JavaScript 26.05% HTML 0.99% CSS 4.60% Shell 0.46%
game ludo terminal-game multithreading cpp cpp17 ludo-game

ludo-the_game's Introduction

CMake Codacy Badge deepcode CodeFactor Build Status

The repo now has a web version too, added by @Athi223, and is available in web/ directory, and deployed at https://ludo-the-game-a10a0.web.app/ πŸŽ‰

Ludo - The Game v2.0

Ludo, our popular Indian board game, completely implemented in C++

β€œScreenShot”

Ask any doubts in the #Discussions :D

Features

  • Easy and Powerful customisability (More in developer notes)
  • Variable number of inputs at all input fields
  • Shortcuts, Keywords, Cheat codes
  • Two robot modes -
    • RandomRobo
    • ThinkerRobo (it will chose the best possible move at a time, from almost 30-90 possibilities)
  • Display adaptive to width of screen
  • Memory-safe (using smart_pointers, and uncounted for 'new' statements)
  • Multi-threaded (for ThinkerRobo execution)
  • 0 dependencies outside stdc++ (for coloured output support, agauniyal.github.io/rang/ is utilised and included as a header rang.hpp)
  • Plus all basic ludo game features, and my own custom keywords (you can create yours too :D )

Building

On Linux & Windows -

mkdir build -p
cd build
cmake ..
cmake --build .

After building you will have a ludo.exe inside build/ (Linux) or build/{Debug,Release} (Windows), that's your executable πŸ˜ƒ

Installation

On Arch, simply run 'makepkg -si', the PKGBUILD file will handle rest

After #Building, run cmake --install .

Files in the Project

.
β”œβ”€β”€ extras
β”œβ”€β”€ util    # utility library
β”œβ”€β”€ includes
β”‚   β”œβ”€β”€ boardPrinter.hpp			# showing ludo board
β”‚   β”œβ”€β”€ rang.hpp					# for colored output
β”‚   β”œβ”€β”€ die.hpp						# die; functions for die roll
β”‚   β”œβ”€β”€ enums.hpp					# enums; (coord,colour,Player etc.)
|   β”œβ”€β”€ exceptions.hpp				# errors
|   β”œβ”€β”€ game.hpp					# **[MAIN]** The Game class (and all functions)
|   β”œβ”€β”€ keywords.hpp				# constants
|   β”œβ”€β”€ ludo_box.hpp				# :)
|   β”œβ”€β”€ ludo_coords.hpp				# Stores corners and home locations (coordinates, not fixed)
|   β”œβ”€β”€ ludo_goti.hpp				# :)
|   β”œβ”€β”€ ludo_state.hpp				# For robots, a lightweight class to store 'state'
β”‚   └── thinker.hpp					# For robots, thinker class, provides logic for robots
β”œβ”€β”€ src
|   β”œβ”€β”€ game.cpp
|   β”œβ”€β”€ ludo_box.cpp
|   β”œβ”€β”€ ludo_coords.cpp
|   β”œβ”€β”€ ludo_goti.cpp
|   β”œβ”€β”€ ludo_state.cpp
|   β”œβ”€β”€ thinker.cpp
β”œβ”€β”€ main.cpp
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ LICENSE.md
└── README.md

READING THE CODE

You DON'T need to understand 'all' code to understand this program

Discussion: If you can't understand something, simply ask that in 'Discussion' section, let's grow together !, we will reply :D

  1. Even though, the codebase may seem big, or confusing, you should see the "name of the functions" that gets called inside these, in this order -

    • main.cpp
    • board.cpp::Init_Game()
    • board.cpp::play()
  2. I think only seeing the names of functions calls in these, you would get the workflow of this(the functions have been named such)... then if you want, see the includes directory first, and for how the function is implemented, see src.

  3. //! or /**/ -> This syntax for comments has been used for giving info of the code.

The whole structure of the code is such that most things can be easily changed, to be able to show effect elsewehere too, some of which for eg.

  • To change Order of Gameplay, you only need to change one vector, ie. colourOrder<>

  • Different Players can be bound to different gotis, as you want, just update the colourMap and playerMap

  • To change Number of Gotis, just update the goti_per_user, and internally it just got implemented! No fuss

  • And, for display on output : In the updateDisplay(), may use if conditions to add an additional type2() row, for each +2 gotis of goti_per_user

  • In most apps, even if you get a 6, you have to decide your move then, but at our gaon, we could proceed to roll the die, till its not 6, YOU can opt any of those ways, for that, replace dieNumbers<> to a single integer!

  • Many more if when you search (yaar please consider point 1, if that's the case :-)

Contribution -

Start an issue for whatever feature you believe should be good here.

And, in case you want to be a contributer here, and work on it together, do ask.

Do sugggest any other feature you would like, i do claim the codebase to be quite modular, and easily customisable (It was what i used to think earlier, it IS modular enough to understand, i am not modifying it now, so as to keep it more original when i made it).

Thanks ! || ΰ€§ΰ€¨ΰ₯ΰ€―ΰ€΅ΰ€Ύΰ€¦ΰ₯ πŸ™

ludo-the_game's People

Contributors

abraham-john-paul avatar adi-g15 avatar athi223 avatar codacy-badger avatar code-factor avatar dependabot[bot] avatar imgbotapp avatar melakki avatar silentwatcher3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ludo-the_game's Issues

[Angular] Design a Ludo Board

This is #13 , but you can approach it with Angular(>=8)

Design a responsive webpage for a Ludo Board.

  • These issues are meant for beginners πŸ˜„

You can start with this ->

===============================================================================
                                LUDO - THE GAME
===============================================================================
                                                           |
                                                           |
                                                           |
                                                           |    --scoreboard--
                                                           |
                    --Board inside--                       |
                                                           |
                                                           |
                                                           |
                                                           |
                                                           |
                                                           |
-------------------------------------------------------------------------------
                                                           
                                --log area--                                                                                   

Approaching Goti removes already existing opponent goti, even at Safe Spots

In this case, originally there was a blue at the starting point in blue, then the Red goti moved a distance of 4 units, reaching the same spot, and the blue goti went back in locked positions.

Though safe spot logic works for other cases, this is a condition were it is unexpected behaviour, happened twice in the gameplay.

Expected Behaviour:
When the final position has a goti, THEN before attacking & removing, first check if it is one of the safe spots on the board, if it is, then just add this goti to list of gotis on the final box, if not then proceed to attack.

image

Case of three consecutive 6 in dice throw

In this case, what happens is since each dice throw result is one by one, so it doesn't know what were the previous outputs, so each 6 is treated differently.

Expected Behaviour: In case of 3 consecutive sixes, the moves should not be considered, ignore/roll back the moves (for a single colour only)

Follow practises for Better Code Quality

Though the repo maintains great standards according to automated review systems, but since there is always a scope to be better... codefactor.io gives a C rating to the repo, due to the complexity of code at particular files, so that is a great way to improve the code, as well as know what practises are recommended and what not, since as you go solving even a few suggestions from there, you will gain a lot πŸ‘πŸ½ .

Follow the suggestions from these review sites-
CodeFactor
Codacy

Screenshot (8)

Help me

I want create ludo game with c++, I don't know how to start!! Could anyone help me please!!

Extra Move after a Goti finishes

Notice the Green Goti, about to finish

Earlier:

image

After moving 1 unit (So, ek goti pung gayi, ie. one goti finished it's path):
image

Expected Behaviour:
One additional move (if not yet finished all 4) to the player/colour whose goti finishes.

[BUG] Correcting occurences of Direction::Left and Direction::Right in code

This is a note to myself, though if you like, you can work on it.

Describe the bug
In ludo_coords.cpp, occurences of Left and Right directions are to be exchanged, and so the affected code, using the ludo_coords class too, this can get dirty though.

To Reproduce
Nothing to reproduce, Code works fine, the problem is only at readable level, this problem, occured due to renaming the directions

Replace unsuitable occurences of const std::string& with std::string_view

It's as simple to just to replace all const std::string& with std::string_view, but chose the suitable ones.

You may read briefly about std::string_view here -> https://riptutorial.com/cplusplus/example/6571/using-the-std--string-view-class

Further Description, more technical
There are 19 occurences of const std::string& and 4 of const std::string &, but it some functions we just need the internal character array, like in trim_copy and other _copy functions.
Also, some functions that are more likely to be called like - foo("hi long string"), you don't need to bother yourself with that much though.

[HTML] Design a Ludo board

Design a responsive webpage for a Ludo Board, being displayed.
It will be used for the web version of this project, you should give it a good go, and it's fairly simple, and will be some code you can actually work on πŸ˜„ .

You can start with this ->

===============================================================================
                                LUDO - THE GAME
===============================================================================
                                                           |
                                                           |
                                                           |
                                                           |    --scoreboard--
                                                           |
                    --Board inside--                       |
                                                           |
                                                           |
                                                           |
                                                           |
                                                           |
                                                           |
-------------------------------------------------------------------------------
                                                           
                                --log area--                                                                                   

[ReactJS] Design a Ludo board

This is #13 , but you can approach it with ReactJS, which i will likely use in the web version, and you can be the prime contributor for that πŸ˜„

Design a responsive webpage for a Ludo Board, that will be utilized for this project's web version.

You can start with this ->

===============================================================================
                                LUDO - THE GAME
===============================================================================
                                                           |
                                                           |
                                                           |
                                                           |    --scoreboard--
                                                           |
                    --Board inside--                       |
                                                           |
                                                           |
                                                           |
                                                           |
                                                           |
                                                           |
-------------------------------------------------------------------------------
                                                           
                                --log area--                                                                                   

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.