#! /usr/bin/python # Polas: LOAPS simple player v0.1 (25 lines of code), mjs, 27-Oct-2005 import sys from string import * from random import choice def coord(p): return '%s%u' % ( 'abcdefg'[p[0]], p[1]+1 ) squares = [(a,b) for a in range(7) for b in range(7)] data = open(sys.argv[1]).readlines() me, turn = [eval(z) for z in split(data[0])] other = (1,2)[me==1] board = dict([ ((x,y),int(data[9-y].replace('.','0')[x])) for x,y in squares ]) options = [] for x,y in squares : if board.get((x,y)) != me: continue for dx,dy in [(1,0),(1,1),(0,1),(-1,1)]: num = len([1 for m in range(-6,7) if board.get((x+m*dx,y+m*dy)) in (1,2)]) for ax,ay in [(dx,dy),(-dx,-dy)]: good = 1 for step in range(1,num): if board.get((x+ax*step,y+ay*step)) in (other,None): good = 0 value = board.get((x+ax*num,y+ay*num)) if good and value not in (me,None): options.append( [value, (x,y), (x+ax*num,y+ay*num)] ) if options: value,start,fin = choice( options ) print coord(start), coord(fin) else: print 'I resign!'