├── .gitignore
├── LICENSE
├── Pipfile
├── Pipfile.lock
├── README.md
├── img
├── number_guess.png
└── playgames.png
├── playgame.py
├── requirements.txt
└── src
├── RockPaperScissor.py
├── dice.py
├── dragon_realm.py
├── guess_the_number.py
├── hangman.py
├── minesweeper.py
└── tictactoe.py
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | *.ipynb
3 | venv/
4 | .venv
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Paras Gupta
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | url = "https://pypi.org/simple"
3 | verify_ssl = true
4 | name = "pypi"
5 |
6 | [packages]
7 | pyfiglet = "*"
8 | pyinquirer = "*"
9 | tinge = "*"
10 |
11 | [dev-packages]
12 | black = "*"
13 |
14 | [requires]
15 | python_version = "3.6"
16 |
17 | [pipenv]
18 | allow_prereleases = true
19 |
--------------------------------------------------------------------------------
/Pipfile.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_meta": {
3 | "hash": {
4 | "sha256": "0955d50f552d3f0d5db72cbd721da904b2c12182b79d2f719e45624e8a19935e"
5 | },
6 | "pipfile-spec": 6,
7 | "requires": {
8 | "python_version": "3.6"
9 | },
10 | "sources": [
11 | {
12 | "name": "pypi",
13 | "url": "https://pypi.org/simple",
14 | "verify_ssl": true
15 | }
16 | ]
17 | },
18 | "default": {
19 | "colorama": {
20 | "hashes": [
21 | "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
22 | "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
23 | ],
24 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
25 | "version": "==0.4.4"
26 | },
27 | "prompt-toolkit": {
28 | "hashes": [
29 | "sha256:7281b5199235adaef6980942840c43753e4ab20dfe41338da634fb41c194f9d8",
30 | "sha256:82c7f8e07d7a0411ff5367a5a8ff520f0112b9179f3e599ee8ad2ad9b943d911",
31 | "sha256:cc66413b1b4b17021675d9f2d15d57e640b06ddfd99bb724c73484126d22622f"
32 | ],
33 | "version": "==1.0.14"
34 | },
35 | "pyfiglet": {
36 | "hashes": [
37 | "sha256:c6c2321755d09267b438ec7b936825a4910fec696292139e664ca8670e103639",
38 | "sha256:d555bcea17fbeaf70eaefa48bb119352487e629c9b56f30f383e2c62dd67a01c"
39 | ],
40 | "index": "pypi",
41 | "version": "==0.8.post1"
42 | },
43 | "pygments": {
44 | "hashes": [
45 | "sha256:a18f47b506a429f6f4b9df81bb02beab9ca21d0a5fee38ed15aef65f0545519f",
46 | "sha256:d66e804411278594d764fc69ec36ec13d9ae9147193a1740cd34d272ca383b8e"
47 | ],
48 | "markers": "python_version >= '3.5'",
49 | "version": "==2.9.0"
50 | },
51 | "pyinquirer": {
52 | "hashes": [
53 | "sha256:c9a92d68d7727fbd886a7908c08fd9e9773e5dc211bf5cbf836ba90d366dee51"
54 | ],
55 | "index": "pypi",
56 | "version": "==1.0.3"
57 | },
58 | "regex": {
59 | "hashes": [
60 | "sha256:0eb2c6e0fcec5e0f1d3bcc1133556563222a2ffd2211945d7b1480c1b1a42a6f",
61 | "sha256:15dddb19823f5147e7517bb12635b3c82e6f2a3a6b696cc3e321522e8b9308ad",
62 | "sha256:173bc44ff95bc1e96398c38f3629d86fa72e539c79900283afa895694229fe6a",
63 | "sha256:1c78780bf46d620ff4fff40728f98b8afd8b8e35c3efd638c7df67be2d5cddbf",
64 | "sha256:2366fe0479ca0e9afa534174faa2beae87847d208d457d200183f28c74eaea59",
65 | "sha256:2bceeb491b38225b1fee4517107b8491ba54fba77cf22a12e996d96a3c55613d",
66 | "sha256:2ddeabc7652024803666ea09f32dd1ed40a0579b6fbb2a213eba590683025895",
67 | "sha256:2fe5e71e11a54e3355fa272137d521a40aace5d937d08b494bed4529964c19c4",
68 | "sha256:319eb2a8d0888fa6f1d9177705f341bc9455a2c8aca130016e52c7fe8d6c37a3",
69 | "sha256:3f5716923d3d0bfb27048242a6e0f14eecdb2e2a7fac47eda1d055288595f222",
70 | "sha256:422dec1e7cbb2efbbe50e3f1de36b82906def93ed48da12d1714cabcd993d7f0",
71 | "sha256:4c9c3155fe74269f61e27617529b7f09552fbb12e44b1189cebbdb24294e6e1c",
72 | "sha256:4f64fc59fd5b10557f6cd0937e1597af022ad9b27d454e182485f1db3008f417",
73 | "sha256:564a4c8a29435d1f2256ba247a0315325ea63335508ad8ed938a4f14c4116a5d",
74 | "sha256:59506c6e8bd9306cd8a41511e32d16d5d1194110b8cfe5a11d102d8b63cf945d",
75 | "sha256:598c0a79b4b851b922f504f9f39a863d83ebdfff787261a5ed061c21e67dd761",
76 | "sha256:59c00bb8dd8775473cbfb967925ad2c3ecc8886b3b2d0c90a8e2707e06c743f0",
77 | "sha256:6110bab7eab6566492618540c70edd4d2a18f40ca1d51d704f1d81c52d245026",
78 | "sha256:6afe6a627888c9a6cfbb603d1d017ce204cebd589d66e0703309b8048c3b0854",
79 | "sha256:791aa1b300e5b6e5d597c37c346fb4d66422178566bbb426dd87eaae475053fb",
80 | "sha256:8394e266005f2d8c6f0bc6780001f7afa3ef81a7a2111fa35058ded6fce79e4d",
81 | "sha256:875c355360d0f8d3d827e462b29ea7682bf52327d500a4f837e934e9e4656068",
82 | "sha256:89e5528803566af4df368df2d6f503c84fbfb8249e6631c7b025fe23e6bd0cde",
83 | "sha256:99d8ab206a5270c1002bfcf25c51bf329ca951e5a169f3b43214fdda1f0b5f0d",
84 | "sha256:9a854b916806c7e3b40e6616ac9e85d3cdb7649d9e6590653deb5b341a736cec",
85 | "sha256:b85ac458354165405c8a84725de7bbd07b00d9f72c31a60ffbf96bb38d3e25fa",
86 | "sha256:bc84fb254a875a9f66616ed4538542fb7965db6356f3df571d783f7c8d256edd",
87 | "sha256:c92831dac113a6e0ab28bc98f33781383fe294df1a2c3dfd1e850114da35fd5b",
88 | "sha256:cbe23b323988a04c3e5b0c387fe3f8f363bf06c0680daf775875d979e376bd26",
89 | "sha256:ccb3d2190476d00414aab36cca453e4596e8f70a206e2aa8db3d495a109153d2",
90 | "sha256:d8bbce0c96462dbceaa7ac4a7dfbbee92745b801b24bce10a98d2f2b1ea9432f",
91 | "sha256:db2b7df831c3187a37f3bb80ec095f249fa276dbe09abd3d35297fc250385694",
92 | "sha256:e586f448df2bbc37dfadccdb7ccd125c62b4348cb90c10840d695592aa1b29e0",
93 | "sha256:e5983c19d0beb6af88cb4d47afb92d96751fb3fa1784d8785b1cdf14c6519407",
94 | "sha256:e6a1e5ca97d411a461041d057348e578dc344ecd2add3555aedba3b408c9f874",
95 | "sha256:eaf58b9e30e0e546cdc3ac06cf9165a1ca5b3de8221e9df679416ca667972035",
96 | "sha256:ed693137a9187052fc46eedfafdcb74e09917166362af4cc4fddc3b31560e93d",
97 | "sha256:edd1a68f79b89b0c57339bce297ad5d5ffcc6ae7e1afdb10f1947706ed066c9c",
98 | "sha256:f080248b3e029d052bf74a897b9d74cfb7643537fbde97fe8225a6467fb559b5",
99 | "sha256:f9392a4555f3e4cb45310a65b403d86b589adc773898c25a39184b1ba4db8985",
100 | "sha256:f98dc35ab9a749276f1a4a38ab3e0e2ba1662ce710f6530f5b0a6656f1c32b58"
101 | ],
102 | "version": "==2021.7.6"
103 | },
104 | "six": {
105 | "hashes": [
106 | "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
107 | "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
108 | ],
109 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
110 | "version": "==1.16.0"
111 | },
112 | "tinge": {
113 | "hashes": [
114 | "sha256:02c261994f513c56847c885f0441eabd29e16918a375af7e70703fc06a1222a3",
115 | "sha256:7dde354bd9b5cae7bb364e288fccbb5ce4748cf26484dae2cff7e9a2f979a7e7"
116 | ],
117 | "index": "pypi",
118 | "version": "==0.0.2"
119 | },
120 | "wcwidth": {
121 | "hashes": [
122 | "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784",
123 | "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"
124 | ],
125 | "version": "==0.2.5"
126 | }
127 | },
128 | "develop": {
129 | "appdirs": {
130 | "hashes": [
131 | "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41",
132 | "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"
133 | ],
134 | "version": "==1.4.4"
135 | },
136 | "black": {
137 | "hashes": [
138 | "sha256:1c7aa6ada8ee864db745b22790a32f94b2795c253a75d6d9b5e439ff10d23116",
139 | "sha256:c8373c6491de9362e39271630b65b964607bc5c79c83783547d76c839b3aa219"
140 | ],
141 | "index": "pypi",
142 | "version": "==21.7b0"
143 | },
144 | "click": {
145 | "hashes": [
146 | "sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a",
147 | "sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6"
148 | ],
149 | "markers": "python_version >= '3.6'",
150 | "version": "==8.0.1"
151 | },
152 | "dataclasses": {
153 | "hashes": [
154 | "sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf",
155 | "sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97"
156 | ],
157 | "markers": "python_version < '3.7'",
158 | "version": "==0.8"
159 | },
160 | "importlib-metadata": {
161 | "hashes": [
162 | "sha256:079ada16b7fc30dfbb5d13399a5113110dab1aa7c2bc62f66af75f0b717c8cac",
163 | "sha256:9f55f560e116f8643ecf2922d9cd3e1c7e8d52e683178fecd9d08f6aa357e11e"
164 | ],
165 | "markers": "python_version < '3.8'",
166 | "version": "==4.6.1"
167 | },
168 | "mypy-extensions": {
169 | "hashes": [
170 | "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
171 | "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
172 | ],
173 | "version": "==0.4.3"
174 | },
175 | "pathspec": {
176 | "hashes": [
177 | "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a",
178 | "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"
179 | ],
180 | "version": "==0.9.0"
181 | },
182 | "regex": {
183 | "hashes": [
184 | "sha256:0eb2c6e0fcec5e0f1d3bcc1133556563222a2ffd2211945d7b1480c1b1a42a6f",
185 | "sha256:15dddb19823f5147e7517bb12635b3c82e6f2a3a6b696cc3e321522e8b9308ad",
186 | "sha256:173bc44ff95bc1e96398c38f3629d86fa72e539c79900283afa895694229fe6a",
187 | "sha256:1c78780bf46d620ff4fff40728f98b8afd8b8e35c3efd638c7df67be2d5cddbf",
188 | "sha256:2366fe0479ca0e9afa534174faa2beae87847d208d457d200183f28c74eaea59",
189 | "sha256:2bceeb491b38225b1fee4517107b8491ba54fba77cf22a12e996d96a3c55613d",
190 | "sha256:2ddeabc7652024803666ea09f32dd1ed40a0579b6fbb2a213eba590683025895",
191 | "sha256:2fe5e71e11a54e3355fa272137d521a40aace5d937d08b494bed4529964c19c4",
192 | "sha256:319eb2a8d0888fa6f1d9177705f341bc9455a2c8aca130016e52c7fe8d6c37a3",
193 | "sha256:3f5716923d3d0bfb27048242a6e0f14eecdb2e2a7fac47eda1d055288595f222",
194 | "sha256:422dec1e7cbb2efbbe50e3f1de36b82906def93ed48da12d1714cabcd993d7f0",
195 | "sha256:4c9c3155fe74269f61e27617529b7f09552fbb12e44b1189cebbdb24294e6e1c",
196 | "sha256:4f64fc59fd5b10557f6cd0937e1597af022ad9b27d454e182485f1db3008f417",
197 | "sha256:564a4c8a29435d1f2256ba247a0315325ea63335508ad8ed938a4f14c4116a5d",
198 | "sha256:59506c6e8bd9306cd8a41511e32d16d5d1194110b8cfe5a11d102d8b63cf945d",
199 | "sha256:598c0a79b4b851b922f504f9f39a863d83ebdfff787261a5ed061c21e67dd761",
200 | "sha256:59c00bb8dd8775473cbfb967925ad2c3ecc8886b3b2d0c90a8e2707e06c743f0",
201 | "sha256:6110bab7eab6566492618540c70edd4d2a18f40ca1d51d704f1d81c52d245026",
202 | "sha256:6afe6a627888c9a6cfbb603d1d017ce204cebd589d66e0703309b8048c3b0854",
203 | "sha256:791aa1b300e5b6e5d597c37c346fb4d66422178566bbb426dd87eaae475053fb",
204 | "sha256:8394e266005f2d8c6f0bc6780001f7afa3ef81a7a2111fa35058ded6fce79e4d",
205 | "sha256:875c355360d0f8d3d827e462b29ea7682bf52327d500a4f837e934e9e4656068",
206 | "sha256:89e5528803566af4df368df2d6f503c84fbfb8249e6631c7b025fe23e6bd0cde",
207 | "sha256:99d8ab206a5270c1002bfcf25c51bf329ca951e5a169f3b43214fdda1f0b5f0d",
208 | "sha256:9a854b916806c7e3b40e6616ac9e85d3cdb7649d9e6590653deb5b341a736cec",
209 | "sha256:b85ac458354165405c8a84725de7bbd07b00d9f72c31a60ffbf96bb38d3e25fa",
210 | "sha256:bc84fb254a875a9f66616ed4538542fb7965db6356f3df571d783f7c8d256edd",
211 | "sha256:c92831dac113a6e0ab28bc98f33781383fe294df1a2c3dfd1e850114da35fd5b",
212 | "sha256:cbe23b323988a04c3e5b0c387fe3f8f363bf06c0680daf775875d979e376bd26",
213 | "sha256:ccb3d2190476d00414aab36cca453e4596e8f70a206e2aa8db3d495a109153d2",
214 | "sha256:d8bbce0c96462dbceaa7ac4a7dfbbee92745b801b24bce10a98d2f2b1ea9432f",
215 | "sha256:db2b7df831c3187a37f3bb80ec095f249fa276dbe09abd3d35297fc250385694",
216 | "sha256:e586f448df2bbc37dfadccdb7ccd125c62b4348cb90c10840d695592aa1b29e0",
217 | "sha256:e5983c19d0beb6af88cb4d47afb92d96751fb3fa1784d8785b1cdf14c6519407",
218 | "sha256:e6a1e5ca97d411a461041d057348e578dc344ecd2add3555aedba3b408c9f874",
219 | "sha256:eaf58b9e30e0e546cdc3ac06cf9165a1ca5b3de8221e9df679416ca667972035",
220 | "sha256:ed693137a9187052fc46eedfafdcb74e09917166362af4cc4fddc3b31560e93d",
221 | "sha256:edd1a68f79b89b0c57339bce297ad5d5ffcc6ae7e1afdb10f1947706ed066c9c",
222 | "sha256:f080248b3e029d052bf74a897b9d74cfb7643537fbde97fe8225a6467fb559b5",
223 | "sha256:f9392a4555f3e4cb45310a65b403d86b589adc773898c25a39184b1ba4db8985",
224 | "sha256:f98dc35ab9a749276f1a4a38ab3e0e2ba1662ce710f6530f5b0a6656f1c32b58"
225 | ],
226 | "version": "==2021.7.6"
227 | },
228 | "tomli": {
229 | "hashes": [
230 | "sha256:0713b16ff91df8638a6a694e295c8159ab35ba93e3424a626dd5226d386057be",
231 | "sha256:be670d0d8d7570fd0ea0113bd7bb1ba3ac6706b4de062cc4c952769355c9c268"
232 | ],
233 | "markers": "python_version >= '3.6'",
234 | "version": "==1.0.4"
235 | },
236 | "typed-ast": {
237 | "hashes": [
238 | "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace",
239 | "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff",
240 | "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266",
241 | "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528",
242 | "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6",
243 | "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808",
244 | "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4",
245 | "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363",
246 | "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341",
247 | "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04",
248 | "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41",
249 | "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e",
250 | "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3",
251 | "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899",
252 | "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805",
253 | "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c",
254 | "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c",
255 | "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39",
256 | "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a",
257 | "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3",
258 | "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7",
259 | "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f",
260 | "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075",
261 | "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0",
262 | "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40",
263 | "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428",
264 | "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927",
265 | "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3",
266 | "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f",
267 | "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"
268 | ],
269 | "markers": "python_version < '3.8'",
270 | "version": "==1.4.3"
271 | },
272 | "typing-extensions": {
273 | "hashes": [
274 | "sha256:0ac0f89795dd19de6b97debb0c6af1c70987fd80a2d62d1958f7e56fcc31b497",
275 | "sha256:50b6f157849174217d0656f99dc82fe932884fb250826c18350e159ec6cdf342",
276 | "sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84"
277 | ],
278 | "markers": "python_version < '3.8'",
279 | "version": "==3.10.0.0"
280 | },
281 | "zipp": {
282 | "hashes": [
283 | "sha256:957cfda87797e389580cb8b9e3870841ca991e2125350677b2ca83a0e99390a3",
284 | "sha256:f5812b1e007e48cff63449a5e9f4e7ebea716b4111f9c4f9a645f91d579bf0c4"
285 | ],
286 | "markers": "python_version >= '3.6'",
287 | "version": "==3.5.0"
288 | }
289 | }
290 | }
291 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Command Line Interface Python Games
2 |
3 | Collection of some starter python game projects for beginners
4 |
5 | ### How to play these games
6 |
7 | 1. Clone this repository
8 |
9 | ```bash
10 | git clone https://github.com/g-paras/python-games.git
11 | cd python-games
12 | ```
13 |
14 | 2. Install requirements
15 |
16 | ```bash
17 | pip install -r requirements.txt
18 | ```
19 |
20 | 3. Start Game
21 |
22 | ```bash
23 | python3 playgame.py
24 | ```
25 |
26 | ### Sample play of Number Guess game
27 |
28 | 
29 |
30 | ## About this repository
31 |
32 | There are a total of 5 games in this repository, all of them are beginner lever that will help you practice your python basics like `loops`, `if-else`, `function`, `recursion`, `list comprehension`, `random module`, `time module`, and much more.
33 |
34 | #### Two additional modules are also used in this.
35 |
36 | - `tinge` : for printing colored text in console
37 | - `pyfiglet` : for ascii-art
38 | - `PyInquirer` : interactive command line interface
39 |
40 | #### Dependencies
41 |
42 | ```
43 | Package Version
44 | -------------- ---------
45 | pip 21.0.1
46 | prompt-toolkit 1.0.14
47 | pyfiglet 0.8.post1
48 | Pygments 2.9.0
49 | PyInquirer 1.0.3
50 | regex 2021.4.4
51 | setuptools 56.0.0
52 | six 1.16.0
53 | tinge 0.0.2
54 | wcwidth 0.2.5
55 | wheel 0.36.2
56 | ```
57 |
58 | ## Contributors
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/img/number_guess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/g-paras/python-games/4456f3a41b528f3903b43407860cc26e6c997cdd/img/number_guess.png
--------------------------------------------------------------------------------
/img/playgames.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/g-paras/python-games/4456f3a41b528f3903b43407860cc26e6c997cdd/img/playgames.png
--------------------------------------------------------------------------------
/playgame.py:
--------------------------------------------------------------------------------
1 | from PyInquirer import prompt, style_from_dict
2 |
3 |
4 | question = [
5 | {
6 | "type": "list",
7 | "name": "game",
8 | "message": "What would you like to play?",
9 | "choices": [
10 | "Dragon Realm",
11 | "Rock Paper Scissor",
12 | "Number Guess",
13 | "Tic Tac Toe",
14 | "Hangman",
15 | "Minesweeper"
16 | ],
17 | }
18 | ]
19 |
20 | answer = prompt(question).get("game")
21 | if answer == "Dragon Realm":
22 | from src.dragon_realm import main
23 | main()
24 |
25 | elif answer == "Rock Paper Scissor":
26 | from src.RockPaperScissor import main
27 | main()
28 |
29 | elif answer == "Number Guess":
30 | from src.guess_the_number import main
31 | main()
32 |
33 | elif answer == "Tic Tac Toe":
34 | from src.tictactoe import main
35 | main()
36 |
37 | elif answer == "Minesweeper":
38 | from src.minesweeper import main
39 | main()
40 | else:
41 | from src.hangman import main
42 | main()
43 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pyfiglet
2 | PyInquirer
3 | Tinge
--------------------------------------------------------------------------------
/src/RockPaperScissor.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 |
4 | def main():
5 | computer = random.choice(["rock", "paper", "scissor"])
6 | user = input("Guess any one from -> rock paper scissor: ")
7 | print("opponent choice : {}".format(computer))
8 |
9 | if computer == user:
10 | print("Tie")
11 | elif computer == "paper" and user == "scissor":
12 | print("{0} cuts {1}\ncongrats You win!".format(user, computer), "\U0001F929")
13 | elif computer == "paper" and user == "rock":
14 | print("{1} covers {0}\noops You lost!".format(user, computer), "\U0001F972")
15 | elif computer == "scissor" and user == "paper":
16 | print("{1} cuts {0}\noops You lost!".format(user, computer), "\U0001F972")
17 | elif computer == "scissor" and user == "rock":
18 | print("{0} smashes {1}\ncongrats You win!".format(user, computer), "\U0001F929")
19 | elif computer == "rock" and user == "scissor":
20 | print("{1} smashes {0}\noops You lost!".format(user, computer), "\U0001F972")
21 | elif computer == "rock" and user == "paper":
22 | print("{0} covers {1}\ncongrats You win!".format(user, computer), "\U0001F929")
23 | playagain()
24 |
25 |
26 | def playagain():
27 | """Ask user if he/she wants to play again or not"""
28 |
29 | if input("Would you like to play again (Yes/No)? ").lower().startswith("y"):
30 | main()
31 | else:
32 | print("Leaving so soon, we will miss you", "\U0001F97A")
33 |
34 |
35 | if __name__ == "__main__":
36 | main()
37 |
--------------------------------------------------------------------------------
/src/dice.py:
--------------------------------------------------------------------------------
1 | # roll the dice
2 | import random
3 | from tinge import colored
4 |
5 |
6 | def roll():
7 | return random.randint(1, 6)
8 |
9 |
10 | if __name__ == "__main__":
11 | while True:
12 | val = input(colored("Press Enter to roll the dice or q to quit ", "red"))
13 | if val.lower() == "q":
14 | break
15 | print(colored(f"You have got {roll()}", "blue"))
16 | print("Thank You for playing")
17 |
--------------------------------------------------------------------------------
/src/dragon_realm.py:
--------------------------------------------------------------------------------
1 | import random
2 | import time
3 |
4 |
5 | def display_intro():
6 | print("You are in a land full of drangons. In front of you,")
7 | print("You see two caves. In one cave, the dragon is friendly")
8 | print("and will share his treasure with you. The other dragon")
9 | print("is greedy and hungry, and will eat you on sight.")
10 |
11 |
12 | def choose_cave() -> int:
13 | cave = ""
14 | while cave != "1" and cave != "2":
15 | print("Which cave will you go into? (1 or 2)", end=" ")
16 | cave = input()
17 |
18 | return int(cave)
19 |
20 |
21 | def check_cave(choose_cave: int):
22 | print("You approaches the cave...")
23 | time.sleep(2)
24 | print("It is dark and spooky...")
25 | time.sleep(2)
26 | print("A large dragon jumps out in front of you!")
27 | print("He opens his jaws in front of you and...")
28 | print()
29 | time.sleep(2)
30 |
31 | friendly_cave = random.randint(1, 2)
32 |
33 | if choose_cave == friendly_cave:
34 | print("Gives you his treasure!")
35 | else:
36 | print("Gobbles you down in one bite!")
37 |
38 |
39 | def playagain() -> bool:
40 | """ask user to play again"""
41 | return input("Would you like to play again (Yes/No)? ").lower().startswith("y")
42 |
43 |
44 | def main():
45 | while True:
46 | display_intro()
47 | cave_number = choose_cave()
48 | check_cave(cave_number)
49 |
50 | if not playagain():
51 | return
52 |
53 |
54 | if __name__ == "__main__":
55 | main()
56 |
--------------------------------------------------------------------------------
/src/guess_the_number.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | from tinge import colored
4 |
5 |
6 | def welcome():
7 | """Welcome new user and explain rules of the game"""
8 | print(colored("Hello there \U0001F60A, Welcome to Guess the Number game", "green"))
9 | print("Game Rule -> ")
10 | print(
11 | "In this game you have to guess a number and you will have total 5 chances to guess it correct"
12 | "\n"
13 | "You guess should be in between 1 and 25"
14 | )
15 |
16 |
17 | def user_input():
18 | """Ask user to guess a number, if input is valid digit then return the user_input"""
19 | user_number = input("Guess a number: ")
20 | try:
21 | user_number = int(user_number)
22 | except:
23 | print("Please ender a valid digit!")
24 | return user_input()
25 | else:
26 | if 1 <= user_number <= 25:
27 | return user_number
28 | else:
29 | print("You need to enter a digit between 0 and 50")
30 | return user_input()
31 |
32 |
33 | def success(count: int):
34 | """Print the sucess message when user guess the correct number"""
35 | positions = ["1st", "2nd", "3rd", "4th", "5th"]
36 | print(
37 | colored(
38 | f"Wow!\U0001F929, you have won the game in {positions[count-1]} try",
39 | "green",
40 | )
41 | )
42 |
43 |
44 | def playagain():
45 | """Ask user if he/she wants to play again or not"""
46 | if input("Would you like to play again (Yes/No)? ").lower().startswith("y"):
47 | main()
48 | else:
49 | print("Leaving soon, we will miss you", "\U0001F97A")
50 | print(colored("Thanks for playing, Made with \u2665 by g-paras", "blue"))
51 |
52 |
53 | def main():
54 | welcome()
55 | number = random.randint(1, 25)
56 | # number = 18 # used while testing
57 | count = 0
58 | MAX_COUNT = 5
59 | while count < MAX_COUNT:
60 | user_number = user_input()
61 |
62 | count += 1
63 | if user_number == number:
64 | success(count)
65 | playagain()
66 | break
67 | elif user_number < number:
68 | print(colored("Number is too small", "red"))
69 | else:
70 | print(colored("Number is too big", "red"))
71 |
72 | if count == MAX_COUNT:
73 | print("You have exhausted all the chances, better luck next time.")
74 | playagain()
75 |
76 |
77 | if __name__ == "__main__":
78 | main()
79 |
--------------------------------------------------------------------------------
/src/hangman.py:
--------------------------------------------------------------------------------
1 | import random
2 | from string import ascii_lowercase as letters
3 | import pyfiglet
4 |
5 | HANGMAN = [
6 | r"""
7 | +-----+
8 | | |
9 | |
10 | |
11 | |
12 | |
13 | =========== """,
14 | r"""
15 | +-----+
16 | | |
17 | O |
18 | |
19 | |
20 | |
21 | =========== """,
22 | r"""
23 | +-----+
24 | | |
25 | O |
26 | | |
27 | |
28 | |
29 | =========== """,
30 | r"""
31 | +-----+
32 | | |
33 | O |
34 | /| |
35 | |
36 | |
37 | =========== """,
38 | r"""
39 | +-----+
40 | | |
41 | O |
42 | /|\ |
43 | |
44 | |
45 | =========== """,
46 | r"""
47 | +-----+
48 | | |
49 | O |
50 | /|\ |
51 | / |
52 | |
53 | =========== """,
54 | r"""
55 | +-----+
56 | | |
57 | O |
58 | /|\ |
59 | / \ |
60 | |
61 | =========== """,
62 | ]
63 |
64 | riddles = {
65 | "What is full of holes but still holds water?": "sponge",
66 | "What is always in front of you but can’t be seen?": "future",
67 | "I’m tall when I’m young, and I’m short when I’m old. What am I?": "candle",
68 | "What can you break, even if you never pick it up or touch it?": "promise",
69 | "What gets wet while drying?": "towel",
70 | "I shave every day, but my beard stays the same. What am I?": "barber",
71 | "The more of this there is, the less you see. What is it?": "darkness",
72 | }
73 |
74 |
75 | def get_random_riddle(riddles):
76 | return random.choice(list(riddles.items()))
77 |
78 |
79 | def display_board(HANGMAN, missed_letter, correct_letter, actual_word):
80 | print(HANGMAN[len(missed_letter)])
81 | print("Missed Letters:", "".join(missed_letter))
82 |
83 | print("Correct Letters: ", end="")
84 | # for i in actual_word:
85 | # if i in correct_letter:
86 | # print(i, end="")
87 | # else:
88 | # print("_", end="")
89 | # print()
90 |
91 | # or using list comprehension
92 | print("".join([i if i in correct_letter else "_" for i in actual_word]))
93 |
94 |
95 | def get_guess(already_guessed):
96 | guess = input("Guess a letter: ").lower()
97 | if len(guess) != 1:
98 | print("Please enter a single letter")
99 | return get_guess(already_guessed)
100 |
101 | elif guess in already_guessed:
102 | print("Already guessed")
103 | return get_guess(already_guessed)
104 |
105 | elif guess not in letters:
106 | print("Please enter a Letter")
107 | return get_guess(already_guessed)
108 |
109 | return guess
110 |
111 |
112 | def playagain():
113 | return input("Would you like to play again (Yes/No)? ").lower().startswith("y")
114 |
115 |
116 | def guessed_all(correct_letter, actual_answer):
117 | for i in actual_answer:
118 | if not i in correct_letter:
119 | return False
120 | return True
121 |
122 |
123 | def main():
124 | pyfiglet.print_figlet("HANGMAN")
125 | correct_letter = []
126 | missed_letter = []
127 | riddle, answer = get_random_riddle(riddles)
128 | print(riddle)
129 | while True:
130 | guess = get_guess(correct_letter + missed_letter)
131 | if guess in answer:
132 | correct_letter.append(guess)
133 | else:
134 | missed_letter.append(guess)
135 | display_board(HANGMAN, missed_letter, correct_letter, answer)
136 |
137 | if len(missed_letter) == 6:
138 | print("Correct answer is", answer)
139 | print("You lost, better luck next time \U0001F92A")
140 | if playagain():
141 | return main()
142 | return
143 |
144 | elif guessed_all(correct_letter, answer):
145 | print("Correct answer is", answer)
146 | print("You got the answer, you won \U0001F973")
147 | if playagain():
148 | return main()
149 | return
150 |
151 |
152 | if __name__ == "__main__":
153 | main()
154 |
--------------------------------------------------------------------------------
/src/minesweeper.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | def GenerateMineSweeperMap(n, k):
4 | arr = [[0 for row in range(n)] for column in range(n)]
5 | for num in range(k):
6 | x = random.randint(0,n-1)
7 | y = random.randint(0,n-1)
8 | arr[y][x] = 'X'
9 | if (x >=0 and x <= n-2) and (y >= 0 and y <= n-1):
10 | if arr[y][x+1] != 'X':
11 | arr[y][x+1] += 1
12 | if (x >=1 and x <= n-1) and (y >= 0 and y <= n-1):
13 | if arr[y][x-1] != 'X':
14 | arr[y][x-1] += 1
15 | if (x >= 1 and x <= n-1) and (y >= 1 and y <= n-1):
16 | if arr[y-1][x-1] != 'X':
17 | arr[y-1][x-1] += 1
18 |
19 | if (x >= 0 and x <= n-2) and (y >= 1 and y <= n-1):
20 | if arr[y-1][x+1] != 'X':
21 | arr[y-1][x+1] += 1
22 | if (x >= 0 and x <= n-1) and (y >= 1 and y <= n-1):
23 | if arr[y-1][x] != 'X':
24 | arr[y-1][x] += 1
25 |
26 | if (x >=0 and x <= n-2) and (y >= 0 and y <= n-2):
27 | if arr[y+1][x+1] != 'X':
28 | arr[y+1][x+1] += 1
29 | if (x >= 1 and x <= n-1) and (y >= 0 and y <= n-2):
30 | if arr[y+1][x-1] != 'X':
31 | arr[y+1][x-1] += 1
32 | if (x >= 0 and x <= n-1) and (y >= 0 and y <= n-2):
33 | if arr[y+1][x] != 'X':
34 | arr[y+1][x] += 1
35 | return arr
36 | def GeneratePlayerMap(n):
37 | arr = [['-' for row in range(n)] for column in range(n)]
38 | return arr
39 | def DisplayMap(map):
40 | for row in map:
41 | print(" ".join(str(cell) for cell in row))
42 | print("")
43 | def CheckWon(map):
44 | for row in map:
45 | for cell in row:
46 | if cell == '-':
47 | return False
48 | return True
49 | def CheckContinueGame(score):
50 | print("Score: ", score)
51 | isContinue = input("Do you want to try again? (y/n) :")
52 | if isContinue == 'n':
53 | return False
54 | return True
55 | def main():
56 | GameStatus = True
57 | while GameStatus:
58 | difficulty = input("Select your difficulty (1, 2, 3):")
59 | if difficulty.lower() == '1':
60 | n = 5
61 | k = 3
62 | elif difficulty.lower() == '2':
63 | n = 6
64 | k = 8
65 | else:
66 | n = 8
67 | k = 20
68 |
69 | minesweeper_map = GenerateMineSweeperMap(n, k)
70 | player_map = GeneratePlayerMap(n)
71 | score = 0
72 | while True:
73 | if CheckWon(player_map) == False:
74 | print("Which cell do you want to open : eg. 1,1 upto 5,5\n")
75 | ans=input()
76 | x=int(ans.split(",")[0])-1
77 | y=int(ans.split(",")[0])-1
78 | if (minesweeper_map[y][x] == 'X'):
79 | print("Game Over :(")
80 | DisplayMap(minesweeper_map)
81 | GameStatus = CheckContinueGame(score)
82 | break
83 | else:
84 | player_map[y][x] = minesweeper_map[y][x]
85 | DisplayMap(player_map)
86 | score += 1
87 |
88 | else:
89 | DisplayMap(player_map)
90 | print("You Won!!")
91 | GameStatus = CheckContinueGame(score)
92 | break
93 |
94 | if __name__ == "__main__":
95 | while True:
96 | try:
97 | main()
98 | except KeyboardInterrupt:
99 | print('\nEnd of Game.')
100 |
--------------------------------------------------------------------------------
/src/tictactoe.py:
--------------------------------------------------------------------------------
1 | from random import randint, choices, choice
2 | from tinge import colored
3 |
4 | # different marker for board to make it look interesting
5 | markers = [
6 | ("\U0000274C", "\U00002B55"),
7 | ("\U0001F642", "\U0001F975"),
8 | ("\U0001F60E", "\U0001F974"),
9 | ("\U0001F620", "\U0001F608"),
10 | ]
11 |
12 |
13 | def welcome():
14 | """Function to welcome new player"""
15 | print("Welcome to TicTacToe")
16 | print("Here is a sample board,\nremember the positions of board")
17 | draw_board([" 0", "1", "2", " 3", "4", "5", " 6", "7", "8"])
18 |
19 |
20 | def draw_board(board: list) -> None:
21 | """function to draw tictactoe board"""
22 | print(*board[:3], sep=" | ")
23 | print("------------")
24 | print(*board[3:6], sep=" | ")
25 | print("------------")
26 | print(*board[6:], sep=" | ")
27 |
28 |
29 | def choose_marker():
30 | """ask user to choose his/her marker"""
31 | options = choice(markers)
32 | print("Choose your marker 1.{} 2.{}:".format(*options), end=" ")
33 | marker = input()
34 | try:
35 | marker = int(marker)
36 | except:
37 | print("Reply with 1 or 2")
38 | return choose_marker()
39 | else:
40 | if marker in [1, 2]:
41 | print(f"Your maker is {options[marker-1]}")
42 | return options if marker == 1 else options[::-1]
43 | else:
44 | print("Reply with 1 or 2")
45 | return choose_marker()
46 |
47 |
48 | def is_board_full(board: list) -> bool:
49 | """return true if board is full else false"""
50 | return all([i != " " for i in board])
51 |
52 |
53 | def play_again() -> bool:
54 | """ask player to play again and return bool accouding to answer"""
55 | return input("Would you like to play again (Yes/No)? ").lower().startswith("y")
56 |
57 |
58 | def player_win(board: list, player: str) -> bool:
59 | """function to check weather player won or not"""
60 | return (
61 | (board[0] == board[1] == board[2] == player)
62 | or (board[3] == board[4] == board[5] == player)
63 | or (board[6] == board[7] == board[8] == player)
64 | or (board[0] == board[3] == board[6] == player)
65 | or (board[1] == board[4] == board[7] == player)
66 | or (board[2] == board[5] == board[8] == player)
67 | or (board[0] == board[4] == board[8] == player)
68 | or (board[2] == board[4] == board[6] == player)
69 | )
70 |
71 |
72 | def is_free(board: list, pos: int) -> bool:
73 | """checks if pos is free or filled"""
74 | return board[pos] == " "
75 |
76 |
77 | def who_first():
78 | """who will play first"""
79 | return randint(0, 1)
80 |
81 |
82 | def user_input(board):
83 | """promt user to enter next move, then check is that number is valid and that position is free, if yes the return the position"""
84 | move = input("Make your move (0-8) ")
85 | try:
86 | move = int(move)
87 | if move in range(9):
88 | if is_free(board, move):
89 | return move
90 | else:
91 | print("That position is already taken")
92 | return user_input(board)
93 | else:
94 | print("Your move should be in [0, 8]")
95 | return user_input(board)
96 | except:
97 | print("Please enter a valid digit")
98 | return user_input(board)
99 |
100 |
101 | def make_move(board: list, player: str, pos: int) -> None:
102 | """ask user to make move if input is valid then place the marker"""
103 | board[pos] = player
104 |
105 |
106 | def board_copy(board):
107 | """return a shallow copy of board"""
108 | return board.copy()
109 |
110 |
111 | def available_positions(board):
112 | """return all the available positions"""
113 | return [i for i in range(9) if board[i] == " "]
114 |
115 |
116 | def computer_move(board: list, computer: str, player: str) -> None:
117 |
118 | for i in available_positions(board):
119 | cboard = board_copy(board)
120 | make_move(cboard, computer, i)
121 | if player_win(cboard, computer):
122 | make_move(board, computer, i)
123 | print("Computer moved at position {}".format(i))
124 | return
125 |
126 | for i in available_positions(board):
127 | cboard = board_copy(board)
128 | make_move(cboard, player, i)
129 | if player_win(cboard, player):
130 | make_move(board, computer, i)
131 | print("Computer moved at position {}".format(i))
132 | return
133 |
134 | for i in [0, 2, 6, 8, 4, 1, 3, 5, 7]:
135 | if is_free(board, i):
136 | make_move(board, computer, i)
137 | print("Computer moved at position {}".format(i))
138 | return
139 |
140 |
141 | def main():
142 | """main function to play game"""
143 | welcome()
144 | board = [" "] * 9
145 | (player, computer) = choose_marker()
146 | turn = who_first()
147 | if turn == 1:
148 | print("Computer will make first move")
149 | else:
150 | print("You will go first")
151 | while True:
152 |
153 | if turn == 1:
154 | computer_move(board, computer, player)
155 | draw_board(board)
156 | turn = 0
157 | if player_win(board, computer):
158 | print("You loose, computer win")
159 | break
160 | elif is_board_full(board):
161 | print("There is a tie")
162 | break
163 | else:
164 | pos = user_input(board)
165 | make_move(board, player, pos)
166 | draw_board(board)
167 | turn = 1
168 | if player_win(board, player):
169 | print("You win, computer loose")
170 | break
171 | elif is_board_full(board):
172 | print("There is a tie")
173 | break
174 |
175 |
176 | if __name__ == "__main__":
177 | main()
178 |
--------------------------------------------------------------------------------