#!/usr/bin/python

import gtp
import ishi
import goban

def main():
	boardsize = 7
	komi=6.5
	handicap=0
	player = [0,0]
	player[ishi.black] = gtp.gtp("gnugo --mode gtp",boardsize,0)
	player[ishi.white] = gtp.gtp("gnugo --mode gtp",boardsize,0)
	board = goban.board(boardsize,handicap)
	print board
	print
	passcount = 0
	while 1:
		for state in [ishi.black,ishi.white]:
			move = player[state].get_input(state,board)
			print 'got move',move,'from',ishi.description(state)
			if move == 'PASS':
				passcount += 1
			else:
				passcount = 0
			player[ishi.invert(state)].feed_move(state,move)
			if move != 'PASS':
				board.move(move,state)
			print board
			print
			if passcount == 2:
				break
		if passcount == 2:
			break
	for state in [ishi.black,ishi.white]:
		print ishi.description(state),'estimates',\
			player[state].get_result()

main()