1
1
import random
2
+ import pandas as pd
2
3
3
4
# Taking players data
4
5
players = {} # stores players name their locations
5
6
isReady = {}
6
7
current_loc = 1 # vaiable for iterating location
7
8
8
- imp = True
9
+ # creating board
10
+ board = [
11
+ [100 , 99 , 98 , "S" , 96 , "S" , 94 , 93 , 92 , 91 ],
12
+ [81 , 82 , 83 , 84 , 85 , 86 , "L" , "S" , 89 , 90 ],
13
+ [80 , 79 , 78 , 77 , 76 , 75 , 74 , 73 , 72 , "L" ],
14
+ [61 , 62 , "S" , 64 , 65 , 66 , 67 , 68 , 69 , 70 ],
15
+ [60 , 59 , 58 , 57 , 56 , 55 , 54 , 53 , 52 , 51 ],
16
+ [41 , 42 , 43 , 44 , 45 , 46 , 47 , "S" , 49 , "L" ],
17
+ ["L" , 39 , 38 , 37 , "S" , 35 , 34 , 33 , "S" , 31 ],
18
+ [21 , 22 , 23 , 24 , 25 , 26 , 27 , "L" , 29 , 30 ],
19
+ ["L" , 19 , 18 , 17 , 16 , 15 , 14 , 13 , 12 , 11 ],
20
+ [1 , 2 , 3 , "L" , 5 , 6 , 7 , "L" , 9 , 10 ],
21
+ ]
22
+
23
+ df = pd .DataFrame (board )
24
+
25
+ styled_df = df .style \
26
+ .set_properties (** {'background-color' : 'lightblue' , 'color' : 'black' }) \
27
+ .set_table_styles ([{
28
+ 'selector' : 'td' ,
29
+ 'props' : [
30
+ ('padding' , '20px' ),
31
+ ]
32
+ }])
33
+
34
+ # DataFrame as HTML
35
+ html_output = styled_df .render ()
36
+
37
+ # Save the HTML output
38
+ with open ('styled_df_output.html' , 'w' ) as f :
39
+ f .write (html_output )
40
+
41
+ print ("HTML output saved to 'styled_df_output.html'" )
9
42
43
+ imp = True
10
44
11
45
# players input function
12
46
def player_input ():
@@ -42,13 +76,13 @@ def play():
42
76
global isReady
43
77
global imp
44
78
45
- while imp :
46
- print ("/" * 20 )
47
- print ("1 -> roll the dice (or enter)" )
48
- print ("2 -> start new game" )
49
- print ("3 -> exit the game" )
50
- print ("/" * 20 )
79
+ print ("/" * 20 )
80
+ print ("1 -> roll the dice (or enter)" )
81
+ print ("2 -> start new game" )
82
+ print ("3 -> exit the game" )
83
+ print ("/" * 20 )
51
84
85
+ while imp :
52
86
for i in players :
53
87
n = input ("{}'s turn: " .format (i )) or 1
54
88
n = int (n )
@@ -86,6 +120,7 @@ def play():
86
120
return
87
121
88
122
print (f"you are at position { players [i ]} " )
123
+ print ('-' * 20 )
89
124
90
125
elif n == 2 :
91
126
players = {} # stores player ans their locations
@@ -155,7 +190,7 @@ def ladder(a, i):
155
190
players [i ] = 67
156
191
elif (a == 71 ):
157
192
players [i ] = 92
158
- elif (a == 88 ):
193
+ elif (a == 87 ):
159
194
players [i ] = 99
160
195
else :
161
196
return players [i ]
@@ -170,4 +205,4 @@ def ladder(a, i):
170
205
print ("/" * 40 )
171
206
172
207
173
- player_input ()
208
+ player_input ()
0 commit comments