@ThomasS1/

MineSweeper-5

Python

No description

fork
loading
Files
  • main.py
  • instructions.txt
  • replit.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9759769980475825","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJhbmRvbSwgdGltZSwgY29weSwgcmVwbGl0CmZyb20gdGVybWNvbG9yIGltcG9ydCBjcHJpbnQKCiNJbnRyb2R1Y3Rpb24KcHJpbnQoKQpjcHJpbnQoJ1dlbGNvbWUgdG8gTWluZVN3ZWVwZXIgdi4zLjAhJywgJ3JlZCcpCmNwcmludCgnPT09PT09PT09PT09PT09PT09PT09PT09PT09PT0nLCAncmVkJykKcHJpbnQoKQpwcmludCgnRXhjaXRlZCB0byBkZWNsYXJlIHZlcnNpb24gMy4wIG9mIE1pbmVTd2VlcGVyIGFzIGFsbW9zdCBmdWxseSBmdW5jdGlvbmFsIScpCgoKI1NldHMgdXAgdGhlIGdhbWUuCmRlZiByZXNldCgpOgogICAgcHJpbnQoJycnCk1BSU4gTUVOVQo9PT09PT09PT0KCi0+IEZvciBpbnN0cnVjdGlvbnMgb24gaG93IHRvIHBsYXksIHR5cGUgJ0knCi0+IFRvIHBsYXkgaW1tZWRpYXRlbHksIHR5cGUgJ1AnCicnJykKCiAgICBjaG9pY2UgPSBpbnB1dCgnVHlwZSBoZXJlOiAnKS51cHBlcigpCgogICAgaWYgY2hvaWNlID09ICdJJzoKICAgICAgICByZXBsaXQuY2xlYXIoKQoKICAgICAgICAjUHJpbnRzIGluc3RydWN0aW9ucy4KICAgICAgICBwcmludChvcGVuKCdpbnN0cnVjdGlvbnMudHh0JywgJ3InKS5yZWFkKCkpCgogICAgICAgIGlucHV0KCdQcmVzcyBbZW50ZXJdIHdoZW4gcmVhZHkgdG8gcGxheS4gJykKICAgICAgICAKICAgIGVsaWYgY2hvaWNlICE9ICdQJzoKICAgICAgICByZXBsaXQuY2xlYXIoKQogICAgICAgIHJlc2V0KCkKCiA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IpOgoKICAgICNSb3cgYWJvdmUuCiAgICBpZiBybi0xID4gLTE6CiAgICAgICAgciA9IGJbcm4tMV0KICAgICAgICAKICAgICAgICBpZiBjLTEgPiAtMToKICAgICAgICAgICAgaWYgbm90IHJbYy0xXSA9PSAnKic6CiAgICAgICAgICAgICAgICByW2MtMV0gKz0gMQoKICAgICAgICBpZiBub3QgcltjXSA9PSAnKic6CiAgICAgICAgICAgIHJbY10gKz0gMQoKICAgICAgICBpZiA5ID4gYysxOgogICAgICAgICAgICBpZiBub3QgcltjKzFdID09ICcqJzoKICAgICAgICAgICAgICAgIHJbYysxXSArPSAxCgogICAgI1NhbWUgcm93LiAgICAKICAgIHIgPSBiW3JuXQoKICAgIGlmIGMtMSA+IC0xOgogICAgICAgIGlmIG5vdCByW2MtMV0gPT0gJyonOgogICAgICAgICAgICByW2MtMV0gKz0gMQoKICAgIGlmIDkgPiBjKzE6CiAgICAgICAgaWYgbm90IHJbYysxXSA9PSAnKic6CiAgICAgICAgICAgIHJbYysxXSArPSAxCgogICAgI1JvdyBiZWxvdy4KICAgIGlmIDkgPiBybisxOgogICAgICAgIHIgPSBiW3JuKzFdCgogICAgICAgIGlmIGMtMSA+IC0xOgogICAgICAgICAgICBpZiBub3QgcltjLTFdID09ICcqJzoKICAgICAgICAgICAgICAgIHJbYy0xXSArPSAxCgogICAgICAgIGlmIG5vdCByW2NdID09ICcqJzoKICAgICAgICAgICAgcltjXSArPSAxCgogICAgICAgIGlmIDkgPiBjKzE6CiAgICAgICAgICAgIGlmIG5vdCByW2MrMV0gPT0gJyonOgogICAgICAgICAgICAgICAgcltjKzFdICs9IDEKCiNQcmludHMgdGhlIGdpdmVuIGJvYXJkLgpkZWYgcHJpbnRCb2FyZChiKToKICAgIHJlcGxpdC5jbGVhcigpCiAgICBwcmludCgnICAgIEEgICBCICAgQyAgIEQgICBFICAgRiAgIEcgICBIICAgSScpCiAgICBwcmludCgnICDilZTilZDilZDilZDilabilZDilZDilZDilabilZDilZDilZDil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KCdDaG9vc2UgYSBzcXVhcmUgKGVnLiBFNCkgb3IgcGxhY2UgYSBtYXJrZXIgKGVnLiBtRTQpOiAnKS5sb3dlcigpCiAgICAgICAgI0NoZWNrcyBmb3IgdmFsaWQgc3F1YXJlLgogICAgICAgIGlmIGxlbihjaG9zZW4pID09IDMgYW5kIGNob3NlblswXSA9PSAnbScgYW5kIGNob3NlblsxXSBpbiBsZXR0ZXJzIGFuZCBjaG9zZW5bMl0gaW4gbnVtYmVyczoKICAgICAgICAgICAgYywgciA9IChvcmQoY2hvc2VuWzFdKSktOTcsIGludChjaG9zZW5bMl0pCiAgICAgICAgICAgIG1hcmtlcihyLCBjLCBrKQogICAgICAgICAgICBwbGF5KGIsIGssIHN0YXJ0VGltZSkKICAgICAgICAgICAgYnJlYWsKICAgICAgICBlbGlmIGxlbihjaG9zZW4pID09IDIgYW5kIGNob3NlblswXSBpbiBsZXR0ZXJzIGFuZCBjaG9zZW5bMV0gaW4gbnVtYmVyczogcmV0dXJuIChvcmQoY2hvc2VuWzBdKSktOTcsIGludChjaG9zZW5bMV0pCiAgICAgICAgZWxzZTogY2hvb3NlKGIsIGssIHN0YXJ0VGltZSkKCiNQbGFjZXMgYSBtYXJrZXIgaW4gdGhlIGdpdmVuIGxvY2F0aW9uLgpkZWYgbWFya2VyKHIsIGMsIGspOgogICAga1tyXVtjXSA9ICfimpAnCiAgICBwcmludEJvYXJkKGspCgojV2hlbiBhIHplcm8gaXMgZm91bmQsIGFsbCB0aGUgc3F1YXJlcyBhcm91bmQgaXQgYXJlIG9wZW5lZC4KZGVmIHplcm9Qcm9jZWR1cmUociwgYywgaywgYik6CgogICAgI1JvdyBhYm92ZQogICAgaWYgci0xID4gLTE6CiAgICAgICAgcm93ID0ga1tyLTFdCiAgICAgICAgaWYgYy0xID4gLTE6IHJvd1tjLTFdID0gbChyLTEsIGMtMSwgYikKICAgICAgICByb3dbY10gPSBsKHItMSwgYywgYikKICAgICAgICBpZiA5ID4gYysxOiByb3dbYysxXSA9IGwoci0xLCBjKzEsIGIpCgogICAgI1NhbWUgcm93CiAgICByb3cgPSBrW3JdCiAgICBpZiBjLTEgPiAtMTogcm93W2MtMV0gPSBsKHIsIGMtMSwgYikKICAgIGlmIDkgPiBjKzE6IHJvd1tjKzFdID0gbChyLCBjKzEsIGIpCgogICAgI1JvdyBiZWxvdwogICAgaWYgOSA+IHIrMToKICAgICAgICByb3cgPSBrW3IrMV0KICAgICAgICBpZiBjLTEgPiAtMTogcm93W2MtMV0gPSBsKHIrMSwgYy0xLCBiKQogICAgICAgIHJvd1tjXSA9IGwocisxLCBjLCBiKQogICAgICAgIGlmIDkgPiBjKzE6IHJvd1tjKzFdID0gbChyKzEsIGMrMSwgYikKCiNDaGVja3Mga25vd24gZ3JpZCBmb3IgMHMuCmRlZiBjaGVja1plcm9zKGssIGIsIHIsIGMpOgogICAgb2xkR3JpZCA9IGNvcHkuZGVlcGNvcHkoaykKICAgIHplcm9Qcm9jZWR1cmUociwgYywgaywgYikKICAgIGlmIG9sZEdyaWQgPT0gazoKICAgICAgICByZXR1cm4KICAgIHdoaWxlIFRydWU6CiAgICAgICAgb2xkR3JpZCA9IGNvcHkuZGVlcGNvcHkoaykKICAgICAgICBmb3IgeCBpbiByYW5nZSAoOSk6CiAgICAgICAgICAgIGZvciB5IGluIHJhbmdlICg5KToKICAgICAgICAgICAgICAgIGlmIGwoeCwgeSwgaykgPT0gMDoKICAgICAgICAgICAgICAgICAgICB6ZXJvUHJvY2VkdXJlKHgsIHksIGssIGIpCiAgICAgICAgaWYgb2xkR3JpZCA9PSBrOgogICAgICAgICAgICByZXR1cm4KCiNUaGUgbWFqb3JpdHkgb2YgdGhlIGdhbWVwbGF5IGhhcHBlbnMgaGVyZS4KZGVmIHBsYXkoYiwgaywgc3RhcnRUaW1lKToKICAgICNQbGF5ZXIgY2hvb3NlcyBzcXVhcmUuCiAgICBjLCByID0gY2hvb3NlKGIsIGssIHN0YXJ0VGltZSkKICAgICNHZXRzIHRoZSB2YWx1ZSBhdCB0aGF0IGxvY2F0aW9uLgogICAgdiA9IGwociwgYywgYikKICAgICNJZiB5b3UgaGl0IGEgYm9tYiwgaXQgZW5kcyB0aGUgZ2FtZS4KICAgIGlmIHYgPT0gJyonOgogICAgICAgIHByaW50Qm9hcmQoYikKICAgICAgICBwcmludCgnWW91IExvc2UhJykKICAgICAgICAjUHJpbnQgdGltZXIgcmVzdWx0LgogICAgICAgIHByaW50KCdUaW1lOiAnICsgc3RyKHJvdW5kKHRpbWUudGltZSgpIC0gc3RhcnRUaW1lKSkgKyAncycpCiAgICAgICAgI09mZmVyIHRvIHBsYXkgYWdhaW4uCiAgICAgICAgcGxheUFnYWluID0gaW5wdXQoJ1BsYXkgYWdhaW4/IChZL04pOiAnKS5sb3dlcigpCiAgICAgICAgaWYgcGxheUFnYWluID09ICd5JzoKICAgICAgICAgICAgcmVwbGl0LmNsZWFyKCkKICAgICAgICAgICAgcmVzZXQoKQogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHF1aXQoKQogICAgI1B1dHMgdGhhdCB2YWx1ZSBpbnRvIHRoZSBrbm93biBncmlkIChrKS4KICAgIGtbcl1bY10gPSB2CiAgICAjUnVucyBjaGVja1plcm9zKCkgaWYgdGhhdCB2YWx1ZSBpcyBhIDAuCiAgICBpZiB2ID09IDA6CiAgICAgICAgY2hlY2taZXJvcyhrLCBiLCByLCBjKQogICAgcHJpbnRCb2FyZChrKQogICAgI0NoZWNrcyB0byBzZWUgaWYgeW91IGhhdmUgd29uLgogICAgc3F1YXJlc0xlZnQgPSAwCiAgICBmb3IgeCBpbiByYW5nZSAoMCwgOSk6CiAgICAgICAgcm93ID0ga1t4XQogICAgICAgIHNxdWFyZXNMZWZ0ICs9IHJvdy5jb3VudCgnICcpCiAgICAgICAgc3F1YXJlc0xlZnQgKz0gcm93LmNvdW50KCfimpAnKQogICAgaWYgc3F1YXJlc0xlZnQgPT0gMTA6CiAgICAgICAgcHJpbnRCb2FyZChiKQogICAgICAgIHByaW50KCdZb3Ugd2luIScpCiAgICAgICAgI1ByaW50IHRpbWVyIHJlc3VsdC4KICAgICAgICBwcmludCgnVGltZTogJyArIHN0cihyb3VuZCh0aW1lLnRpbWUoKSAtIHN0YXJ0VGltZSkpICsgJ3MnKQogICAgICAgICNPZmZlciB0byBwbGF5IGFnYWluLgogICAgICAgIHBsYXlBZ2FpbiA9IGlucHV0KCdQbGF5IGFnYWluPyAoWS9OKTogJykKICAgICAgICBwbGF5QWdhaW4gPSBwbGF5QWdhaW4ubG93ZXIoKQogICAgICAgIGlmIHBsYXlBZ2FpbiA9PSAneSc6CiAgICAgICAgICAgIHJlcGxpdC5jbGVhcigpCiAgICAgICAgICAgIHJlc2V0KCkKICAgICAgICBlbHNlOgogICAgICAgICAgICBxdWl0KCkKICAgICNSZXBlYXRzIQogICAgcGxheShiLCBrLCBzdGFydFRpbWUpCgoKCgpyZXNldCgp"},"asBuffer":null},"loaded":true}}
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import random, time, copy, replit
from termcolor import cprint

#Introduction
print()
cprint('Welcome to MineSweeper v.3.0!', 'red')
cprint('=============================', 'red')
print()
print('Excited to declare version 3.0 of MineSweeper as almost fully functional!')


#Sets up the game.
def reset():
    print('''
MAIN MENU
=========

-> For instructions on how to play, type 'I'
-> To play immediately, type 'P'
''')

    choice = input('Type here: ').upper()

    if choice == 'I':
        replit.clear()

        #Prints instructions.
        print(open('instructions.txt', 'r').read())

        input('Press [enter] when ready to play. ')
        
    elif choice != 'P':
        replit.clear()
        reset()

    #The solution grid.
    b = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]

    for n in range (0, 10):
        placeBomb(b)

    for r in range (0, 9):
        for c in range (0, 9):
            value = l(r, c, b)
            if value == '*':
                updateValues(r, c, b)

    #Sets the variable k to a grid of blank spaces, because nothing is yet known about the grid.
    k = [[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']]

    printBoard(k)

    #Start timer
    startTime = time.time()

    #The game begins!
    play(b, k, startTime)

#Gets the value of a coordinate on the grid.
def l(r, c, b):
    return b[r][c]

#Places a bomb in a random location.
def placeBomb(b):
    r = random.randint(0, 8)
    c = random.randint(0, 8)
    #Checks if there's a bomb in the randomly generated location. If not, it puts one there. If there is, it requests a new location to try.
    currentRow = b[r]
    if not currentRow[c] == '*':
        currentRow[c] = '*'
    else:
        placeBomb(b)

#Adds 1 to all of the squares around a bomb.
def updateValues(rn, c, b):

    #Row above.
    if rn-1 > -1:
        r = b[rn-1]
        
        if c-1 > -1:
            if not r[c-1] == '*':
                r[c-1] += 1

        if not r[c] == '*':
            r[c] += 1

        if 9 > c+1:
            if not r[c+1] == '*':
                r[c+1] += 1

    #Same row.    
    r = b[rn]

    if c-1 > -1:
        if not r[c-1] == '*':
            r[c-1] += 1

    if 9 > c+1:
        if not r[c+1] == '*':
            r[c+1] += 1

    #Row below.
    if 9 > rn+1:
        r = b[rn+1]

        if c-1 > -1:
            if not r[c-1] == '*':
                r[c-1] += 1

        if not r[c] == '*':
            r[c] += 1

        if 9 > c+1:
            if not r[c+1] == '*':
                r[c+1] += 1

#Prints the given board.
def printBoard(b):
    replit.clear()
    print('    A   B   C   D   E   F   G   H   I')
    print('  ╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗')
    for r in range (0, 9):
        print(r,'║',l(r,0,b),'║',l(r,1,b),'║',l(r,2,b),'║',l(r,3,b),'║',l(r,4,b),'║',l(r,5,b),'║',l(r,6,b),'║',l(r,7,b),'║',l(r,8,b),'║')
        if not r == 8:
            print('  ╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣')
    print('  ╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝')

#The player chooses a location.
def choose(b, k, startTime):
    #Variables 'n stuff.
    letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ,'i']
    numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8']
    #Loop in case of invalid entry.
    while True:
        chosen = input('Choose a square (eg. E4) or place a marker (eg. mE4): ').lower()
        #Checks for valid square.
        if len(chosen) == 3 and chosen[0] == 'm' and chosen[1] in letters and chosen[2] in numbers:
            c, r = (ord(chosen[1]))-97, int(chosen[2])
            marker(r, c, k)
            play(b, k, startTime)
            break
        elif len(chosen) == 2 and chosen[0] in letters and chosen[1] in numbers: return (ord(chosen[0]))-97, int(chosen[1])
        else: choose(b, k, startTime)

#Places a marker in the given location.
def marker(r, c, k):
    k[r][c] = '⚐'
    printBoard(k)

#When a zero is found, all the squares around it are opened.
def zeroProcedure(r, c, k, b):

    #Row above
    if r-1 > -1:
        row = k[r-1]
        if c-1 > -1: row[c-1] = l(r-1, c-1, b)
        row[c] = l(r-1, c, b)
        if 9 > c+1: row[c+1] = l(r-1, c+1, b)

    #Same row
    row = k[r]
    if c-1 > -1: row[c-1] = l(r, c-1, b)
    if 9 > c+1: row[c+1] = l(r, c+1, b)

    #Row below
    if 9 > r+1:
        row = k[r+1]
        if c-1 > -1: row[c-1] = l(r+1, c-1, b)
        row[c] = l(r+1, c, b)
        if 9 > c+1: row[c+1] = l(r+1, c+1, b)

#Checks known grid for 0s.
def checkZeros(k, b, r, c):
    oldGrid = copy.deepcopy(k)
    zeroProcedure(r, c, k, b)
    if oldGrid == k:
        return
    while True:
        oldGrid = copy.deepcopy(k)
        for x in range (9):
            for y in range (9):
                if l(x, y, k) == 0:
                    zeroProcedure(x, y, k, b)
        if oldGrid == k:
            return

#The majority of the gameplay happens here.
def play(b, k, startTime):
    #Player chooses square.
    c, r = choose(b, k, startTime)
    #Gets the value at that location.
    v = l(r, c, b)
    #If you hit a bomb, it ends the game.
    if v == '*':
        printBoard(b)
        print('You Lose!')
        #Print timer result.
        print('Time: ' + str(round(time.time() - startTime)) + 's')
        #Offer to play again.
        playAgain = input('Play again? (Y/N): ').lower()
        if playAgain == 'y':
            replit.clear()
            reset()
        else:
            quit()
    #Puts that value into the known grid (k).
    k[r][c] = v
    #Runs checkZeros() if that value is a 0.
    if v == 0:
        checkZeros(k, b, r, c)
    printBoard(k)
    #Checks to see if you have won.
    squaresLeft = 0
    for x in range (0, 9):
        row = k[x]
        squaresLeft += row.count(' ')
        squaresLeft += row.count('⚐')
    if squaresLeft == 10:
        printBoard(b)
        print('You win!')
        #Print timer result.
        print('Time: ' + str(round(time.time() - startTime)) + 's')
        #Offer to play again.
        playAgain = input('Play again? (Y/N): ')
        playAgain = playAgain.lower()
        if playAgain == 'y':
            replit.clear()
            reset()
        else:
            quit()
    #Repeats!
    play(b, k, startTime)




reset()