-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconsole_output.py
82 lines (58 loc) · 1.56 KB
/
console_output.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
from generals_io_client.generals import FOG,EMPTY,OBSTACLE,MOUNTAIN
def clear():
os.system('cls' if os.name=='nt' else 'clear')
def game_output(state, ranks=None):
#terrain /tiles
terrain=state['tile_grid']
tiles=state['tile_grid']
armies=state['army_grid']
cities=state['cities']
# basic info
rows=state['rows']
cols=state['cols']
turn=state['turn']
# player
pi = state['player_index']
generals=state['generals']
usernames=state['usernames']
teams=state['teams']
stars=state['stars']
#scores
lands=state['lands']
soldiers=state['armies']
alives=state['alives']
#others
replay_url=state['replay_url']
clear()
print 'Turn', turn
title='\t'
for x in range(0,len(tiles[0])):
title+='%s\t' %x
print title
for y in range(0,len(tiles)):
this_row='%s\t' %y
for x in range(0, len(tiles[y])):
tile=tiles[y][x]
l=''
if tile==FOG:
l='F'
elif tile==EMPTY:
l=' '
elif tile==MOUNTAIN:
l='M'
elif tile==OBSTACLE:
l='O'
elif (y,x) in cities:
l='C'
else:
l='P%s' %tile
this_row+='%s,' %l
number = armies[y][x]
this_row+='%s,' %number
# for pos in ranks:
# if pos==(y,x):
# this_row+='%s,' %ranks[pos]
this_row+='\t'
print this_row+'\t'
print ''