-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (46 loc) · 2.13 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
import os, sys
import argparse
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
import battle_system
import gui
from player import *
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Pokémon combat system (1st gen) re-implementation using MiniMax-type algorithms.\
\nAuthor: nebuchadneZZar01 (Michele Ferro)\
\nGitHub: https://github.com/nebuchadneZZar01/PokeMMon\
\nAll credits of the material used (characters, sounds, images and ideas) belong to The Pokémon Company, Nintendo, Game Freak and Creatures Inc.',\
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--ai', type=str, help='artificial intelligence algorithm used [random/minimax/alphabeta/expectimax] (default: minimax)', default='minimax')
parser.add_argument('--depth', type=int, help='maximum depth of the nodes to visit in game\'s tree (default: 7)', default='7')
parser.add_argument('--s', type=str, help='sound [Y/n] (default: yes)', default='y')
args = parser.parse_args()
if args.s.lower() == 'y':
sound = True
else:
sound = False
player = Trainer()
if args.ai == 'random':
ai = RandomAI()
if args.ai == 'minimax':
ai = MinimaxAI(player, args.depth)
elif args.ai == 'alphabeta':
ai = MMAlphaBetaAI(player, args.depth)
elif args.ai == 'expectimax':
ai = ExpectiMaxAI(player, args.depth)
ai.get_team()
bs = battle_system.TurnBattleSystem(player, ai)
gui.pygame.display.set_caption('PokéMMon')
icon = gui.pygame.image.load(os.path.join('assets/icon.svg'))
gui.pygame.display.set_icon(icon)
gui.pygame.init()
game_gui = gui.GameWindow(bs, sound)
while True:
clock = gui.pygame.time.Clock()
clock.tick(60)
event = gui.pygame.event.poll()
if event.type == gui.pygame.QUIT:
gui.pygame.display.quit()
gui.pygame.quit()
break
game_gui.draw()
bs.handle_turns()