├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Documents ├── entry.png └── ludo_ai_gif.gif ├── Help to understand └── Position in Ludo board.png ├── Images ├── 1_block.png ├── 2_block.png ├── 3_block.png ├── 4_block.png ├── 5_block.png ├── 6_block.png └── ludo_icon.ico ├── LICENSE ├── Ludo_game_with_Sam.py └── README.md /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at samarpan2dasgupta@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | This documentation contains a set of guidelines to help you during the contribution process. 4 | We are happy to welcome all the contributions from anyone willing to improve/add new projects (doesn't matter which language) to this Repository. 5 | 6 | Code of Conduct 7 | --------------- 8 | 9 | ### Before contributing please ensure your **pull request** adheres to the following guidelines: 10 | 11 | ## STEP-1 : Find an issue 12 | - Take a look at the Existing [Issues](https://github.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/issues) and [Pull Requests](https://github.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/pulls) as yours may be a duplicate or create your own [Issues!](https://github.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/issues) 13 | 14 | - If your issue not an existing issue, then you can add new issue under [Issues](https://github.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/issues) 15 | 16 | - Wait for the Issue to be assigned to you after which you can start working on it. 17 | 18 | 19 | ## Step 2 : Fork the Project 20 | - Fork this Repository. This will create a Local Copy of this Repository on your Github Profile. Keep a reference to the original project in `upstream` remote. 21 | ``` 22 | $ git clone https://github.com// 23 | $ cd 24 | $ git remote add upstream https://github.com// 25 | ``` 26 | 27 | - If you have already forked the project, update your copy before working. 28 | ``` 29 | $ git remote update 30 | $ git checkout 31 | $ git rebase upstream/ 32 | ``` 33 | 34 | ## Step 3 : Choose your domain. 35 | - Create a branch : 36 | ``` 37 | $ git branch 38 | $ git checkout 39 | 40 | ``` 41 | 42 | - Add your projects to a folder and the folder name should be your project . 43 | - Add all the files/folders needed. 44 | - After you've made changes or made your contribution to the project add changes to the branch you've just created by: 45 | ``` 46 | # To add only a few files to Branch_Name 47 | $ git add 48 | # To add only a few files to Branch_Name 49 | $ git add 50 | ``` 51 | 52 | 53 | ## Step 4 : Commit 54 | - To commit give a descriptive message for the convenience of reviewer by: 55 | - Please make an individual commit for each suggestion in a separate pull request. 56 | - Check your spelling and grammar. 57 | - Remove any trailing whitespace. 58 | ``` 59 | # This message get associated with all files you have changed 60 | $ git commit -m "message" 61 | ``` 62 | 63 | ## Step 5 : Work Remotely 64 | - Now you are ready to your work to the remote repository. 65 | - When your work is ready and complies with the project conventions, upload your changes to your fork: 66 | 67 | ``` 68 | # To push your work to your remote repository 69 | $ git push -u origin Branch_Name 70 | ``` 71 | 72 | ## Step 6 : Pull Request 73 | - Go to your repository in browser and click on compare and pull requests. Then add a title and description to your pull request that explains your contribution. 74 | - Make sure your PR easy to review. That means having a clear description and only touching code that's necessary for your change. 75 | - Check your spelling and grammar. 76 | - Remove any trailing whitespace. 77 | 78 | **Note** : 79 | - New categories, or improvements to the existing categorisation, are always welcome. 80 | - Being an open source contributor doesn't just mean writing code, either. You can help out by writing documentation, tests, or even giving suggestions. 🏆 81 | 82 | ## Need more help?🤔 83 | You can refer to the following articles on basics of Git and Github and also contact the Project [Mentor](https://github.com/Kushal997-das/), in case you are stuck: 84 | - [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) 85 | - [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-an-issue-or-pull-request) 86 | - [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github) 87 | - [Getting started with Git and GitHub](https://towardsdatascience.com/getting-started-with-git-and-github-6fcd0f2d4ac6) 88 | - [Learn GitHub from Scratch](https://www.youtube.com/watch?v=BCQHnlnPusY&list=PLozRqGzj97d02YjR5JVqDwN2K0cAiT7VK) 89 | 90 | Tip from us😇 91 | ------------- 92 | It always takes time to understand and learn. So, do not worry at all. We know you have got this!💪 93 | -------------------------------------------------------------------------------- /Documents/entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Documents/entry.png -------------------------------------------------------------------------------- /Documents/ludo_ai_gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Documents/ludo_ai_gif.gif -------------------------------------------------------------------------------- /Help to understand/Position in Ludo board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Help to understand/Position in Ludo board.png -------------------------------------------------------------------------------- /Images/1_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/1_block.png -------------------------------------------------------------------------------- /Images/2_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/2_block.png -------------------------------------------------------------------------------- /Images/3_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/3_block.png -------------------------------------------------------------------------------- /Images/4_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/4_block.png -------------------------------------------------------------------------------- /Images/5_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/5_block.png -------------------------------------------------------------------------------- /Images/6_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/6_block.png -------------------------------------------------------------------------------- /Images/ludo_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/e6e8c2ab6ece3f876db23c579bc706b6790bd774/Images/ludo_icon.ico -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Ludo_game_with_Sam.py: -------------------------------------------------------------------------------- 1 | # Ludo game Integrated With AI # 2 | from tkinter import * 3 | from tkinter import messagebox 4 | from PIL import Image,ImageTk 5 | import time 6 | from random import randint, choice 7 | 8 | class Ludo: 9 | def __init__(self, root,six_side_block,five_side_block,four_side_block,three_side_block,two_side_block,one_side_block): 10 | self.window = root 11 | # Make canvas 12 | self.make_canvas = Canvas(self.window, bg="#141414", width=800, height=630) 13 | self.make_canvas.pack(fill=BOTH,expand=1) 14 | 15 | # Make some containers to store data 16 | self.made_red_coin = [] 17 | self.made_green_coin = [] 18 | self.made_yellow_coin = [] 19 | self.made_sky_blue_coin = [] 20 | 21 | self.red_number_label = [] 22 | self.green_number_label = [] 23 | self.yellow_number_label = [] 24 | self.sky_blue_number_label = [] 25 | 26 | self.block_value_predict = [] 27 | self.total_people_play = [] 28 | 29 | # Ludo block all side image store 30 | self.block_number_side = [one_side_block, two_side_block, three_side_block, four_side_block, five_side_block, six_side_block] 31 | 32 | # Use for store specific position of all coins 33 | self.red_coord_store = [-1, -1, -1, -1] 34 | self.green_coord_store = [-1, -1, -1, -1] 35 | self.yellow_coord_store = [-1, -1, -1, -1] 36 | self.sky_blue_coord_store = [-1, -1, -1, -1] 37 | 38 | self.red_coin_position = [0, 1, 2, 3] 39 | self.green_coin_position = [0, 1, 2, 3] 40 | self.yellow_coin_position = [0, 1, 2, 3] 41 | self.sky_blue_coin_position = [0, 1, 2, 3] 42 | 43 | for index in range(len(self.red_coin_position)):# Specific coin position set to -1 by default 44 | self.red_coin_position[index] = -1 45 | self.green_coin_position[index] = -1 46 | self.yellow_coin_position[index] = -1 47 | self.sky_blue_coin_position[index] = -1 48 | 49 | # Number to room to be traverse by specific color coin, store in that variable 50 | self.move_red_counter = 0 51 | self.move_green_counter = 0 52 | self.move_yellow_counter = 0 53 | self.move_sky_blue_counter = 0 54 | 55 | self.take_permission = 0 56 | self.six_with_overlap = 0 57 | 58 | self.red_store_active = 0 59 | self.sky_blue_store_active = 0 60 | self.yellow_store_active = 0 61 | self.green_store_active = 0 62 | 63 | self.six_counter = 0 64 | self.time_for = -1 65 | 66 | # Some variables initializes with None 67 | self.right_star = None 68 | self.down_star = None 69 | self.left_star = None 70 | self.up_star = None 71 | 72 | # Robo Control 73 | self.robo_prem = 0 74 | self.count_robo_stage_from_start = 0 75 | self.robo_store = [] 76 | 77 | # By default some function call 78 | self.board_set_up() 79 | 80 | self.instruction_btn_red() 81 | self.instruction_btn_sky_blue() 82 | self.instruction_btn_yellow() 83 | self.instruction_btn_green() 84 | 85 | self.take_initial_control() 86 | 87 | 88 | def board_set_up(self): 89 | # Cover Box made 90 | self.make_canvas.create_rectangle(100, 15, 100 + (40 * 15), 15 + (40 * 15), width=6, fill="white") 91 | 92 | # Square box 93 | self.make_canvas.create_rectangle(100, 15, 100+240, 15+240, width=3, fill="red")# left up large square 94 | self.make_canvas.create_rectangle(100, (15+240)+(40*3), 100+240, (15+240)+(40*3)+(40*6), width=3, fill="#04d9ff")# left down large square 95 | self.make_canvas.create_rectangle(340+(40*3), 15, 340+(40*3)+(40*6), 15+240, width=3, fill="#00FF00")# right up large square 96 | self.make_canvas.create_rectangle(340+(40*3), (15+240)+(40*3), 340+(40*3)+(40*6), (15+240)+(40*3)+(40*6), width=3, fill="yellow")# right down large square 97 | 98 | # Left 3 box(In white region) 99 | self.make_canvas.create_rectangle(100, (15+240), 100+240, (15+240)+40, width=3) 100 | self.make_canvas.create_rectangle(100+40, (15 + 240)+40, 100 + 240, (15 + 240) + 40+40, width=3, fill="#F00000") 101 | self.make_canvas.create_rectangle(100, (15 + 240)+80, 100 + 240, (15 + 240) + 80+40, width=3) 102 | 103 | # right 3 box(In white region) 104 | self.make_canvas.create_rectangle(100+240, 15, 100 + 240+40, 15 + (40*6), width=3) 105 | self.make_canvas.create_rectangle(100+240+40, 15+40, 100+240+80, 15 + (40*6), width=3, fill="#00FF00") 106 | self.make_canvas.create_rectangle(100+240+80, 15, 100 + 240+80+40, 15 + (40*6), width=3) 107 | 108 | # up 3 box(In white region) 109 | self.make_canvas.create_rectangle(340+(40*3), 15+240, 340+(40*3)+(40*6), 15+240+40, width=3) 110 | self.make_canvas.create_rectangle(340+(40*3), 15+240+40, 340+(40*3)+(40*6)-40, 15+240+80, width=3, fill="yellow") 111 | self.make_canvas.create_rectangle(340+(40*3), 15+240+80, 340+(40*3)+(40*6), 15+240+120, width=3) 112 | 113 | # down 3 box(In white region) 114 | self.make_canvas.create_rectangle(100, (15 + 240)+(40*3), 100 + 240+40, (15 + 240)+(40*3)+(40*6), width=3) 115 | self.make_canvas.create_rectangle(100+240+40, (15 + 240)+(40*3), 100 + 240+40+40, (15 + 240)+(40*3)+(40*6)-40, width=3, fill="#04d9ff") 116 | self.make_canvas.create_rectangle(100 + 240+40+40, (15 + 240)+(40*3), 100 + 240+40+40+40, (15 + 240)+(40*3)+(40*6), width=3) 117 | 118 | # All left separation line 119 | start_x = 100 + 40 120 | start_y = 15 + 240 121 | end_x = 100 + 40 122 | end_y = 15 + 240 + (40 * 3) 123 | for _ in range(5): 124 | self.make_canvas.create_line(start_x, start_y, end_x, end_y, width=3) 125 | start_x+=40 126 | end_x+= 40 127 | 128 | # All right separation line 129 | start_x = 100+240+(40*3)+40 130 | start_y = 15 + 240 131 | end_x = 100+240+(40*3)+40 132 | end_y = 15 + 240 + (40 * 3) 133 | for _ in range(5): 134 | self.make_canvas.create_line(start_x, start_y, end_x, end_y, width=3) 135 | start_x += 40 136 | end_x += 40 137 | 138 | # All up separation done 139 | start_x = 100+240 140 | start_y = 15+40 141 | end_x = 100+240+(40*3) 142 | end_y = 15+40 143 | for _ in range(5): 144 | self.make_canvas.create_line(start_x, start_y, end_x, end_y, width=3) 145 | start_y += 40 146 | end_y += 40 147 | 148 | # All down separation done 149 | start_x = 100 + 240 150 | start_y = 15 + (40*6)+(40*3)+40 151 | end_x = 100 + 240 + (40 * 3) 152 | end_y = 15 + (40*6)+(40*3)+40 153 | for _ in range(5): 154 | self.make_canvas.create_line(start_x, start_y, end_x, end_y, width=3) 155 | start_y += 40 156 | end_y += 40 157 | 158 | # Square box(Coins containers) white region make 159 | self.make_canvas.create_rectangle(100+20, 15+40-20, 100 + 40 + 60 + 40 +60+20, 15+40+40+40+100-20, width=3, fill="white") 160 | self.make_canvas.create_rectangle(340+(40*3)+40 - 20, 15 + 40-20, 340+(40*3)+40 + 60 + 40 + 40+20+20, 15+40+40+40+100-20, width=3, fill="white") 161 | self.make_canvas.create_rectangle(100+20, 340+80-20+15, 100 + 40 + 60 + 40 +60+20, 340+80+60+40+40+20+15, width=3, fill="white") 162 | self.make_canvas.create_rectangle(340+(40*3)+40 - 20, 340 + 80 - 20+15, 340+(40*3)+40 + 60 + 40 + 40+20+20, 340 + 80 + 60 + 40 + 40 + 20+15, width=3, fill="white") 163 | 164 | 165 | # Left up square inside box made 166 | self.make_canvas.create_rectangle(100+40, 15+40, 100+40+40, 15+40+40, width=3, fill="red") 167 | self.make_canvas.create_rectangle(100+40+60+60, 15 + 40, 100+40+60+40+60, 15 + 40 + 40, width=3, fill="red") 168 | self.make_canvas.create_rectangle(100 + 40, 15 + 40+100, 100 + 40 + 40, 15 + 40 + 40+100, width=3, fill="red") 169 | self.make_canvas.create_rectangle(100 + 40 + 60 + 60, 15 + 40+100, 100 + 40 + 60 + 40 +60, 15 + 40 + 40+100, width=3, fill="red") 170 | 171 | 172 | # Right up square inside box made 173 | self.make_canvas.create_rectangle(340+(40*3)+40, 15 + 40, 340+(40*3)+40 + 40, 15 + 40 + 40, width=3, fill="#00FF00") 174 | self.make_canvas.create_rectangle(340+(40*3)+40+ 60 + 40+20, 15 + 40, 340+(40*3)+40 + 60 + 40 + 40+20, 15 + 40 + 40, width=3, fill="#00FF00") 175 | self.make_canvas.create_rectangle(340+(40*3)+40, 15 + 40 + 100, 340+(40*3)+40 + 40, 15 + 40 + 40 + 100, width=3, fill="#00FF00") 176 | self.make_canvas.create_rectangle(340+(40*3)+40+ 60 + 40+20, 15 + 40 + 100, 340+(40*3)+40 + 60 + 40 + 40+20, 15 + 40 + 40 + 100, width=3, fill="#00FF00") 177 | 178 | 179 | # Left down square inside box made 180 | self.make_canvas.create_rectangle(100 + 40, 340+80+15, 100 + 40 + 40, 340+80+40+15, width=3, fill="#04d9ff") 181 | self.make_canvas.create_rectangle(100 + 40 + 60 + 40+20, 340+80+15, 100 + 40 + 60 + 40 + 40+20, 340+80+40+15, width=3, fill="#04d9ff") 182 | self.make_canvas.create_rectangle(100 + 40, 340+80+60+40+15, 100 + 40 + 40, 340+80+60+40+40+15, width=3, fill="#04d9ff") 183 | self.make_canvas.create_rectangle(100 + 40 + 60 + 40+20, 340+80+60+40+15, 100 + 40 + 60 + 40 + 40+20, 340+80+60+40+40+15, width=3, fill="#04d9ff") 184 | 185 | 186 | # Right down square inside box made 187 | self.make_canvas.create_rectangle(340 + (40 * 3) + 40, 340+80+15, 340 + (40 * 3) + 40 + 40, 340+80+40+15, width=3, fill="yellow") 188 | self.make_canvas.create_rectangle(340 + (40 * 3) + 40 + 60 + 40+20, 340+80+15, 340 + (40 * 3) + 40 + 60 + 40 + 40+20, 340+80+40+15, width=3, fill="yellow") 189 | self.make_canvas.create_rectangle(340 + (40 * 3) + 40, 340+80+60+40+15, 340 + (40 * 3) + 40 + 40,340+80+60+40+40+15, width=3, fill="yellow") 190 | self.make_canvas.create_rectangle(340 + (40 * 3) + 40 + 60 + 40+20, 340+80+60+40+15,340 + (40 * 3) + 40 + 60 + 40 + 40+20, 340+80+60+40+40+15, width=3, fill="yellow") 191 | 192 | # sky_blue start position 193 | self.make_canvas.create_rectangle(100+240,340+(40*5)-5,100+240+40,340+(40*6)-5,fill="#04d9ff",width=3) 194 | # Red start position 195 | self.make_canvas.create_rectangle(100 + 40, 15+(40*6), 100 +40 + 40, 15+(40*6)+40, fill="red", width=3) 196 | # Green start position 197 | self.make_canvas.create_rectangle(100 + (40*8), 15 + 40, 100 +(40*9), 15 + 40+ 40, fill="#00FF00", width=3) 198 | # Yellow start position 199 | self.make_canvas.create_rectangle(100 + (40 * 6)+(40*3)+(40*4), 15 + (40*8), 100 + (40 * 6)+(40*3)+(40*5), 15 + (40*9), fill="yellow", width=3) 200 | 201 | # Traingle in middle 202 | self.make_canvas.create_polygon(100+240, 15+240, 100+240+60, 15+240+60, 100+240, 15+240+(40*3), width=3,fill="red",outline="black") 203 | self.make_canvas.create_polygon(100 + 240+(40*3), 15 + 240, 100 + 240 + 60, 15 + 240 + 60, 100 + 240+(40*3), 15 + 240 + (40 * 3), width=3, fill="yellow",outline="black") 204 | self.make_canvas.create_polygon(100 + 240, 15 + 240, 100 + 240 + 60, 15 + 240 + 60, 100 + 240 + (40 * 3), 15 + 240, width=3, fill="#00FF00",outline="black") 205 | self.make_canvas.create_polygon(100 + 240, 15 + 240+(40*3), 100 + 240 + 60, 15 + 240 + 60, 100 + 240 + (40 * 3), 15 + 240+(40*3), width=3, fill="#04d9ff",outline="black") 206 | 207 | # Make coin for red left up block 208 | red_1_coin = self.make_canvas.create_oval(100+40, 15+40, 100+40+40, 15+40+40, width=3, fill="red", outline="black") 209 | red_2_coin = self.make_canvas.create_oval(100+40+60+60, 15 + 40, 100+40+60+60+40, 15 + 40 + 40, width=3, fill="red", outline="black") 210 | red_3_coin = self.make_canvas.create_oval(100 + 40 + 60 + 60, 15 + 40 + 100, 100 + 40 + 60 + 60 + 40, 15 + 40 + 40 + 100, width=3, fill="red", outline="black") 211 | red_4_coin = self.make_canvas.create_oval(100 + 40, 15 + 40+100, 100 + 40 + 40, 15 + 40 + 40+100, width=3,fill="red", outline="black") 212 | self.made_red_coin.append(red_1_coin) 213 | self.made_red_coin.append(red_2_coin) 214 | self.made_red_coin.append(red_3_coin) 215 | self.made_red_coin.append(red_4_coin) 216 | 217 | # Make coin under number label for red left up block 218 | red_1_label = Label(self.make_canvas, text="1", font=("Arial", 15, "bold"), bg="red", fg="black") 219 | red_1_label.place(x=100 + 40 + 10, y=15 + 40 + 5) 220 | red_2_label = Label(self.make_canvas, text="2", font=("Arial", 15, "bold"), bg="red", fg="black") 221 | red_2_label.place(x=100 + 40 + 60 + 60 + 10, y=15 + 40 + 5) 222 | red_3_label = Label(self.make_canvas, text="3", font=("Arial", 15, "bold"), bg="red", fg="black") 223 | red_3_label.place(x=100 + 40 + 60 + 60 + 10, y=15 + 40 + 100 + 5) 224 | red_4_label = Label(self.make_canvas, text="4", font=("Arial", 15, "bold"), bg="red", fg="black") 225 | red_4_label.place(x=100 + 40 + 10, y=15 + 40 + 100 + 5) 226 | self.red_number_label.append(red_1_label) 227 | self.red_number_label.append(red_2_label) 228 | self.red_number_label.append(red_3_label) 229 | self.red_number_label.append(red_4_label) 230 | 231 | # Make coin for green right up block 232 | green_1_coin = self.make_canvas.create_oval(340+(40*3)+40, 15 + 40, 340+(40*3)+40 + 40, 15 + 40 + 40, width=3, fill="#00FF00", outline="black") 233 | green_2_coin = self.make_canvas.create_oval(340+(40*3)+40+ 60 + 40+20, 15 + 40, 340+(40*3)+40 + 60 + 40 + 40+20, 15 + 40 + 40, width=3, fill="#00FF00", outline="black") 234 | green_3_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40 + 60 + 40 + 20, 15 + 40 + 100, 340 + (40 * 3) + 40 + 60 + 40 + 40 + 20, 15 + 40 + 40 + 100, width=3, fill="#00FF00", outline="black") 235 | green_4_coin = self.make_canvas.create_oval(340+(40*3)+40, 15 + 40 + 100, 340+(40*3)+40 + 40, 15 + 40 + 40 + 100, width=3, fill="#00FF00", outline="black") 236 | self.made_green_coin.append(green_1_coin) 237 | self.made_green_coin.append(green_2_coin) 238 | self.made_green_coin.append(green_3_coin) 239 | self.made_green_coin.append(green_4_coin) 240 | 241 | # Make coin under number label for green right up block 242 | green_1_label = Label(self.make_canvas, text="1", font=("Arial", 15, "bold"), bg="#00FF00", fg="black") 243 | green_1_label.place(x=340 + (40 * 3) + 40 + 10, y=15 + 40 + 5) 244 | green_2_label = Label(self.make_canvas, text="2", font=("Arial", 15, "bold"), bg="#00FF00", fg="black") 245 | green_2_label.place(x=340 + (40 * 3) + 40 + 40 + 60 + 30, y=15 + 40 + 5) 246 | green_3_label = Label(self.make_canvas, text="3", font=("Arial", 15, "bold"), bg="#00FF00", fg="black") 247 | green_3_label.place(x=340 + (40 * 3) + 40 + 40 + 60 + 30, y=15 + 40 + 100 + 5) 248 | green_4_label = Label(self.make_canvas, text="4", font=("Arial", 15, "bold"), bg="#00FF00", fg="black") 249 | green_4_label.place(x=340 + (40 * 3) + 40 + 10, y=15 + 40 + 100 + 5) 250 | self.green_number_label.append(green_1_label) 251 | self.green_number_label.append(green_2_label) 252 | self.green_number_label.append(green_3_label) 253 | self.green_number_label.append(green_4_label) 254 | 255 | # Make coin for sky_blue left down block 256 | sky_blue_1_coin = self.make_canvas.create_oval(100 + 40, 340+80+15, 100 + 40 + 40, 340+80+40+15, width=3, fill="#04d9ff", outline="black") 257 | sky_blue_2_coin = self.make_canvas.create_oval(100 + 40 + 60 + 40+20, 340+80+15, 100 + 40 + 60 + 40 + 40+20, 340+80+40+15, width=3, fill="#04d9ff", outline="black") 258 | sky_blue_3_coin = self.make_canvas.create_oval(100 + 40 + 60 + 40 + 20, 340 + 80 + 60 + 40 + 15, 100 + 40 + 60 + 40 + 40 + 20, 340 + 80 + 60 + 40 + 40 + 15, width=3, fill="#04d9ff", outline="black") 259 | sky_blue_4_coin = self.make_canvas.create_oval( 100 + 40, 340+80+60+40+15, 100 + 40 + 40, 340+80+60+40+40+15, width=3, fill="#04d9ff", outline="black") 260 | self.made_sky_blue_coin.append(sky_blue_1_coin) 261 | self.made_sky_blue_coin.append(sky_blue_2_coin) 262 | self.made_sky_blue_coin.append(sky_blue_3_coin) 263 | self.made_sky_blue_coin.append(sky_blue_4_coin) 264 | 265 | # Make coin under number label for sky_blue left down block 266 | sky_blue_1_label = Label(self.make_canvas, text="1", font=("Arial", 15, "bold"), bg="#04d9ff", fg="black") 267 | sky_blue_1_label.place(x=100 + 40 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 10) 268 | sky_blue_2_label = Label(self.make_canvas, text="2", font=("Arial", 15, "bold"), bg="#04d9ff", fg="black") 269 | sky_blue_2_label.place(x=100 + 40 + 60 + 60 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 10) 270 | sky_blue_3_label = Label(self.make_canvas, text="3", font=("Arial", 15, "bold"), bg="#04d9ff", fg="black") 271 | sky_blue_3_label.place(x=100 + 40 + 60 + 60 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 60 + 40 + 10) 272 | sky_blue_4_label = Label(self.make_canvas, text="4", font=("Arial", 15, "bold"), bg="#04d9ff", fg="black") 273 | sky_blue_4_label.place(x=100 + 40 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 60 + 40 + 10) 274 | self.sky_blue_number_label.append(sky_blue_1_label) 275 | self.sky_blue_number_label.append(sky_blue_2_label) 276 | self.sky_blue_number_label.append(sky_blue_3_label) 277 | self.sky_blue_number_label.append(sky_blue_4_label) 278 | 279 | # Make coin for yellow right down block 280 | yellow_1_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40, 340+80+15, 340 + (40 * 3) + 40 + 40, 340+80+40+15, width=3, fill="yellow", outline="black") 281 | yellow_2_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40 + 60 + 40 + 20, 340+80+15, 340 + (40 * 3) + 40 + 60 + 40 + 40+20, 340+80+40+15, width=3, fill="yellow", outline="black") 282 | yellow_3_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40 + 60 + 40 + 20, 340 + 80 + 60 + 40 + 15, 340 + (40 * 3) + 40 + 60 + 40 + 40 + 20, 340 + 80 + 60 + 40 + 40 + 15, width=3, fill="yellow", outline="black") 283 | yellow_4_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40, 340+80+60+40+15, 340 + (40 * 3) + 40 + 40,340+80+60+40+40+15, width=3, fill="yellow", outline="black") 284 | self.made_yellow_coin.append(yellow_1_coin) 285 | self.made_yellow_coin.append(yellow_2_coin) 286 | self.made_yellow_coin.append(yellow_3_coin) 287 | self.made_yellow_coin.append(yellow_4_coin) 288 | 289 | # Make coin under number label for yellow right down block 290 | yellow_1_label = Label(self.make_canvas, text="1", font=("Arial", 15, "bold"), bg="yellow", fg="black") 291 | yellow_1_label.place(x=340 + (40 * 3) + 40 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 10) 292 | yellow_2_label = Label(self.make_canvas, text="2", font=("Arial", 15, "bold"), bg="yellow", fg="black") 293 | yellow_2_label.place(x=340 + (40 * 3) + 40 + 40 + 60 + 30, y=30 + (40 * 6) + (40 * 3) + 40 + 10) 294 | yellow_3_label = Label(self.make_canvas, text="3", font=("Arial", 15, "bold"), bg="yellow", fg="black") 295 | yellow_3_label.place(x=340 + (40 * 3) + 40 + 40 + 60 + 30, y=30 + (40 * 6) + (40 * 3) + 40 + 100 + 10) 296 | yellow_4_label = Label(self.make_canvas, text="4", font=("Arial", 15, "bold"), bg="yellow", fg="black") 297 | yellow_4_label.place(x=340 + (40 * 3) + 40 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 100 + 10) 298 | self.yellow_number_label.append(yellow_1_label) 299 | self.yellow_number_label.append(yellow_2_label) 300 | self.yellow_number_label.append(yellow_3_label) 301 | self.yellow_number_label.append(yellow_4_label) 302 | 303 | # Make star safe zone 304 | """ 305 | A 306 | L * B 307 | K * * * * * * C 308 | * * 309 | J * * D 310 | * * 311 | I* * * * * * E 312 | H * F 313 | G 314 | """ 315 | # Right star 316 | common_x = 340+(40*6)+20 317 | common_y = 15+240+2 318 | # A B C D E F G H I J K L 319 | coord = [common_x,common_y, common_x+5,common_y+15, common_x+15,common_y+15, common_x+8,common_y+20, common_x+15,common_y+25, common_x+5,common_y+25, common_x,common_y+25+10, common_x-5,common_y+25, common_x-16,common_y+25, common_x-8,common_y+15+5, common_x-15,common_y+15, common_x-5,common_y+15] 320 | self.make_canvas.create_polygon(coord,width=3,fill="blue") 321 | 322 | # Up star 323 | common_x = 100+240+2+18 324 | common_y = 15 + (40*2) + 2 325 | # A B C D E F G H I J K L 326 | coord = [common_x, common_y, common_x + 5, common_y + 15, common_x + 15, common_y + 15, common_x + 8, common_y + 20, common_x + 15, common_y + 25, common_x + 5, common_y + 25, common_x, common_y + 25 + 10, common_x - 5, common_y + 25, common_x - 16, common_y + 25, common_x - 8,common_y + 15 + 5, common_x - 15,common_y + 15, common_x - 5,common_y + 15] 327 | self.make_canvas.create_polygon(coord, width=3, fill="blue") 328 | 329 | # Left star 330 | common_x = 100 + (40*2) + 2 +18 331 | common_y = 15 + 240+(40*2) + 2 332 | # A B C D E F G H I J K L 333 | coord = [common_x, common_y, common_x + 5, common_y + 15, common_x + 15, common_y + 15, common_x + 8,common_y + 20, common_x + 15, common_y + 25, common_x + 5, common_y + 25, common_x, common_y + 25 + 10, common_x - 5, common_y + 25, common_x - 16, common_y + 25, common_x - 8, common_y + 15 + 5, common_x - 15, common_y + 15, common_x - 5, common_y + 15] 334 | self.make_canvas.create_polygon(coord, width=3, fill="blue") 335 | 336 | # Down star 337 | common_x = 100 + 240 + (40*2) + 2 + 18 338 | common_y = 15 + (40 * 6) + (40*3)+(40*3)+2 339 | # A B C D E F G H I J K L 340 | coord = [common_x, common_y, common_x + 5, common_y + 15, common_x + 15, common_y + 15, common_x + 8, common_y + 20, common_x + 15, common_y + 25, common_x + 5, common_y + 25, common_x, common_y + 25 + 10, common_x - 5, common_y + 25, common_x - 16, common_y + 25, common_x - 8, common_y + 15 + 5, common_x - 15, common_y + 15, common_x - 5, common_y + 15] 341 | self.make_canvas.create_polygon(coord, width=3, fill="blue") 342 | 343 | 344 | # Total number of players: Control take at first 345 | def take_initial_control(self): 346 | for i in range(4): 347 | self.block_value_predict[i][1]['state'] = DISABLED 348 | 349 | # Make other window to control take 350 | top = Toplevel() 351 | top.geometry("530x300") 352 | top.maxsize(530,300) 353 | top.minsize(530,300) 354 | top.config(bg="#141414") 355 | top.iconbitmap("Images/ludo_icon.ico") 356 | 357 | head = Label(top,text="-:Total number of players:- ",font=("Arial",25,"bold","italic"),bg="#141414",fg="chocolate") 358 | head.place(x=50,y=30) 359 | take_entry = Entry(top,font=("Arial",18,"bold","italic"),relief=SUNKEN,bd=5,width=12, state=DISABLED) 360 | take_entry.place(x=130,y=85) 361 | take_entry.focus() 362 | 363 | def filtering():# Total player input value filtering 364 | def input_filtering(coin_number):# Input value Filtering 365 | try: 366 | return True if (4>=int(coin_number)>=2) or type(coin_number) == int else False 367 | except: 368 | return False 369 | 370 | response_take = input_filtering(take_entry.get()) 371 | if response_take: 372 | for player_index in range(int(take_entry.get())): 373 | self.total_people_play.append(player_index) 374 | print(self.total_people_play) 375 | self.make_command() 376 | top.destroy() 377 | else: 378 | messagebox.showerror("Input Error", "Please input number of players between 2 and 4") 379 | top.destroy() 380 | self.take_initial_control() 381 | 382 | submit_btn = Button(top,text="Submit",bg="#262626",fg="#00FF00",font=("Arial",13,"bold"),relief=RAISED,bd=3,command=filtering,state=DISABLED) 383 | submit_btn.place(x=330,y=87) 384 | 385 | def operate(ind): 386 | if ind: 387 | self.robo_prem = 1 388 | for player_index in range(2): 389 | self.total_people_play.append(player_index) 390 | print(self.total_people_play) 391 | def delay_with_instrctions(time_is): 392 | if place_ins['text'] != "": 393 | place_ins.place_forget() 394 | if command_play['text'] != "": 395 | command_play.place_forget() 396 | 397 | place_ins['text'] = f" Your game will start within {time_is} sec" 398 | place_ins.place(x=20, y=220) 399 | 400 | if time_is > 5: 401 | command_play['text'] = f" Machine Play With Red and You Play With Sky Blue" 402 | elif time_is>= 2 and time_is<5: 403 | command_play['text'] = f" You Will Get the First Chance to play" 404 | else: 405 | command_play['text'] = f" Enjoy this Game" 406 | command_play.place(x=10, y=260) 407 | 408 | time_is = 10 409 | place_ins = Label(top, text="", font=("Arial", 20, "bold"), fg="#FF0000", bg="#141414") 410 | command_play = Label(top, text="", font=("Arial", 12, "bold"), fg="#af7439", bg="#141414") 411 | 412 | try: 413 | while time_is: 414 | delay_with_instrctions(time_is) 415 | time_is-=1 416 | self.window.update() 417 | time.sleep(1) 418 | top.destroy() 419 | except: 420 | print("Force Stop Error in Operate") 421 | self.block_value_predict[1][1]['state'] = NORMAL 422 | else: 423 | submit_btn['state'] = NORMAL 424 | take_entry['state'] = NORMAL 425 | 426 | mvc_btn = Button(top,text="Play With Computer",bg="#262626",fg="#00FF00",font=("Arial",15,"bold"),relief=RAISED,bd=3,command=lambda: operate(1), activebackground="#262626") 427 | mvc_btn.place(x=30,y=160) 428 | 429 | mvh_btn = Button(top,text="Play With Friends",bg="#262626",fg="#00FF00",font=("Arial",15,"bold"),relief=RAISED,bd=3,command=lambda: operate(0), activebackground="#262626") 430 | mvh_btn.place(x=260,y=160) 431 | 432 | top.mainloop() 433 | 434 | # Get block value after prediction based on probability 435 | def make_prediction(self,color_indicator): 436 | try: 437 | if color_indicator == "red": 438 | block_value_predict = self.block_value_predict[0] 439 | if self.robo_prem and self.count_robo_stage_from_start < 3: 440 | self.count_robo_stage_from_start += 1 441 | if self.robo_prem and self.count_robo_stage_from_start == 3 and self.six_counter < 2: 442 | permanent_block_number = self.move_red_counter = 6 443 | self.count_robo_stage_from_start += 1 444 | else: 445 | permanent_block_number = self.move_red_counter = randint(1, 6) 446 | 447 | elif color_indicator == "sky_blue": 448 | block_value_predict = self.block_value_predict[1] 449 | permanent_block_number = self.move_sky_blue_counter = randint(1, 6) 450 | if self.robo_prem and permanent_block_number == 6: 451 | for coin_loc in self.red_coin_position: 452 | if coin_loc>=40 and coin_loc<=46: 453 | permanent_block_number = self.move_sky_blue_counter = randint(1, 5) 454 | break 455 | 456 | elif color_indicator == "yellow": 457 | block_value_predict = self.block_value_predict[2] 458 | permanent_block_number = self.move_yellow_counter = randint(1, 6) 459 | 460 | else: 461 | block_value_predict = self.block_value_predict[3] 462 | permanent_block_number = self.move_green_counter = randint(1, 6) 463 | 464 | block_value_predict[1]['state'] = DISABLED 465 | 466 | # Illusion of coin floating 467 | temp_counter = 12 468 | while temp_counter>0: 469 | move_temp_counter = randint(1, 6) 470 | block_value_predict[0]['image'] = self.block_number_side[move_temp_counter - 1] 471 | self.window.update() 472 | time.sleep(0.1) 473 | temp_counter-=1 474 | 475 | print("Prediction result: ", permanent_block_number) 476 | 477 | # Permanent predicted value containing image set 478 | block_value_predict[0]['image'] = self.block_number_side[permanent_block_number-1] 479 | if self.robo_prem == 1 and color_indicator == "red": 480 | self.window.update() 481 | time.sleep(0.4) 482 | self.instructional_btn_customization_based_on_current_situation(color_indicator,permanent_block_number,block_value_predict) 483 | except: 484 | print("Force Stop Error in Prediction") 485 | 486 | def instructional_btn_customization_based_on_current_situation(self,color_indicator,permanent_block_number,block_value_predict): 487 | robo_operator = None 488 | if color_indicator == "red": 489 | temp_coin_position = self.red_coin_position 490 | elif color_indicator == "green": 491 | temp_coin_position = self.green_coin_position 492 | elif color_indicator == "yellow": 493 | temp_coin_position = self.yellow_coin_position 494 | else: 495 | temp_coin_position = self.sky_blue_coin_position 496 | 497 | all_in = 1 498 | for i in range(4): 499 | if temp_coin_position[i] == -1: 500 | all_in = 1 501 | else: 502 | all_in = 0 503 | break 504 | 505 | if permanent_block_number == 6: 506 | self.six_counter += 1 507 | else: 508 | self.six_counter = 0 509 | 510 | if ((all_in == 1 and permanent_block_number == 6) or (all_in==0)) and self.six_counter<3: 511 | permission = 1 512 | if color_indicator == "red": 513 | temp = self.red_coord_store 514 | elif color_indicator == "green": 515 | temp = self.green_coord_store 516 | elif color_indicator == "yellow": 517 | temp = self.yellow_coord_store 518 | else: 519 | temp = self.sky_blue_coord_store 520 | 521 | if permanent_block_number<6: 522 | if self.six_with_overlap == 1: 523 | self.time_for-=1 524 | self.six_with_overlap=0 525 | for i in range(4): 526 | if temp[i] == -1: 527 | permission=0 528 | elif temp[i]>100: 529 | if temp[i]+permanent_block_number<=106: 530 | permission=1 531 | break 532 | else: 533 | permission=0 534 | else: 535 | permission=1 536 | break 537 | else: 538 | for i in range(4): 539 | if temp[i]>100: 540 | if temp[i] + permanent_block_number <= 106: 541 | permission = 1 542 | break 543 | else: 544 | permission = 0 545 | else: 546 | permission = 1 547 | break 548 | if permission == 0: 549 | self.make_command(None) 550 | else: 551 | self.num_btns_state_controller(block_value_predict[2]) 552 | 553 | if self.robo_prem == 1 and block_value_predict == self.block_value_predict[0]: 554 | robo_operator = "give" 555 | block_value_predict[1]['state'] = DISABLED# Predict btn deactivation 556 | 557 | else: 558 | block_value_predict[1]['state'] = NORMAL# Predict btn activation 559 | if self.six_with_overlap == 1: 560 | self.time_for -= 1 561 | self.six_with_overlap = 0 562 | self.make_command() 563 | 564 | if permanent_block_number == 6 and self.six_counter<3 and block_value_predict[2][0]['state'] == NORMAL: 565 | self.time_for-=1 566 | else: 567 | self.six_counter=0 568 | 569 | if self.robo_prem == 1 and robo_operator: 570 | self.robo_judge(robo_operator) 571 | 572 | # Player Scope controller 573 | def make_command(self, robo_operator=None): 574 | if self.time_for == -1: 575 | pass 576 | else: 577 | self.block_value_predict[self.total_people_play[self.time_for]][1]['state'] = DISABLED 578 | if self.time_for == len(self.total_people_play)-1: 579 | self.time_for = -1 580 | 581 | self.time_for+=1 582 | self.block_value_predict[self.total_people_play[self.time_for]][1]['state'] = NORMAL 583 | 584 | if self.robo_prem==1 and self.time_for == 0: 585 | robo_operator = "predict" 586 | if robo_operator: 587 | self.robo_judge(robo_operator) 588 | 589 | 590 | def instruction_btn_red(self): 591 | block_predict_red = Label(self.make_canvas,image=self.block_number_side[0]) 592 | block_predict_red.place(x=34,y=15) 593 | predict_red = Button(self.make_canvas, bg="black", fg="#00FF00", relief=RAISED, bd=5, text="Predict", font=("Arial", 8, "bold"), command=lambda: self.make_prediction("red")) 594 | predict_red.place(x=25, y=15 + 50) 595 | 596 | btn_1 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="1",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("red",'1'), state=DISABLED, disabledforeground="red") 597 | btn_1.place(x=20,y=15+100) 598 | btn_2 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="2",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("red",'2'), state=DISABLED, disabledforeground="red") 599 | btn_2.place(x=60,y=15+100) 600 | btn_3 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="3",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("red",'3'), state=DISABLED, disabledforeground="red") 601 | btn_3.place(x=20,y=15+100+40) 602 | btn_4 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="4",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("red",'4'), state=DISABLED, disabledforeground="red") 603 | btn_4.place(x=60,y=15+100+40) 604 | 605 | Label(self.make_canvas,text="Player 1",bg="#141414",fg="gold",font=("Arial",15,"bold")).place(x=15,y=15+140+50) 606 | self.store_instructional_btn(block_predict_red,predict_red,[btn_1,btn_2,btn_3,btn_4]) 607 | 608 | def instruction_btn_sky_blue(self): 609 | block_predict_sky_blue = Label(self.make_canvas, image=self.block_number_side[0]) 610 | block_predict_sky_blue.place(x=34, y=15+(40*6+40*3)+10) 611 | predict_sky_blue = Button(self.make_canvas, bg="black", fg="#00FF00", relief=RAISED, bd=5, text="Predict",font=("Arial", 8, "bold"), command=lambda: self.make_prediction("sky_blue")) 612 | predict_sky_blue.place(x=25, y=15+(40*6+40*3)+40 + 20) 613 | 614 | btn_1 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="1",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("sky_blue",'1'), state=DISABLED, disabledforeground="red") 615 | btn_1.place(x=20,y=15+(40*6+40*3)+40 + 70) 616 | btn_2 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="2",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("sky_blue",'2'), state=DISABLED, disabledforeground="red") 617 | btn_2.place(x=60,y=15+(40*6+40*3)+40 + 70) 618 | btn_3 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="3",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("sky_blue",'3'), state=DISABLED, disabledforeground="red") 619 | btn_3.place(x=20,y=15+(40*6+40*3)+40 + 70+ 40) 620 | btn_4 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="4",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("sky_blue",'4'), state=DISABLED, disabledforeground="red") 621 | btn_4.place(x=60,y=15+(40*6+40*3)+40 + 70+ 40) 622 | 623 | Label(self.make_canvas, text="Player 2", bg="#141414", fg="gold", font=("Arial", 15, "bold")).place(x=12,y=15+(40*6+40*3)+40 + 110+50) 624 | self.store_instructional_btn(block_predict_sky_blue, predict_sky_blue, [btn_1,btn_2,btn_3,btn_4]) 625 | 626 | def instruction_btn_yellow(self): 627 | block_predict_yellow = Label(self.make_canvas, image=self.block_number_side[0]) 628 | block_predict_yellow.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 10)+20, y=15 + (40 * 6 + 40 * 3) + 10) 629 | predict_yellow = Button(self.make_canvas, bg="black", fg="#00FF00", relief=RAISED, bd=5, text="Predict",font=("Arial", 8, "bold"), command=lambda: self.make_prediction("yellow")) 630 | predict_yellow.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+20, y=15 + (40 * 6 + 40 * 3) + 40 + 20) 631 | 632 | btn_1 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="1",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("yellow",'1'), state=DISABLED, disabledforeground="red") 633 | btn_1.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15, y=15 + (40 * 6 + 40 * 3) + 40 + 70) 634 | btn_2 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="2",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("yellow",'2'), state=DISABLED, disabledforeground="red") 635 | btn_2.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15 + 40, y=15 + (40 * 6 + 40 * 3) + 40 + 70) 636 | btn_3 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="3",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("yellow",'3'), state=DISABLED, disabledforeground="red") 637 | btn_3.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15, y=15 + (40 * 6 + 40 * 3) + 40 + 70+ 40) 638 | btn_4 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="4",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("yellow",'4'), state=DISABLED, disabledforeground="red") 639 | btn_4.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15 + 40, y=15 + (40 * 6 + 40 * 3) + 40 + 70+ 40) 640 | 641 | Label(self.make_canvas, text="Player 3", bg="#141414", fg="gold", font=("Arial", 15, "bold")).place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 +7),y=15+(40*6+40*3)+40 + 110+50) 642 | self.store_instructional_btn(block_predict_yellow, predict_yellow, [btn_1,btn_2,btn_3,btn_4]) 643 | 644 | def instruction_btn_green(self): 645 | block_predict_green = Label(self.make_canvas, image=self.block_number_side[0]) 646 | block_predict_green.place(x=100+(40*6+40*3+40*6+10)+20, y=15) 647 | predict_green = Button(self.make_canvas, bg="black", fg="#00FF00", relief=RAISED, bd=5, text="Predict", font=("Arial", 8, "bold"), command=lambda: self.make_prediction("green")) 648 | predict_green.place(x=100+(40*6+40*3+40*6+2)+20, y=15 + 50) 649 | 650 | btn_1 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="1",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("green",'1'), state=DISABLED, disabledforeground="red") 651 | btn_1.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15,y=15+100) 652 | btn_2 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="2",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("green",'2'), state=DISABLED, disabledforeground="red") 653 | btn_2.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15 + 40,y=15+100) 654 | btn_3 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="3",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("green",'3'), state=DISABLED, disabledforeground="red") 655 | btn_3.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15,y=15+100+40) 656 | btn_4 = Button(self.make_canvas,bg="#262626",fg="#00eb00",text="4",font=("Arial",13,"bold","italic"),relief=RAISED,bd=3,command=lambda: self.main_controller("green",'4'), state=DISABLED, disabledforeground="red") 657 | btn_4.place(x=100 + (40 * 6 + 40 * 3 + 40 * 6 + 2)+15 + 40,y=15+100+40) 658 | 659 | Label(self.make_canvas, text="Player 4", bg="#141414", fg="gold", font=("Arial", 15, "bold")).place(x=100+(40*6+40*3+40*6+7), y=15+140+50) 660 | self.store_instructional_btn(block_predict_green, predict_green, [btn_1,btn_2,btn_3,btn_4]) 661 | 662 | def store_instructional_btn(self, block_indicator, predictor, entry_controller): 663 | temp = [] 664 | temp.append(block_indicator) 665 | temp.append(predictor) 666 | temp.append(entry_controller) 667 | self.block_value_predict.append(temp) 668 | 669 | def red_circle_start_position(self, coin_number): 670 | self.make_canvas.delete(self.made_red_coin[int(coin_number)-1]) 671 | self.made_red_coin[int(coin_number)-1] = self.make_canvas.create_oval(100 + 40, 15+(40*6), 100 +40 + 40, 15+(40*6)+40, fill="red", width=3, outline="black") 672 | 673 | self.red_number_label[int(coin_number)-1].place_forget() 674 | red_start_label_x = 100 + 40 + 10 675 | red_start_label_y = 15 + (40 * 6) + 5 676 | self.red_number_label[int(coin_number)-1].place(x=red_start_label_x, y=red_start_label_y) 677 | 678 | self.red_coin_position[int(coin_number)-1] = 1 679 | self.window.update() 680 | time.sleep(0.2) 681 | 682 | def green_circle_start_position(self,coin_number): 683 | self.make_canvas.delete(self.made_green_coin[int(coin_number)-1]) 684 | self.made_green_coin[int(coin_number)-1] = self.make_canvas.create_oval(100 + (40*8), 15 + 40, 100 +(40*9), 15 + 40+ 40, fill="#00FF00", width=3) 685 | 686 | self.green_number_label[int(coin_number)-1].place_forget() 687 | green_start_label_x = 100 + (40*8) + 10 688 | green_start_label_y = 15 + 40 + 5 689 | self.green_number_label[int(coin_number)-1].place(x=green_start_label_x, y=green_start_label_y) 690 | 691 | self.green_coin_position[int(coin_number)-1] = 14 692 | self.window.update() 693 | time.sleep(0.2) 694 | 695 | def yellow_circle_start_position(self,coin_number): 696 | self.make_canvas.delete(self.made_yellow_coin[int(coin_number)-1]) 697 | self.made_yellow_coin[int(coin_number)-1] = self.make_canvas.create_oval(100 + (40 * 6)+(40*3)+(40*4), 15 + (40*8), 100 + (40 * 6)+(40*3)+(40*5), 15 + (40*9), fill="yellow", width=3) 698 | 699 | self.yellow_number_label[int(coin_number)-1].place_forget() 700 | yellow_start_label_x = 100 + (40 * 6)+(40*3)+(40*4) + 10 701 | yellow_start_label_y = 15 + (40*8) + 5 702 | self.yellow_number_label[int(coin_number) - 1].place(x=yellow_start_label_x, y=yellow_start_label_y) 703 | 704 | self.yellow_coin_position[int(coin_number) - 1] = 27 705 | self.window.update() 706 | time.sleep(0.2) 707 | 708 | def sky_blue_circle_start_position(self,coin_number): 709 | self.make_canvas.delete(self.made_sky_blue_coin[int(coin_number)-1]) 710 | self.made_sky_blue_coin[int(coin_number)-1] = self.make_canvas.create_oval(100+240,340+(40*5)-5,100+240+40,340+(40*6)-5,fill="#04d9ff",width=3) 711 | 712 | self.sky_blue_number_label[int(coin_number)-1].place_forget() 713 | sky_blue_start_label_x = 100+240 + 10 714 | sky_blue_start_label_y = 340+(40*5)-5 + 5 715 | self.sky_blue_number_label[int(coin_number) - 1].place(x=sky_blue_start_label_x, y=sky_blue_start_label_y) 716 | 717 | self.sky_blue_coin_position[int(coin_number) - 1] = 40 718 | self.window.update() 719 | time.sleep(0.2) 720 | 721 | def num_btns_state_controller(self, take_nums_btns_list, state_control = 1): 722 | if state_control: 723 | for num_btn in take_nums_btns_list: 724 | num_btn['state'] = NORMAL 725 | else: 726 | for num_btn in take_nums_btns_list: 727 | num_btn['state'] = DISABLED 728 | 729 | def main_controller(self, color_coin, coin_number): 730 | robo_operator = None 731 | 732 | if color_coin == "red": 733 | self.num_btns_state_controller(self.block_value_predict[0][2], 0) 734 | 735 | if self.move_red_counter == 106: 736 | messagebox.showwarning("Destination reached","Reached at the destination") 737 | 738 | elif self.red_coin_position[int(coin_number)-1] == -1 and self.move_red_counter == 6: 739 | self.red_circle_start_position(coin_number) 740 | self.red_coord_store[int(coin_number) - 1] = 1 741 | 742 | elif self.red_coin_position[int(coin_number)-1] > -1: 743 | take_coord = self.make_canvas.coords(self.made_red_coin[int(coin_number)-1]) 744 | red_start_label_x = take_coord[0] + 10 745 | red_start_label_y = take_coord[1] + 5 746 | self.red_number_label[int(coin_number) - 1].place(x=red_start_label_x, y=red_start_label_y) 747 | 748 | if self.red_coin_position[int(coin_number)-1]+self.move_red_counter<=106: 749 | self.red_coin_position[int(coin_number)-1] = self.motion_of_coin(self.red_coin_position[int(coin_number) - 1],self.made_red_coin[int(coin_number)-1],self.red_number_label[int(coin_number)-1],red_start_label_x,red_start_label_y,"red",self.move_red_counter) 750 | if self.robo_prem and self.red_coin_position[int(coin_number)-1] == 106 and color_coin == "red": 751 | self.robo_store.remove(int(coin_number)) 752 | print("After removing: ", self.robo_store) 753 | 754 | else: 755 | if not self.robo_prem: 756 | messagebox.showerror("Not possible","Sorry, not permitted") 757 | self.num_btns_state_controller(self.block_value_predict[0][2]) 758 | 759 | if self.robo_prem: 760 | robo_operator = "give" 761 | self.robo_judge(robo_operator) 762 | return 763 | 764 | if self.red_coin_position[int(coin_number)-1]==22 or self.red_coin_position[int(coin_number)-1]==9 or self.red_coin_position[int(coin_number)-1]==48 or self.red_coin_position[int(coin_number)-1]==35 or self.red_coin_position[int(coin_number)-1]==14 or self.red_coin_position[int(coin_number)-1]==27 or self.red_coin_position[int(coin_number)-1]==40 or self.red_coin_position[int(coin_number)-1]==1: 765 | pass 766 | else: 767 | if self.red_coin_position[int(coin_number) - 1] < 100: 768 | self.coord_overlap(self.red_coin_position[int(coin_number)-1],color_coin, self.move_red_counter) 769 | 770 | self.red_coord_store[int(coin_number)-1] = self.red_coin_position[int(coin_number)-1] 771 | 772 | else: 773 | messagebox.showerror("Wrong choice","Sorry, Your coin in not permitted to travel") 774 | self.num_btns_state_controller(self.block_value_predict[0][2]) 775 | 776 | if self.robo_prem == 1: 777 | robo_operator = "give" 778 | self.robo_judge(robo_operator) 779 | return 780 | 781 | self.block_value_predict[0][1]['state'] = NORMAL 782 | 783 | 784 | elif color_coin == "green": 785 | self.num_btns_state_controller(self.block_value_predict[3][2], 0) 786 | 787 | if self.move_green_counter == 106: 788 | messagebox.showwarning("Destination reached","Reached at the destination") 789 | 790 | elif self.green_coin_position[int(coin_number) - 1] == -1 and self.move_green_counter == 6: 791 | self.green_circle_start_position(coin_number) 792 | self.green_coord_store[int(coin_number) - 1] = 14 793 | 794 | elif self.green_coin_position[int(coin_number) - 1] > -1: 795 | take_coord = self.make_canvas.coords(self.made_green_coin[int(coin_number) - 1]) 796 | green_start_label_x = take_coord[0] + 10 797 | green_start_label_y = take_coord[1] + 5 798 | self.green_number_label[int(coin_number) - 1].place(x=green_start_label_x, y=green_start_label_y) 799 | 800 | 801 | if self.green_coin_position[int(coin_number) - 1] + self.move_green_counter <= 106: 802 | self.green_coin_position[int(coin_number) - 1] = self.motion_of_coin(self.green_coin_position[int(coin_number) - 1], self.made_green_coin[int(coin_number) - 1], self.green_number_label[int(coin_number) - 1], green_start_label_x, green_start_label_y, "green", self.move_green_counter) 803 | else: 804 | messagebox.showerror("Not possible","No path available") 805 | self.num_btns_state_controller(self.block_value_predict[3][2]) 806 | return 807 | 808 | 809 | if self.green_coin_position[int(coin_number)-1]==22 or self.green_coin_position[int(coin_number)-1]==9 or self.green_coin_position[int(coin_number)-1]==48 or self.green_coin_position[int(coin_number)-1]==35 or self.green_coin_position[int(coin_number)-1]==1 or self.green_coin_position[int(coin_number)-1]==27 or self.green_coin_position[int(coin_number)-1]==40 or self.green_coin_position[int(coin_number)-1]==14: 810 | pass 811 | else: 812 | if self.green_coin_position[int(coin_number) - 1] < 100: 813 | self.coord_overlap(self.green_coin_position[int(coin_number) - 1],color_coin, self.move_green_counter) 814 | 815 | self.green_coord_store[int(coin_number) - 1] = self.green_coin_position[int(coin_number) - 1] 816 | 817 | else: 818 | messagebox.showerror("Wrong choice", "Sorry, Your coin in not permitted to travel") 819 | self.num_btns_state_controller(self.block_value_predict[3][2]) 820 | return 821 | 822 | self.block_value_predict[3][1]['state'] = NORMAL 823 | 824 | elif color_coin == "yellow": 825 | 826 | self.num_btns_state_controller(self.block_value_predict[2][2], 0) 827 | 828 | if self.move_yellow_counter == 106: 829 | messagebox.showwarning("Destination reached","Reached at the destination") 830 | 831 | elif self.yellow_coin_position[int(coin_number) - 1] == -1 and self.move_yellow_counter == 6: 832 | self.yellow_circle_start_position(coin_number) 833 | self.yellow_coord_store[int(coin_number) - 1] = 27 834 | 835 | elif self.yellow_coin_position[int(coin_number) - 1] > -1: 836 | take_coord = self.make_canvas.coords(self.made_yellow_coin[int(coin_number) - 1]) 837 | yellow_start_label_x = take_coord[0] + 10 838 | yellow_start_label_y = take_coord[1] + 5 839 | self.yellow_number_label[int(coin_number) - 1].place(x=yellow_start_label_x, y=yellow_start_label_y) 840 | 841 | if self.yellow_coin_position[int(coin_number) - 1] + self.move_yellow_counter <= 106: 842 | self.yellow_coin_position[int(coin_number) - 1] = self.motion_of_coin(self.yellow_coin_position[int(coin_number) - 1], self.made_yellow_coin[int(coin_number) - 1], self.yellow_number_label[int(coin_number) - 1], yellow_start_label_x, yellow_start_label_y, "yellow", self.move_yellow_counter) 843 | else: 844 | messagebox.showerror("Not possible","No path available") 845 | 846 | self.num_btns_state_controller(self.block_value_predict[2][2]) 847 | return 848 | 849 | if self.yellow_coin_position[int(coin_number)-1]==22 or self.yellow_coin_position[int(coin_number)-1]==9 or self.yellow_coin_position[int(coin_number)-1]==48 or self.yellow_coin_position[int(coin_number)-1]==35 or self.yellow_coin_position[int(coin_number)-1]==1 or self.yellow_coin_position[int(coin_number)-1]==14 or self.yellow_coin_position[int(coin_number)-1]==40 or self.yellow_coin_position[int(coin_number)-1]==27: 850 | pass 851 | else: 852 | if self.yellow_coin_position[int(coin_number) - 1] < 100: 853 | self.coord_overlap(self.yellow_coin_position[int(coin_number) - 1],color_coin, self.move_yellow_counter) 854 | 855 | self.yellow_coord_store[int(coin_number) - 1] = self.yellow_coin_position[int(coin_number) - 1] 856 | 857 | else: 858 | messagebox.showerror("Wrong choice", "Sorry, Your coin in not permitted to travel") 859 | self.num_btns_state_controller(self.block_value_predict[2][2]) 860 | return 861 | 862 | self.block_value_predict[2][1]['state'] = NORMAL 863 | 864 | 865 | elif color_coin == "sky_blue": 866 | self.num_btns_state_controller(self.block_value_predict[1][2], 0) 867 | 868 | if self.move_red_counter == 106: 869 | messagebox.showwarning("Destination reached","Reached at the destination") 870 | 871 | elif self.sky_blue_coin_position[int(coin_number) - 1] == -1 and self.move_sky_blue_counter == 6: 872 | self.sky_blue_circle_start_position(coin_number) 873 | self.sky_blue_coord_store[int(coin_number) - 1] = 40 874 | 875 | elif self.sky_blue_coin_position[int(coin_number) - 1] > -1: 876 | take_coord = self.make_canvas.coords(self.made_sky_blue_coin[int(coin_number) - 1]) 877 | sky_blue_start_label_x = take_coord[0] + 10 878 | sky_blue_start_label_y = take_coord[1] + 5 879 | self.sky_blue_number_label[int(coin_number) - 1].place(x=sky_blue_start_label_x, y=sky_blue_start_label_y) 880 | 881 | if self.sky_blue_coin_position[int(coin_number) - 1] + self.move_sky_blue_counter <= 106: 882 | self.sky_blue_coin_position[int(coin_number) - 1] = self.motion_of_coin(self.sky_blue_coin_position[int(coin_number) - 1], self.made_sky_blue_coin[int(coin_number) - 1], self.sky_blue_number_label[int(coin_number) - 1], sky_blue_start_label_x, sky_blue_start_label_y, "sky_blue", self.move_sky_blue_counter) 883 | else: 884 | messagebox.showerror("Not possible","No path available") 885 | 886 | self.num_btns_state_controller(self.block_value_predict[1][2]) 887 | return 888 | 889 | if self.sky_blue_coin_position[int(coin_number)-1]==22 or self.sky_blue_coin_position[int(coin_number)-1]==9 or self.sky_blue_coin_position[int(coin_number)-1]==48 or self.sky_blue_coin_position[int(coin_number)-1]==35 or self.sky_blue_coin_position[int(coin_number)-1]==1 or self.sky_blue_coin_position[int(coin_number)-1]==14 or self.sky_blue_coin_position[int(coin_number)-1]==27 or self.sky_blue_coin_position[int(coin_number)-1]==40: 890 | pass 891 | else: 892 | if self.sky_blue_coin_position[int(coin_number) - 1] < 100: 893 | self.coord_overlap(self.sky_blue_coin_position[int(coin_number) - 1],color_coin, self.move_sky_blue_counter) 894 | 895 | self.sky_blue_coord_store[int(coin_number) - 1] = self.sky_blue_coin_position[int(coin_number) - 1] 896 | 897 | else: 898 | messagebox.showerror("Wrong choice", "Sorry, Your coin in not permitted to travel") 899 | self.num_btns_state_controller(self.block_value_predict[1][2]) 900 | return 901 | 902 | self.block_value_predict[1][1]['state'] = NORMAL 903 | 904 | print(self.red_coord_store) 905 | print(self.green_coord_store) 906 | print(self.yellow_coord_store) 907 | print(self.sky_blue_coord_store) 908 | if self.robo_prem == 1: 909 | print("Robo Store is: ", self.robo_store) 910 | 911 | permission_granted_to_proceed = True 912 | 913 | if color_coin == "red" and self.red_coin_position[int(coin_number)-1] == 106: 914 | permission_granted_to_proceed = self.check_winner_and_runner(color_coin) 915 | elif color_coin == "green" and self.green_coin_position[int(coin_number)-1] == 106: 916 | permission_granted_to_proceed = self.check_winner_and_runner(color_coin) 917 | elif color_coin == "yellow" and self.yellow_coin_position[int(coin_number)-1] == 106: 918 | permission_granted_to_proceed = self.check_winner_and_runner(color_coin) 919 | elif color_coin == "sky_blue" and self.sky_blue_coin_position[int(coin_number)-1] == 106: 920 | permission_granted_to_proceed = self.check_winner_and_runner(color_coin) 921 | 922 | if permission_granted_to_proceed:# if that is False, Game is over and not proceed more 923 | self.make_command(robo_operator) 924 | 925 | def motion_of_coin(self,counter_coin,specific_coin,number_label,number_label_x ,number_label_y,color_coin,path_counter): 926 | try: 927 | number_label.place(x=number_label_x,y=number_label_y) 928 | while True: 929 | if path_counter == 0: 930 | break 931 | elif (counter_coin == 51 and color_coin == "red") or (counter_coin==12 and color_coin == "green") or (counter_coin == 25 and color_coin == "yellow") or (counter_coin == 38 and color_coin == "sky_blue") or counter_coin>=100: 932 | if counter_coin<100: 933 | counter_coin=100 934 | 935 | counter_coin = self.under_room_traversal_control(specific_coin, number_label, number_label_x, number_label_y, path_counter, counter_coin, color_coin) 936 | 937 | if counter_coin == 106: 938 | 939 | if self.robo_prem == 1 and color_coin == "red": 940 | messagebox.showinfo("Destination reached","Hey! I am at the destination") 941 | else: 942 | messagebox.showinfo("Destination reached","Congrats! You now at the destination") 943 | if path_counter == 6: 944 | self.six_with_overlap = 1 945 | else: 946 | self.time_for -= 1 947 | break 948 | 949 | counter_coin += 1 950 | path_counter -=1 951 | number_label.place_forget() 952 | 953 | print(counter_coin) 954 | 955 | if counter_coin<=5: 956 | self.make_canvas.move(specific_coin, 40, 0) 957 | number_label_x+=40 958 | elif counter_coin == 6: 959 | self.make_canvas.move(specific_coin, 40, -40) 960 | number_label_x += 40 961 | number_label_y-=40 962 | elif 6< counter_coin <=11: 963 | self.make_canvas.move(specific_coin, 0, -40) 964 | number_label_y -= 40 965 | elif counter_coin <=13: 966 | self.make_canvas.move(specific_coin, 40, 0) 967 | number_label_x += 40 968 | elif counter_coin <=18: 969 | self.make_canvas.move(specific_coin, 0, 40) 970 | number_label_y += 40 971 | elif counter_coin == 19: 972 | self.make_canvas.move(specific_coin, 40, 40) 973 | number_label_x += 40 974 | number_label_y += 40 975 | elif counter_coin <=24: 976 | self.make_canvas.move(specific_coin, 40, 0) 977 | number_label_x += 40 978 | elif counter_coin <=26: 979 | self.make_canvas.move(specific_coin, 0, 40) 980 | number_label_y += 40 981 | elif counter_coin <=31: 982 | self.make_canvas.move(specific_coin, -40, 0) 983 | number_label_x -= 40 984 | elif counter_coin == 32: 985 | self.make_canvas.move(specific_coin, -40, 40) 986 | number_label_x -= 40 987 | number_label_y += 40 988 | elif counter_coin <= 37: 989 | self.make_canvas.move(specific_coin, 0, 40) 990 | number_label_y += 40 991 | elif counter_coin <= 39: 992 | self.make_canvas.move(specific_coin, -40, 0) 993 | number_label_x -= 40 994 | elif counter_coin <= 44: 995 | self.make_canvas.move(specific_coin, 0, -40) 996 | number_label_y -= 40 997 | elif counter_coin == 45: 998 | self.make_canvas.move(specific_coin, -40, -40) 999 | number_label_x -= 40 1000 | number_label_y -= 40 1001 | elif counter_coin <= 50: 1002 | self.make_canvas.move(specific_coin, -40, 0) 1003 | number_label_x -= 40 1004 | elif 50< counter_coin <=52: 1005 | self.make_canvas.move(specific_coin, 0, -40) 1006 | number_label_y -= 40 1007 | elif counter_coin == 53: 1008 | self.make_canvas.move(specific_coin, 40, 0) 1009 | number_label_x += 40 1010 | counter_coin = 1 1011 | 1012 | number_label.place_forget() 1013 | number_label.place(x=number_label_x, y=number_label_y) 1014 | 1015 | self.window.update() 1016 | time.sleep(0.2) 1017 | 1018 | return counter_coin 1019 | except: 1020 | print("Force Stop Error Came in motion of coin") 1021 | 1022 | # For same position, previous coin deleted and set to the room 1023 | def coord_overlap(self, counter_coin, color_coin, path_to_traverse_before_overlap): 1024 | if color_coin!="red": 1025 | for take_coin_number in range(len(self.red_coord_store)): 1026 | if self.red_coord_store[take_coin_number] == counter_coin: 1027 | if path_to_traverse_before_overlap == 6: 1028 | self.six_with_overlap=1 1029 | else: 1030 | self.time_for-=1 1031 | 1032 | self.make_canvas.delete(self.made_red_coin[take_coin_number]) 1033 | self.red_number_label[take_coin_number].place_forget() 1034 | self.red_coin_position[take_coin_number] = -1 1035 | self.red_coord_store[take_coin_number] = -1 1036 | if self.robo_prem == 1: 1037 | self.robo_store.remove(take_coin_number+1) 1038 | if self.red_coin_position.count(-1)>=1: 1039 | self.count_robo_stage_from_start = 2 1040 | 1041 | if take_coin_number == 0: 1042 | remade_coin = self.make_canvas.create_oval(100+40, 15+40, 100+40+40, 15+40+40, width=3, fill="red", outline="black") 1043 | self.red_number_label[take_coin_number].place(x=100 + 40 + 10, y=15 + 40 + 5) 1044 | elif take_coin_number == 1: 1045 | remade_coin = self.make_canvas.create_oval(100+40+60+60, 15 + 40, 100+40+60+60+40, 15 + 40 + 40, width=3, fill="red", outline="black") 1046 | self.red_number_label[take_coin_number].place(x=100 + 40 + 60 +60 + 10, y=15 + 40 + 5) 1047 | elif take_coin_number == 2: 1048 | remade_coin = self.make_canvas.create_oval(100 + 40 + 60 + 60, 15 + 40 + 100, 100 + 40 + 60 + 60 + 40, 15 + 40 + 40 + 100, width=3, fill="red", outline="black") 1049 | self.red_number_label[take_coin_number].place(x=100 + 40 + 60 + 60 + 10, y=15 + 40 + 100 + 5) 1050 | else: 1051 | remade_coin = self.make_canvas.create_oval(100 + 40, 15 + 40+100, 100 + 40 + 40, 15 + 40 + 40+100, width=3,fill="red", outline="black") 1052 | self.red_number_label[take_coin_number].place(x=100 + 40 + 10, y=15 + 40 + 100 + 5) 1053 | 1054 | self.made_red_coin[take_coin_number]=remade_coin 1055 | 1056 | if color_coin != "green": 1057 | for take_coin_number in range(len(self.green_coord_store)): 1058 | if self.green_coord_store[take_coin_number] == counter_coin: 1059 | if path_to_traverse_before_overlap == 6: 1060 | self.six_with_overlap = 1 1061 | else: 1062 | self.time_for-=1 1063 | 1064 | self.make_canvas.delete(self.made_green_coin[take_coin_number]) 1065 | self.green_number_label[take_coin_number].place_forget() 1066 | self.green_coin_position[take_coin_number] = -1 1067 | self.green_coord_store[take_coin_number] = -1 1068 | 1069 | if take_coin_number == 0: 1070 | remade_coin = self.make_canvas.create_oval(340+(40*3)+40, 15 + 40, 340+(40*3)+40 + 40, 15 + 40 + 40, width=3, fill="#00FF00", outline="black") 1071 | self.green_number_label[take_coin_number].place(x=340 + (40 * 3) + 40 + 10, y=15 + 40 + 5) 1072 | elif take_coin_number == 1: 1073 | remade_coin = self.make_canvas.create_oval(340+(40*3)+40+ 60 + 40+20, 15 + 40, 340+(40*3)+40 + 60 + 40 + 40+20, 15 + 40 + 40, width=3, fill="#00FF00", outline="black") 1074 | self.green_number_label[take_coin_number].place(x=340 + (40 * 3) + 40 + 40 + 60 + 30, y=15 + 40 + 5) 1075 | elif take_coin_number == 2: 1076 | remade_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40 + 60 + 40 + 20, 15 + 40 + 100, 340 + (40 * 3) + 40 + 60 + 40 + 40 + 20, 15 + 40 + 40 + 100, width=3, fill="#00FF00", outline="black") 1077 | self.green_number_label[take_coin_number].place(x=340 + (40 * 3) + 40 + 40 + 60 + 30, y=15 + 40 + 100 + 5) 1078 | else: 1079 | remade_coin = self.make_canvas.create_oval(340+(40*3)+40, 15 + 40 + 100, 340+(40*3)+40 + 40, 15 + 40 + 40 + 100, width=3, fill="#00FF00", outline="black") 1080 | self.green_number_label[take_coin_number].place(x=340+(40*3) + 40 + 10, y=15 + 40 + 100 + 5) 1081 | 1082 | self.made_green_coin[take_coin_number] = remade_coin 1083 | 1084 | 1085 | if color_coin != "yellow": 1086 | for take_coin_number in range(len(self.yellow_coord_store)): 1087 | if self.yellow_coord_store[take_coin_number] == counter_coin: 1088 | if path_to_traverse_before_overlap == 6: 1089 | self.six_with_overlap = 1 1090 | else: 1091 | self.time_for -= 1 1092 | 1093 | self.make_canvas.delete(self.made_yellow_coin[take_coin_number]) 1094 | self.yellow_number_label[take_coin_number].place_forget() 1095 | self.yellow_coin_position[take_coin_number] = -1 1096 | self.yellow_coord_store[take_coin_number] = -1 1097 | 1098 | if take_coin_number == 0: 1099 | remade_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40, 340+80+15, 340 + (40 * 3) + 40 + 40, 340+80+40+15, width=3, fill="yellow", outline="black") 1100 | self.yellow_number_label[take_coin_number].place(x=340+(40*3) + 40 + 10, y=30 + (40*6)+(40*3)+40+10) 1101 | elif take_coin_number == 1: 1102 | remade_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40 + 60 + 40 + 20, 340+80+15, 340 + (40 * 3) + 40 + 60 + 40 + 40+20, 340+80+40+15, width=3, fill="yellow", outline="black") 1103 | self.yellow_number_label[take_coin_number].place(x=340+(40*3)+ 40 + 40+ 60 + 30, y=30 + (40*6)+(40*3)+40+10) 1104 | elif take_coin_number == 2: 1105 | remade_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40 + 60 + 40 + 20, 340 + 80 + 60 + 40 + 15, 340 + (40 * 3) + 40 + 60 + 40 + 40 + 20, 340 + 80 + 60 + 40 + 40 + 15, width=3, fill="yellow", outline="black") 1106 | self.yellow_number_label[take_coin_number].place(x=340+(40*3)+ 40 + 40+ 60 + 30, y=30 + (40*6)+(40*3)+40+100+10) 1107 | else: 1108 | remade_coin = self.make_canvas.create_oval(340 + (40 * 3) + 40, 340+80+60+40+15, 340 + (40 * 3) + 40 + 40,340+80+60+40+40+15, width=3, fill="yellow", outline="black") 1109 | self.yellow_number_label[take_coin_number].place(x=340 + (40 * 3) + 40 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 100 + 10) 1110 | 1111 | self.made_yellow_coin[take_coin_number] = remade_coin 1112 | 1113 | if color_coin != "sky_blue": 1114 | for take_coin_number in range(len(self.sky_blue_coord_store)): 1115 | if self.sky_blue_coord_store[take_coin_number] == counter_coin: 1116 | if path_to_traverse_before_overlap == 6: 1117 | self.six_with_overlap = 1 1118 | else: 1119 | self.time_for -= 1 1120 | 1121 | self.make_canvas.delete(self.made_sky_blue_coin[take_coin_number]) 1122 | self.sky_blue_number_label[take_coin_number].place_forget() 1123 | self.sky_blue_coin_position[take_coin_number] = -1 1124 | self.sky_blue_coord_store[take_coin_number]=-1 1125 | 1126 | if take_coin_number == 0: 1127 | remade_coin = self.make_canvas.create_oval(100 + 40, 340+80+15, 100 + 40 + 40, 340+80+40+15, width=3, fill="#04d9ff", outline="black") 1128 | self.sky_blue_number_label[take_coin_number].place(x=100+40+10, y=30 + (40*6)+(40*3)+40+10) 1129 | elif take_coin_number == 1: 1130 | remade_coin = self.make_canvas.create_oval(100 + 40 + 60 + 40+20, 340+80+15, 100 + 40 + 60 + 40 + 40+20, 340+80+40+15, width=3, fill="#04d9ff", outline="black") 1131 | self.sky_blue_number_label[take_coin_number].place(x=100 + 40 + 60 +60 + 10, y=30 + (40*6)+(40*3)+40+10) 1132 | elif take_coin_number == 2: 1133 | remade_coin = self.make_canvas.create_oval(100 + 40 + 60 + 40 + 20, 340 + 80 + 60 + 40 + 15, 100 + 40 + 60 + 40 + 40 + 20, 340 + 80 + 60 + 40 + 40 + 15, width=3, fill="#04d9ff", outline="black") 1134 | self.sky_blue_number_label[take_coin_number].place(x=100 + 40 + 60 + 60 + 10, y=30 + (40 * 6) + (40 * 3) + 40 + 60 + 40 + 10) 1135 | else: 1136 | remade_coin = self.make_canvas.create_oval( 100 + 40, 340+80+60+40+15, 100 + 40 + 40, 340+80+60+40+40+15, width=3, fill="#04d9ff", outline="black") 1137 | self.sky_blue_number_label[take_coin_number].place(x=100+40+10, y=30 + (40*6)+(40*3)+40+60+40+10) 1138 | 1139 | self.made_sky_blue_coin[take_coin_number] = remade_coin 1140 | 1141 | 1142 | def under_room_traversal_control(self,specific_coin,number_label,number_label_x,number_label_y,path_counter,counter_coin,color_coin): 1143 | if color_coin == "red" and counter_coin >= 100: 1144 | if int(counter_coin)+int(path_counter)<=106: 1145 | counter_coin = self.room_red_traversal(specific_coin, number_label, number_label_x, number_label_y, path_counter, counter_coin) 1146 | 1147 | elif color_coin == "green" and counter_coin >= 100: 1148 | if int(counter_coin) + int(path_counter) <= 106: 1149 | counter_coin = self.room_green_traversal(specific_coin, number_label, number_label_x, number_label_y,path_counter,counter_coin) 1150 | 1151 | elif color_coin == "yellow" and counter_coin >= 100: 1152 | if int(counter_coin) + int(path_counter) <= 106: 1153 | counter_coin = self.room_yellow_traversal(specific_coin, number_label, number_label_x, number_label_y,path_counter,counter_coin) 1154 | 1155 | elif color_coin == "sky_blue" and counter_coin >= 100: 1156 | if int(counter_coin) + int(path_counter) <= 106: 1157 | counter_coin = self.room_sky_blue_traversal(specific_coin, number_label, number_label_x, number_label_y,path_counter,counter_coin) 1158 | 1159 | return counter_coin 1160 | 1161 | 1162 | def room_red_traversal(self, specific_coin, number_label, number_label_x, number_label_y, path_counter, counter_coin): 1163 | while path_counter>0: 1164 | counter_coin += 1 1165 | path_counter -= 1 1166 | self.make_canvas.move(specific_coin, 40, 0) 1167 | number_label_x+=40 1168 | number_label.place(x=number_label_x,y=number_label_y) 1169 | self.window.update() 1170 | time.sleep(0.2) 1171 | return counter_coin 1172 | 1173 | def room_green_traversal(self, specific_coin, number_label, number_label_x, number_label_y, path_counter, counter_coin): 1174 | while path_counter > 0: 1175 | counter_coin += 1 1176 | path_counter -= 1 1177 | self.make_canvas.move(specific_coin, 0, 40) 1178 | number_label_y += 40 1179 | number_label.place(x=number_label_x, y=number_label_y) 1180 | self.window.update() 1181 | time.sleep(0.2) 1182 | return counter_coin 1183 | 1184 | def room_yellow_traversal(self, specific_coin, number_label, number_label_x, number_label_y,path_counter,counter_coin): 1185 | while path_counter > 0: 1186 | counter_coin += 1 1187 | path_counter -= 1 1188 | self.make_canvas.move(specific_coin, -40, 0) 1189 | number_label_x -= 40 1190 | number_label.place(x=number_label_x, y=number_label_y) 1191 | self.window.update() 1192 | time.sleep(0.2) 1193 | return counter_coin 1194 | 1195 | def room_sky_blue_traversal(self, specific_coin, number_label, number_label_x, number_label_y,path_counter,counter_coin): 1196 | while path_counter > 0: 1197 | counter_coin += 1 1198 | path_counter -= 1 1199 | self.make_canvas.move(specific_coin, 0, -40) 1200 | number_label_y -= 40 1201 | number_label.place(x=number_label_x, y=number_label_y) 1202 | self.window.update() 1203 | time.sleep(0.2) 1204 | return counter_coin 1205 | 1206 | def check_winner_and_runner(self,color_coin): 1207 | destination_reached = 0 # Check for all specific color coins 1208 | if color_coin == "red": 1209 | temp_store = self.red_coord_store 1210 | temp_delete = 0# Player index 1211 | elif color_coin == "green": 1212 | temp_store = self.green_coord_store 1213 | temp_delete = 3# Player index 1214 | elif color_coin == "yellow": 1215 | temp_store = self.yellow_coord_store 1216 | temp_delete = 2# Player index 1217 | else: 1218 | temp_store = self.sky_blue_coord_store 1219 | temp_delete = 1# Player index 1220 | 1221 | for take in temp_store: 1222 | if take == 106: 1223 | destination_reached = 1 1224 | else: 1225 | destination_reached = 0 1226 | break 1227 | 1228 | if destination_reached == 1:# If all coins in block reach to the destination, winner and runner check 1229 | self.take_permission += 1 1230 | if self.take_permission == 1:# Winner check 1231 | if self.robo_prem == 1 and color_coin == "red": 1232 | messagebox.showinfo("Winner", "Hurrah! I am the winner") 1233 | else: 1234 | messagebox.showinfo("Winner","Congrats! You are the winner") 1235 | elif self.take_permission == 2:# 1st runner check 1236 | if self.robo_prem == 1 and color_coin == "red": 1237 | messagebox.showinfo("Winner", "Hurrah! I am 1st runner") 1238 | else: 1239 | messagebox.showinfo("Winner", "Wow! You are 1st runner") 1240 | elif self.take_permission == 3:# 2nd runner check 1241 | if self.robo_prem == 1 and color_coin == "red": 1242 | messagebox.showinfo("Result", "I am 2nd runner....Not bad at all") 1243 | else: 1244 | messagebox.showinfo("Result", "You are 2nd runner....Better Luck next time") 1245 | 1246 | self.block_value_predict[temp_delete][1]['state'] = DISABLED 1247 | self.total_people_play.remove(temp_delete) 1248 | 1249 | if len(self.total_people_play) == 1: 1250 | messagebox.showinfo("Game Over","Good bye!!!!") 1251 | self.block_value_predict[0][1]['state'] = DISABLED 1252 | return False 1253 | else: 1254 | self.time_for-=1 1255 | else: 1256 | print("Winner not decided") 1257 | 1258 | return True 1259 | 1260 | def robo_judge(self, ind="give"): 1261 | if ind == "give":# For give the value 1262 | all_in = 1# Denoting all the coins are present in the room 1263 | for i in range(4): 1264 | if self.red_coin_position[i] == -1: 1265 | all_in = 1 1266 | else: 1267 | all_in = 0# Denoting all the coins not present in the room 1268 | break 1269 | 1270 | if all_in == 1:# All coins are present in room 1271 | if self.move_red_counter == 6: 1272 | predicted_coin = choice([1,2,3,4]) 1273 | self.robo_store.append(predicted_coin) 1274 | self.main_controller("red", predicted_coin) 1275 | else: 1276 | pass 1277 | else:# All coins not present in room 1278 | temp = self.red_coin_position# Take red coin position reference 1279 | take_ref = self.sky_blue_coin_position# Take sky_blue coin position reference 1280 | 1281 | if len(self.robo_store) == 1:# When only one coin is outside of the room 1282 | if self.move_red_counter<6:# When prediction less than 6 1283 | if (self.count_robo_stage_from_start>3) and (temp[self.robo_store[0]-1] >=33 and temp[self.robo_store[0]-1]<=38): 1284 | self.count_robo_stage_from_start = 2 1285 | self.main_controller("red", self.robo_store[0]) 1286 | else:# When prediction is 6 1287 | forward_perm = 0# Controlling process to be forward or not 1288 | for coin in take_ref:# coin is sky_blue individual coin distance 1289 | if coin>-1 and coin<101: 1290 | if (coin != 40 or coin != 35 or coin != 27 or coin != 22 or coin != 14 or coin != 9 or coin !=1 or coin !=48) and coin-temp[self.robo_store[0]-1] >= 6 and coin-temp[self.robo_store[0]-1] <= 12: 1291 | forward_perm = 1 1292 | break 1293 | else: 1294 | forward_perm = 0 1295 | else: 1296 | forward_perm = 0 1297 | 1298 | if forward_perm == 0:# Not forward the process 1299 | store = [1,2,3,4] 1300 | store.remove(self.robo_store[0]) 1301 | predicted_coin = choice(store) 1302 | self.robo_store.append(predicted_coin) 1303 | self.main_controller("red", predicted_coin) 1304 | else:# Forward the entire process 1305 | self.main_controller("red", self.robo_store[0]) 1306 | else: 1307 | def normal_movement_according_condition(): 1308 | # This portion is for checking if current location + predicted value <= 106 or not.....Coin Filtering 1309 | normal_movement = 1# Normal Movement of the entite coin 1310 | 1311 | for coin in self.robo_store:# coin is coin number 1312 | if temp[coin-1]+self.move_red_counter <= 106:# For all coins having predicted location <=106 1313 | pass 1314 | else: 1315 | normal_movement = 0 1316 | break 1317 | 1318 | if normal_movement: 1319 | temp_robo_store = [coin for coin in self.robo_store] 1320 | else: 1321 | temp_robo_store = [coin for coin in self.robo_store if temp[coin-1]+self.move_red_counter <= 106] 1322 | 1323 | # This portion is for coin filtering under some constrains 1324 | for coin in temp_robo_store:# coin is coin number 1325 | if len(temp_robo_store)>1 and temp[coin-1]<101: # See Diagram under help to unserstand to understand the location 1326 | if (temp[coin-1] in take_ref) and (temp[coin-1] != 1 or temp[coin-1] != 9 or temp[coin-1] != 14 or temp[coin-1] != 22 or temp[coin-1] != 27 or temp[coin-1] != 35 or temp[coin-1] != 40 or temp[coin-1] != 48): 1327 | temp_robo_store.remove(coin) 1328 | elif temp[coin-1]<=39 and temp[coin-1]+self.move_red_counter>39: 1329 | for loc_coin_other in take_ref: 1330 | if (loc_coin_other>=40 and loc_coin_other<=46) and (temp[coin-1]+self.move_red_counter>loc_coin_other): 1331 | temp_robo_store.remove(coin) 1332 | break 1333 | 1334 | # Overlapp checking with predicted value to eliminate other coin 1335 | process_forward = 1 1336 | for coin in temp_robo_store: 1337 | if temp[coin-1]+self.move_red_counter in take_ref: 1338 | process_forward = 0 1339 | self.main_controller("red", coin) 1340 | break 1341 | 1342 | # Not a single overlapp found so now self rescue or safe forward 1343 | if process_forward: 1344 | take_len = len(temp_robo_store) 1345 | store = {} 1346 | if take_ref: 1347 | for robo in temp_robo_store:# robo is coin number 1348 | for coin_other in take_ref:# coin_other is sky_blue coin location 1349 | if coin_other>-1 and coin_other<100: 1350 | if take_len>1 and (temp[robo-1]>38 and coin_other<=38) or ((temp[robo-1] == 9 or temp[robo-1] == 14 or temp[robo-1] == 27 or temp[robo-1] == 35 or temp[robo-1] == 40 or temp[robo-1] == 48 or temp[robo-1] == 22) and (coin_other<=temp[robo-1] or (coin_other>temp[robo-1] and coin_other<=temp[robo-1]+3))): # avoid case to store 1351 | take_len-=1 1352 | else: 1353 | store[temp[robo-1]-coin_other] = (robo, take_ref.index(coin_other)+1)# Store coin number 1354 | 1355 | # positive_distance = robo front negative_distance = robo_behind 1356 | if store: 1357 | store_positive_dis = {} 1358 | store_negative_dis = {} 1359 | take_max = 0 1360 | take_min = 0 1361 | 1362 | try: 1363 | store_positive_dis = dict((k,v) for k,v in store.items() if k>0) 1364 | take_min = min(store_positive_dis.items()) 1365 | except: 1366 | pass 1367 | try: 1368 | store_negative_dis = dict((k,v) for k,v in store.items() if k<0) 1369 | take_max = max(store_negative_dis.items()) 1370 | except: 1371 | pass 1372 | 1373 | # Positive forward checking 1374 | work_comp_in_pos = 0 1375 | take_len = len(store_positive_dis) 1376 | index_from_last = -1 1377 | 1378 | while take_len: 1379 | if take_min and take_min[0] <= 6: 1380 | 1381 | work_comp_in_pos = 1 1382 | self.main_controller("red", take_min[1][0]) 1383 | break 1384 | else: 1385 | index_from_last -= 1 1386 | try: 1387 | take_min = min(sorted(store_positive_dis.items())[index_from_last]) 1388 | except: 1389 | break 1390 | take_len -= 1 1391 | 1392 | 1393 | # Negative forward checking 1394 | work_comp_in_neg = 0 1395 | if not work_comp_in_pos: 1396 | take_len = len(store_negative_dis) 1397 | index_from_last = len(store_negative_dis)-1 1398 | while take_len: 1399 | if take_max and temp[take_max[1][0]-1] + self.move_red_counter <= take_ref[take_max[1][1]-1]: 1400 | work_comp_in_neg = 1 1401 | self.main_controller("red", take_max[1][0]) 1402 | break 1403 | else: 1404 | index_from_last -= 1 1405 | try: 1406 | take_max = max(sorted(store_negative_dis.items())[index_from_last]) 1407 | except: 1408 | break 1409 | take_len -= 1 1410 | 1411 | # Not operate in positive and negative distance method...So now cover it by closest distance to the destination 1412 | if not work_comp_in_neg and not work_comp_in_pos: 1413 | close_to_dest = temp_robo_store[0] 1414 | for coin_index in range(1,len(temp_robo_store)): 1415 | if temp[temp_robo_store[coin_index]-1] > temp[close_to_dest-1]: 1416 | close_to_dest = temp_robo_store[coin_index] 1417 | 1418 | self.main_controller("red", close_to_dest) 1419 | else:# If store(Not find the location difference) is empty 1420 | close_to_dest = temp_robo_store[0] 1421 | for coin_index in range(1,len(temp_robo_store)): 1422 | if temp[temp_robo_store[coin_index]-1] > temp[close_to_dest-1]: 1423 | close_to_dest = temp_robo_store[coin_index] 1424 | self.main_controller("red", close_to_dest) 1425 | else: 1426 | pass 1427 | 1428 | # For multiple Coin control Giving 1429 | if self.move_red_counter<6: 1430 | normal_movement_according_condition() 1431 | else: 1432 | coin_proceed = 0 1433 | 1434 | for coin in self.robo_store: 1435 | if temp[coin-1] + self.move_red_counter in self.sky_blue_coin_position: 1436 | coin_proceed = coin 1437 | break 1438 | 1439 | if not coin_proceed: 1440 | if -1 in self.red_coin_position: 1441 | # Coin out 1442 | temp_store = [1,2,3,4] 1443 | for coin in self.robo_store: 1444 | temp_store.remove(coin) 1445 | take_pred = choice(temp_store) 1446 | self.robo_store.append(take_pred) 1447 | self.main_controller("red", take_pred) 1448 | else: 1449 | # coin proceed 1450 | normal_movement_according_condition() 1451 | else: 1452 | self.main_controller("red", coin_proceed) 1453 | else: 1454 | self.make_prediction("red")# Prediction Function Call 1455 | 1456 | 1457 | if __name__ == '__main__': 1458 | window = Tk() 1459 | window.geometry("800x630") 1460 | window.maxsize(800,630) 1461 | window.minsize(800,630) 1462 | window.title("AI Integration With Ludo") 1463 | window.iconbitmap("Images/ludo_icon.ico") 1464 | block_six_side = ImageTk.PhotoImage(Image.open("Images/6_block.png").resize((33, 33), Image.ANTIALIAS)) 1465 | block_five_side = ImageTk.PhotoImage(Image.open("Images/5_block.png").resize((33, 33), Image.ANTIALIAS)) 1466 | block_four_side = ImageTk.PhotoImage(Image.open("Images/4_block.png").resize((33, 33), Image.ANTIALIAS)) 1467 | block_three_side = ImageTk.PhotoImage(Image.open("Images/3_block.png").resize((33, 33), Image.ANTIALIAS)) 1468 | block_two_side = ImageTk.PhotoImage(Image.open("Images/2_block.png").resize((33, 33), Image.ANTIALIAS)) 1469 | block_one_side = ImageTk.PhotoImage(Image.open("Images/1_block.png").resize((33, 33), Image.ANTIALIAS)) 1470 | Ludo(window,block_six_side,block_five_side,block_four_side,block_three_side,block_two_side,block_one_side) 1471 | window.mainloop() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://img.shields.io/badge/Programming_Language-Python-blue.svg) 2 | ![](https://img.shields.io/badge/Main_Tool_Used-Tkinter-gold.svg) 3 | ![](https://img.shields.io/badge/Supporting_Tool_Used-Pillow-orange.svg) 4 | ![](https://img.shields.io/badge/Game-Ludo-yellow.svg) 5 | ![](https://img.shields.io/badge/Mode-AI-orange.svg) 6 | ![](https://img.shields.io/badge/Python_Version-3.9-brown.svg) 7 | ![](https://img.shields.io/badge/Status-Stable-green.svg) 8 | 9 |

👋 Welcome Developers 👋

10 | 11 |

⌛ Introducing my New Game ⌛

12 | 13 |

14 | 15 | ###

💖 Yes, This is Ludo Game made by Python Tkinter 💖

16 | 17 | *** 18 | 19 |

🙄 But What Special 😳

20 | 21 |

1. 😲 You Can Play Ludo With Your Computer 😲

22 |

2. 😍 You Can Play Ludo With Your Friends 😍

23 |
24 | 25 |

26 |

🙋 You Can Select Your Favourable Game Mode From Here 🙋

27 | 28 | *** 29 | 30 |

💻 This is a Desktop App 💻


31 |

💘 For Play With Computer 🧐

32 |

🎯 Computer Will Deal With ❤️ Red ❤️ and You Will Deal With 💙 Sky-Blue 💙


33 | 34 |

💘 For Play With Friends 🧐

35 |

🎯 Minimum Players to participate: 2 Players

36 |

🎯 Maximum Players to participate: 4 Players


37 | 38 | ###

🧐 Before Contributing, Recommended to Check [CONTRIBUTING.md](https://github.com/SamarpanCoder2002/AI-Integrated-Ludo-Game/blob/main/CONTRIBUTING.md) file

39 | 40 |

Show 💘 by Starring this Repo

41 | 42 | *** 43 | ### ⚒️ ***_Requirements of this game:-_*** 44 |

1. Python(version >3.3)

45 |

2. Pillow

46 |

🚧 To Install Pillow, Open Your Terminal or cmd and Write:-

47 | 48 | ```bash 49 | pip install pillow 50 | ``` 51 | 52 | *** 53 |

💡 Some Important Links 💡

54 | 55 | - [

Click Here to See the Project Video

](https://youtu.be/5NScX6qgd3Y) 56 | 57 | - [

Follow Me on LinkedIn to Get Regular Project Updates

](https://www.linkedin.com/in/samarpan-dasgupta-4aa1061b0/ "LCO") 58 | 59 |

🧡 Thank You For Visiting 🙏, Have a Nice Day 🧡

60 | 61 | 62 | 63 | --------------------------------------------------------------------------------