forked from harrischristiansen/generals-bot
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathHistory.py
More file actions
60 lines (48 loc) · 1.88 KB
/
History.py
File metadata and controls
60 lines (48 loc) · 1.88 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
51
52
53
54
55
56
57
58
59
60
"""
@ Travis Drake (EklipZ) eklipz.io - tdrake0x45 at gmail)
April 2017
Generals.io Automated Client - https://github.com/harrischristiansen/generals-bot
EklipZ bot - Tries to play generals lol
"""
import logbook
import typing
from copy import deepcopy
import time
import json
from pprint import pprint,pformat
from Models import Move
class History(object):
def __init__(self):
self.contested_cities = {}
self.aggressive_enemy_moves = []
self.player_captures = []
self.attempted_threat_kills = set()
self.move_history: typing.Dict[int, typing.List[Move]] = {}
self.droppedHistory = {}
def add_city_contestation(self, city, turn, player, army):
if city not in self.contested_cities:
contestedObject = ContestedCityInfo(city, 0)
self.contested_cities[city] = contestedObject
contestedObject = self.contested_cities[city]
contestedObject.add_contested(turn, player, army)
def captured_player(self, turn, capturedPlayer, capturingPlayer):
self.player_captures.append(PlayerCapture(turn, capturedPlayer, capturingPlayer))
class ContestedCityInfo(object):
def __init__(self, city, contestationCount = 0):
self.contestationCount = contestationCount
self.tile = city
self.city = city
self.contestedTurns = []
def add_contested(self, turn, player, army):
self.contestedTurns.append(ContestInstance(self.city, turn, player, army))
class ContestInstance(object):
def __init__(self, tile, turn, player, army):
self.tile = tile
self.turn = turn
self.player = player
self.army = army
class PlayerCapture(object):
def __init__(self, turn, capturedPlayer, capturingPlayer):
self.capturedPlayer = capturedPlayer
self.capturingPlayer = capturingPlayer
self.turn = turn