-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmine_game.py
More file actions
41 lines (41 loc) · 1.24 KB
/
mine_game.py
File metadata and controls
41 lines (41 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import random as r
m_no=1
n=int(input("Enter a integer number to play this game : "))
minex=[r.randint(0,n-1),r.randint(0,n-1),r.randint(0,n-1),r.randint(0,n-1)]
miney=[r.randint(0,n-1),r.randint(0,n-1),r.randint(0,n-1),r.randint(0,n-1)]
for i in range(0,3):
m_no+=1
for j in range(i+1,4):
if minex[i] == minex[j] and miney[i] == miney[j]:
m_no-=1
else:
continue
count=0
print("The x coordinates of mines\n",minex)
print("The y coordinates of mines\n",miney)
for i in range(0,(n**2)-m_no):
count+=1
m=input("Enter 'y' for continue : ")
if m=='y':
rx=int(input("Enter the x coordinate : "))
ry=int(input("Enter the y coordinate : "))
if rx>=n or rx<0 or ry>=n or ry<0:
print("Enter a valid input.")
continue
else:
print("Position : ",rx,ry)
if rx in minex and ry in miney:
a=minex.index(rx)
b=miney.index(ry)
if a==b:
print("Game Over")
break
else:
continue
else:
print("You Quit This Game")
break
if count == (n**2)-m_no:
print("You Win This Match")
else:
print("You Loose This Match")