-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashgamebot.py
More file actions
executable file
·50 lines (43 loc) · 1.5 KB
/
hashgamebot.py
File metadata and controls
executable file
·50 lines (43 loc) · 1.5 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
42
43
44
45
46
47
48
49
50
"""
Python Hash Game Bot Test
@author "Gustavo-Sampaio (14mPr0gr4mm3r)"
@description "a bot to play Python Hash Game (created by me too)"
"""
#import math
import random
from time import sleep
from defs import Sign
class Bot():
hashgrid: dict
uservalue: Sign
myvalue: Sign
def __init__(self, hashgrid, uservalue, botvalue):
self.hashgrid = hashgrid
self.uservalue = uservalue
self.myvalue = botvalue
def updateGrid(self, grid: dict):
self.hashgrid = grid
def makeChoice(self):
sleep(random.random() * random.randint(1, 3))
choice = random.randint(1, 9)
tests = [
(1, 2, 3),
(1, 5, 9),
(1, 4, 7),
(2, 5, 8),
(3, 5, 7),
(3, 6, 9),
(4, 5, 6),
(7, 8, 9)
]
for value in [self.uservalue, self.myvalue]:
for t in tests:
if self.hashgrid[t[0]] == value and self.hashgrid[t[1]] == value and self.hashgrid[t[2]] == ' ':
choice = t[2]
elif self.hashgrid[t[0]] == value and self.hashgrid[t[1]] == ' ' and self.hashgrid[t[2]] == value:
choice = t[1]
elif self.hashgrid[t[0]] == ' ' and self.hashgrid[t[1]] == value and self.hashgrid[t[2]] == value:
choice = t[0]
while self.hashgrid[choice] != ' ':
choice = random.randint(1, 9)
return str(choice)