-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
60 lines (53 loc) · 1.72 KB
/
main.py
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
import logging
from typing import Literal
from lpsim.server.match import Match
from lpsim.utils import BaseModel
from lpsim.server.deck import Deck
from lpsim.agents import RandomAgent
class Main(BaseModel):
""" """
version: str = "1.0.0"
name: Literal["GITCG"] = "GITCG"
match: Match = Match()
if __name__ == "__main__":
logging.basicConfig(level=logging.WARNING)
agent_0 = RandomAgent(player_idx=0)
agent_1 = RandomAgent(player_idx=1)
main = Main()
deck = Deck.from_str(
"""
default_version:4.1
character:Rhodeia of Loch
character:Kamisato Ayaka
character:Yaoyao
Traveler's Handy Sword*5
Gambler's Earrings*5
Kanten Senmyou Blessing*5
Sweet Madame*5
Abyssal Summons*5
Fatui Conspiracy*5
Timmie*5
"""
)
main.match.set_deck([deck, deck])
main.match.config.max_same_card_number = 30
main.match.config.history_level = 10
main.match.config.check_deck_restriction = False
main.match.config.initial_hand_size = 20
main.match.config.max_hand_size = 30
main.match.config.card_number = None
assert main.match.start()[0]
main.match.step()
while main.match.round_number < 100 and not main.match.is_game_end():
if main.match.need_respond(0):
current_agent = agent_0
elif main.match.need_respond(1):
current_agent = agent_1
else:
raise RuntimeError("no agent need to respond")
resp = current_agent.generate_response(main.match)
assert resp is not None
main.match.respond(resp)
main.match.step()
main.match.get_history_json(filename="logs.txt")
print("game end, save to logs.txt")