gostyle: the basic library, intitial commit.
[gostyle.git] / utils / colors.py
blob4e4546ebb252375abccdffb0959e02036d2561d4
1 from collections import namedtuple
3 PLAYER_COLOR_WHITE = 'W'
4 PLAYER_COLOR_BLACK = 'B'
6 PLAYER_COLORS = ( PLAYER_COLOR_BLACK, PLAYER_COLOR_WHITE )
8 class BlackWhite(namedtuple('BlackWhite', 'black white')):
9 def map_both(self, f):
10 return BlackWhite(*map( f, self ))
12 def map_pathway(self, func_list):
13 bw = self
14 for f in func_list:
15 bw = bw.map_both(f)
16 return bw
18 def the_other_color(color):
19 if color == PLAYER_COLOR_BLACK:
20 return PLAYER_COLOR_WHITE
21 return PLAYER_COLOR_BLACK