Skip to content

Commit 73cb94e

Browse files
Merge branch 'main' into refactor/874-modular-mainjs
2 parents 5ff77e6 + 4a9ca31 commit 73cb94e

41 files changed

Lines changed: 2867 additions & 1063 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,20 @@ These standalone Python project files do not have a browser counterpart yet and
446446
<sub><b>@Reaper-ai</b></sub>
447447
</a>
448448
</td>
449+
<td align="center" width="120">
450+
<a href="https://github.com/Ridima28">
451+
<img src="https://github.com/Ridima28.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="Ridima28" /><br />
452+
<sub><b>@Ridima28</b></sub>
453+
</a>
454+
</td>
455+
</tr>
456+
<tr>
449457
<td align="center" width="120">
450458
<a href="https://github.com/Sanjhivvarshan-b-s">
451459
<img src="https://github.com/Sanjhivvarshan-b-s.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="Sanjhivvarshan-b-s" /><br />
452460
<sub><b>@Sanjhivvarshan-b-s</b></sub>
453461
</a>
454462
</td>
455-
</tr>
456-
<tr>
457463
<td align="center" width="120">
458464
<a href="https://github.com/SathvikaTalari">
459465
<img src="https://github.com/SathvikaTalari.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="SathvikaTalari" /><br />
@@ -484,14 +490,14 @@ These standalone Python project files do not have a browser counterpart yet and
484490
<sub><b>@Siddh2024</b></sub>
485491
</a>
486492
</td>
493+
</tr>
494+
<tr>
487495
<td align="center" width="120">
488496
<a href="https://github.com/Sparshjoshi-iit">
489497
<img src="https://github.com/Sparshjoshi-iit.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="Sparshjoshi-iit" /><br />
490498
<sub><b>@Sparshjoshi-iit</b></sub>
491499
</a>
492500
</td>
493-
</tr>
494-
<tr>
495501
<td align="center" width="120">
496502
<a href="https://github.com/Sreekuttan-007">
497503
<img src="https://github.com/Sreekuttan-007.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="Sreekuttan-007" /><br />
@@ -522,14 +528,14 @@ These standalone Python project files do not have a browser counterpart yet and
522528
<sub><b>@Tiago-Vier-Preto</b></sub>
523529
</a>
524530
</td>
531+
</tr>
532+
<tr>
525533
<td align="center" width="120">
526534
<a href="https://github.com/Vaishnavisatle2105">
527535
<img src="https://github.com/Vaishnavisatle2105.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="Vaishnavisatle2105" /><br />
528536
<sub><b>@Vaishnavisatle2105</b></sub>
529537
</a>
530538
</td>
531-
</tr>
532-
<tr>
533539
<td align="center" width="120">
534540
<a href="https://github.com/Vanshikakhasat">
535541
<img src="https://github.com/Vanshikakhasat.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="Vanshikakhasat" /><br />
@@ -560,14 +566,14 @@ These standalone Python project files do not have a browser counterpart yet and
560566
<sub><b>@advikdivekar</b></sub>
561567
</a>
562568
</td>
569+
</tr>
570+
<tr>
563571
<td align="center" width="120">
564572
<a href="https://github.com/anujsharma8d">
565573
<img src="https://github.com/anujsharma8d.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="anujsharma8d" /><br />
566574
<sub><b>@anujsharma8d</b></sub>
567575
</a>
568576
</td>
569-
</tr>
570-
<tr>
571577
<td align="center" width="120">
572578
<a href="https://github.com/artic2702">
573579
<img src="https://github.com/artic2702.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="artic2702" /><br />
@@ -598,14 +604,14 @@ These standalone Python project files do not have a browser counterpart yet and
598604
<sub><b>@ayushyadav0707</b></sub>
599605
</a>
600606
</td>
607+
</tr>
608+
<tr>
601609
<td align="center" width="120">
602610
<a href="https://github.com/bhavyapandiya29">
603611
<img src="https://github.com/bhavyapandiya29.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="bhavyapandiya29" /><br />
604612
<sub><b>@bhavyapandiya29</b></sub>
605613
</a>
606614
</td>
607-
</tr>
608-
<tr>
609615
<td align="center" width="120">
610616
<a href="https://github.com/codewithakshyaaa">
611617
<img src="https://github.com/codewithakshyaaa.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="codewithakshyaaa" /><br />
@@ -636,14 +642,14 @@ These standalone Python project files do not have a browser counterpart yet and
636642
<sub><b>@gatiksolanki13-netizen</b></sub>
637643
</a>
638644
</td>
645+
</tr>
646+
<tr>
639647
<td align="center" width="120">
640648
<a href="https://github.com/iamprasoon2006-cell">
641649
<img src="https://github.com/iamprasoon2006-cell.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="iamprasoon2006-cell" /><br />
642650
<sub><b>@iamprasoon2006-cell</b></sub>
643651
</a>
644652
</td>
645-
</tr>
646-
<tr>
647653
<td align="center" width="120">
648654
<a href="https://github.com/itsdakshjain">
649655
<img src="https://github.com/itsdakshjain.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="itsdakshjain" /><br />
@@ -674,14 +680,14 @@ These standalone Python project files do not have a browser counterpart yet and
674680
<sub><b>@kumudasrip</b></sub>
675681
</a>
676682
</td>
683+
</tr>
684+
<tr>
677685
<td align="center" width="120">
678686
<a href="https://github.com/madhavcodes25">
679687
<img src="https://github.com/madhavcodes25.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="madhavcodes25" /><br />
680688
<sub><b>@madhavcodes25</b></sub>
681689
</a>
682690
</td>
683-
</tr>
684-
<tr>
685691
<td align="center" width="120">
686692
<a href="https://github.com/mahi-8758">
687693
<img src="https://github.com/mahi-8758.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="mahi-8758" /><br />
@@ -712,14 +718,14 @@ These standalone Python project files do not have a browser counterpart yet and
712718
<sub><b>@nene-hana</b></sub>
713719
</a>
714720
</td>
721+
</tr>
722+
<tr>
715723
<td align="center" width="120">
716724
<a href="https://github.com/nimkarprachi17">
717725
<img src="https://github.com/nimkarprachi17.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="nimkarprachi17" /><br />
718726
<sub><b>@nimkarprachi17</b></sub>
719727
</a>
720728
</td>
721-
</tr>
722-
<tr>
723729
<td align="center" width="120">
724730
<a href="https://github.com/nishtha-agarwal-211">
725731
<img src="https://github.com/nishtha-agarwal-211.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="nishtha-agarwal-211" /><br />
@@ -750,14 +756,14 @@ These standalone Python project files do not have a browser counterpart yet and
750756
<sub><b>@pragya-manna</b></sub>
751757
</a>
752758
</td>
759+
</tr>
760+
<tr>
753761
<td align="center" width="120">
754762
<a href="https://github.com/prasad-0007">
755763
<img src="https://github.com/prasad-0007.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="prasad-0007" /><br />
756764
<sub><b>@prasad-0007</b></sub>
757765
</a>
758766
</td>
759-
</tr>
760-
<tr>
761767
<td align="center" width="120">
762768
<a href="https://github.com/priya05-git">
763769
<img src="https://github.com/priya05-git.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="priya05-git" /><br />
@@ -788,14 +794,14 @@ These standalone Python project files do not have a browser counterpart yet and
788794
<sub><b>@sakshicoded1111</b></sub>
789795
</a>
790796
</td>
797+
</tr>
798+
<tr>
791799
<td align="center" width="120">
792800
<a href="https://github.com/samarthchawla2005">
793801
<img src="https://github.com/samarthchawla2005.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="samarthchawla2005" /><br />
794802
<sub><b>@samarthchawla2005</b></sub>
795803
</a>
796804
</td>
797-
</tr>
798-
<tr>
799805
<td align="center" width="120">
800806
<a href="https://github.com/sanzzzz-g">
801807
<img src="https://github.com/sanzzzz-g.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="sanzzzz-g" /><br />
@@ -826,14 +832,14 @@ These standalone Python project files do not have a browser counterpart yet and
826832
<sub><b>@shreyasgawande19</b></sub>
827833
</a>
828834
</td>
835+
</tr>
836+
<tr>
829837
<td align="center" width="120">
830838
<a href="https://github.com/siri-004">
831839
<img src="https://github.com/siri-004.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="siri-004" /><br />
832840
<sub><b>@siri-004</b></sub>
833841
</a>
834842
</td>
835-
</tr>
836-
<tr>
837843
<td align="center" width="120">
838844
<a href="https://github.com/snehacodes-2906">
839845
<img src="https://github.com/snehacodes-2906.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="snehacodes-2906" /><br />
@@ -864,14 +870,14 @@ These standalone Python project files do not have a browser counterpart yet and
864870
<sub><b>@tanishkakora</b></sub>
865871
</a>
866872
</td>
873+
</tr>
874+
<tr>
867875
<td align="center" width="120">
868876
<a href="https://github.com/twinkle0tech">
869877
<img src="https://github.com/twinkle0tech.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="twinkle0tech" /><br />
870878
<sub><b>@twinkle0tech</b></sub>
871879
</a>
872880
</td>
873-
</tr>
874-
<tr>
875881
<td align="center" width="120">
876882
<a href="https://github.com/vedansht2211">
877883
<img src="https://github.com/vedansht2211.png?size=100" width="100" height="100" style="border-radius:50%; border:2px solid #555;" alt="vedansht2211" /><br />
@@ -902,7 +908,6 @@ These standalone Python project files do not have a browser counterpart yet and
902908
<sub><b>@yuvraj-k-singh</b></sub>
903909
</a>
904910
</td>
905-
<td width="120"></td>
906911
</tr>
907912
</table>
908913
<!-- CONTRIBUTORS_END -->

games/2048-Game/2048-Game.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
CELL_PADDING = 10
88
BACKGROUND_COLOR = "#92877d"
99
EMPTY_CELL_COLOR = "#9e948a"
10+
TOTAL_MOVES = 100
1011

1112
TILE_COLORS = {
1213
2: "#eee4da",
@@ -45,6 +46,7 @@ def __init__(self, root):
4546
self.root = root
4647
self.root.title("2048 Game")
4748
self.root.resizable(False, False)
49+
self.moves_left = TOTAL_MOVES
4850

4951
self.score = 0
5052
self.high_score = self.load_high_score()
@@ -59,6 +61,12 @@ def __init__(self, root):
5961
)
6062
self.score_label.grid(pady=10)
6163

64+
self.total_moves_label = tk.Label(
65+
root,
66+
text=f"Moves left: {self.moves_left}",
67+
font=("Arial", 16, "bold")
68+
)
69+
self.total_moves_label.grid(pady=10)
6270
self.restart_button = tk.Button(
6371
root,
6472
text="Restart Game",
@@ -137,6 +145,7 @@ def create_grid(self):
137145
def start_new_game(self):
138146
self.board = [[0] * GRID_SIZE for _ in range(GRID_SIZE)]
139147
self.score = 0
148+
self.moves_left = TOTAL_MOVES
140149

141150
self.add_new_tile()
142151
self.add_new_tile()
@@ -175,6 +184,8 @@ def update_grid(self):
175184
self.score_label.configure(
176185
text=f"Score: {self.score} High Score: {self.high_score}"
177186
)
187+
self.total_moves_label.configure(
188+
text=f"Moves left: {self.moves_left}")
178189

179190
self.root.update_idletasks()
180191

@@ -268,9 +279,12 @@ def handle_keypress(self, event):
268279

269280
else:
270281
return
282+
283+
271284

272285
if moved:
273286
self.add_new_tile()
287+
self.moves_left -=1
274288

275289
if self.score > self.high_score:
276290
self.high_score = self.score
@@ -282,6 +296,8 @@ def handle_keypress(self, event):
282296
# Game over is now checked even when no movement happens
283297
if self.check_game_over():
284298
self.game_over()
299+
if self.moves_left<=0:
300+
self.game_over()
285301

286302
def game_over(self):
287303

games/Dots-Boxes-AI/Dots-Boxes-AI.py

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@
1010
MAGENTA = "\033[95m"
1111
BOLD = "\033[1m"
1212

13+
14+
def get_affected_boxes(direction, row, col, size):
15+
affected = []
16+
if direction == 'h':
17+
if row > 0:
18+
affected.append((row - 1, col))
19+
if row < size:
20+
affected.append((row, col))
21+
else:
22+
if col > 0:
23+
affected.append((row, col - 1))
24+
if col < size:
25+
affected.append((row, col))
26+
return affected
27+
28+
29+
def is_completed_box(r, c, horizontal_lines, vertical_lines):
30+
return (
31+
horizontal_lines[r][c]
32+
and horizontal_lines[r + 1][c]
33+
and vertical_lines[r][c]
34+
and vertical_lines[r][c + 1]
35+
)
36+
37+
1338
while True:
1439
print(BOLD + CYAN)
1540
print("=" * 70)
@@ -136,18 +161,14 @@
136161

137162
# Check boxes
138163
completed = False
139-
for r in range(size):
140-
for c in range(size):
141-
if boxes[r][c] == ' ':
142-
top = horizontal_lines[r][c]
143-
bottom = horizontal_lines[r + 1][c]
144-
left = vertical_lines[r][c]
145-
right = vertical_lines[r][c + 1]
146-
if top and bottom and left and right:
147-
boxes[r][c] = symbol
148-
completed = True
149-
if symbol == 'P': player_score += 1
150-
else: computer_score += 1
164+
for r, c in get_affected_boxes(direction, row, col, size):
165+
if boxes[r][c] == ' ' and is_completed_box(r, c, horizontal_lines, vertical_lines):
166+
boxes[r][c] = symbol
167+
completed = True
168+
if symbol == 'P':
169+
player_score += 1
170+
else:
171+
computer_score += 1
151172

152173
if not completed:
153174
current_player = 2 if current_player == 1 else 1
@@ -178,17 +199,10 @@
178199
else: vertical_lines[r][c] = True
179200

180201
completes = False
181-
for r_b in range(size):
182-
for c_b in range(size):
183-
sides = 0
184-
if horizontal_lines[r_b][c_b]: sides += 1
185-
if horizontal_lines[r_b + 1][c_b]: sides += 1
186-
if vertical_lines[r_b][c_b]: sides += 1
187-
if vertical_lines[r_b][c_b + 1]: sides += 1
188-
if sides == 4:
189-
completes = True
190-
break
191-
if completes: break
202+
for r_b, c_b in get_affected_boxes(d, r, c, size):
203+
if is_completed_box(r_b, c_b, horizontal_lines, vertical_lines):
204+
completes = True
205+
break
192206

193207
if d == 'h': horizontal_lines[r][c] = False
194208
else: vertical_lines[r][c] = False
@@ -265,18 +279,14 @@
265279
if direction == 'h': horizontal_lines[row][col] = True
266280
else: vertical_lines[row][col] = True
267281

282+
# Check boxes for AI
268283
completed = False
269-
for r in range(size):
270-
for c in range(size):
271-
if boxes[r][c] == ' ':
272-
top = horizontal_lines[r][c]
273-
bottom = horizontal_lines[r + 1][c]
274-
left = vertical_lines[r][c]
275-
right = vertical_lines[r][c + 1]
276-
if top and bottom and left and right:
277-
boxes[r][c] = 'A'
278-
completed = True
279-
computer_score += 1
284+
for r, c in get_affected_boxes(direction, row, col, size):
285+
if boxes[r][c] == ' ' and is_completed_box(r, c, horizontal_lines, vertical_lines):
286+
boxes[r][c] = 'A'
287+
completed = True
288+
computer_score += 1
289+
280290
if not completed:
281291
current_player = 1
282292

@@ -341,4 +351,4 @@
341351
break
342352
print(RED + "⚠️ Invalid input. Enter 'y' or 'n'." + RESET)
343353
if replay in ['n', 'no']:
344-
break
354+
break

0 commit comments

Comments
 (0)