def xgid2gnubg_Festival2009QuizQ02_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-bB-BBC-B---bBA--bbdc---A-:0:0:1:35:0:0:3:0:8') gnubgid.decode(from_gnubgid, 'cG+DATBmO4MFIA','cIkVAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def preparation_test(self): from_gnubgid1 = BoardEditor() from_gnubgid2 = BoardEditor() gnubgid.decode(from_gnubgid1, 'sM/BATCwZ/ABMA','cAmgAEAAGAAA') gnubgid.decode(from_gnubgid2, 'sM/BATCwZ/ABMA','cAmgAEAAGAAA') print from_gnubgid1 == from_gnubgid2 self.assertEqual(from_gnubgid1, from_gnubgid2)
def xgid2gnubg_jbl_LateHitOriginal_test(self): ''' from http://www.backgammon.gr.jp/forum/viewtopic.php?f=2&t=1072 怪しいキューブ ''' from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-bCCa-B-a------a---bbbbb-A:1:-1:-1:00:0:0:3:0:10') gnubgid.decode(from_gnubgid, '7hgAANm2ISDEAA','AQEAAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_jbl_LateHitRef3_test(self): ''' from http://www.backgammon.gr.jp/forum/viewtopic.php?f=2&t=1072 怪しいキューブ ''' from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-DCaa--------------cccbbB-:1:-1:-1:00:0:0:3:0:10') gnubgid.decode(from_gnubgid, '7wAAwNjuDgAoAA','AQEAAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_bgonline_25ptMatchVMoney_test(self): ''' from http://www.bgonline.org/forums/webbbs_config.pl?read=64989 Surprising difference between 25-away/25-away and money ''' from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-BAC-----------------abab-:1:1:1:00:0:0:0:0:10') gnubgid.decode(from_gnubgid, 'awEAgHUAAAAAAA','UQkAAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def __init__(self, gnubgid=None, board=None): if board is not None: assert isinstance(board, Board) self.board = BoardEditor(board) elif gnubgid is not None: self.board = BoardEditor() pid, mid = gnubgid.split(':') decode(self.board, pid, mid) else: self.board = BoardEditor() self.action = None
def xgid2gnubg_bgonline_HowToTrapAnAnchor_test(self): ''' from How to trap an anchor gnuid http://www.bgonline.org/forums/webbbs_config.pl?read=65226 xgid http://www.bgonline.org/forums/webbbs_config.pl?read=65334 ''' from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-----bBBBCBB----A--A---cc-:1:1:1:12:0:0:0:0:10') gnubgid.decode(from_gnubgid, 'dwAABsC22yACAA','UYkIAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def run(self): self.board.rolled = random.randint(1, 6), random.randint(1, 6) self.result.inc_roll() mf = MoveFactory(self.board) if mf.is_leagal_to_pickup_dice(): if self.board.is_doubles(): self.result.add_timing(self.board.rolled[0] * 4) else: self.result.add_timing(self.board.rolled[0] + self.board.rolled[1]) return True #print mf pid, mid = "2LYBAAAAAAAAAA:cAkgAAAAAAAA".split(':') decode(self.board, pid, mid) self.board.position = b.position[0], CLEAN return False
def make_finalStatePosition(gnubgid): pid, mid = gnubgid.split(':') b = BoardEditor() decode(b, pid, mid) b.position = b.position[0], CLEAN return HashableBoard.freeze(b)
def xgid2gnubg_Festival2009QuizQ08_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '--D-CaBbB---BBa---bbbc-b--:0:0:1:23:1:0:0:3:8') gnubgid.decode(from_gnubgid, '5rYhYAKeM8MGAA','cAltAAAACAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_itikawa_OhsakaOpenQuiz2010_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '--BBCbB---BBd------c-Bbca-:0:0:1:33:0:0:3:0:10') gnubgid.decode(from_gnubgid, '3TjgAQO2M2wABg','cIkNAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def NewBoard(gnubgid): pid, mid = gnubgid.split(':') b = BoardEditor() decode(b, pid, mid) return HashableBoard.freeze(b)
def xgid2gnubg_Festival2009QuizQ03_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '---a--EBBBB-b----ccd--b-B-:0:0:1:12:1:0:0:3:8') gnubgid.decode(from_gnubgid, 'jHcHAwjg2zYAMA','cIloAAAACAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_Festival2009QuizQ01_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-aBa--DaB---cE---d-e---AA-:0:0:1:56:3:1:0:5:8') gnubgid.decode(from_gnubgid, '4PPgICSGZ/ABKA','cIm6ABAAGAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_0_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-B-BAaCBC-----a-----cdBcc-:1:-1:1:66:1:4:0:5:10') gnubgid.decode(from_gnubgid, 'd96BAAKz3A4ADA','QQm7AEAACAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_Festival2009QuizQ04_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-a---BDaCb---A--b-bcbbCB--:1:1:1:55:0:2:0:5:8') gnubgid.decode(from_gnubgid, '2G4GTCCw5yCAGw','UYm2ACAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_Festival2009QuizQ10_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-B-bABEAA--Ba---accc--b-A-:1:-1:1:43:0:0:3:0:8') gnubgid.decode(from_gnubgid, 'jLsLAQyjfcUAIA','QQkOAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_1_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-b---BD-B---cE---c-eb---B-:0:0:1:00:3:4:0:5:10') gnubgid.decode(from_gnubgid, 'sM/BATCwZ/ABMA','cAmgAEAAGAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_itikawa_DenmarkVWorldAtNordic2010_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-Ba-CBBCB----------Abc-ed-:1:1:1:00:7:1:0:15:16') gnubgid.decode(from_gnubgid, '73MDABDjthsAAQ','UQngARAAOAAA') self.assertEqual(from_gnubgid, from_xgid)
def app(environ, start_response): from StringIO import StringIO stdout = StringIO() q = cgi.parse_qs(environ['QUERY_STRING']) EMPTY = ('',) new = q.get('new', EMPTY)[0] gnubgid = q.get('gnubgid', EMPTY)[0] move = q.get('move', EMPTY)[0] cube = q.get('cube', EMPTY)[0] pickupdice = q.get('pickupdice', EMPTY)[0] dice= q.get('dice', EMPTY)[0] print >>sys.stderr, 'got: new=%s, gnubgid=%s, move=%s, cube=%s pickupdice=%s dice=%s'%(new, gnubgid, move, cube, pickupdice, dice) if new: print 'setting initial position for game with', new to_action, score = new.split(':') score, length = score.split('/') print score, length X_score, O_score = score.split('-') print X_score, O_score a = int(to_action) b = BoardEditor( on_action=a, on_inner_action=a, game_state = ON_GOING, match_length=int(length), score=(int(X_score), int(O_score)), crawford=('*' in score), ) p, m = encode(b) else : pid, mid = gnubgid.split(':') print >>sys.stderr, pid, mid assert len(pid) == 14 #01234567890123 #sGfwgAPbuIEDIA assert len(mid) == 12 #01234567890123 #cIkqAAAAAAAA b = BoardEditor() decode(b, pid, mid) print b if b.is_leagal_to_move(b.on_action): #ugh! can be empty, DANCE ! assert move moves = move.split(' ') mf = MoveFactory(b) for mv in moves: print >>sys.stderr, mv if mv: m = moveRegExp.search(mv) if not m: break d = m.groupdict() print d n = int(d['multi'] or '1') while n > 0: print d['src'], d['dest'] found = mf.guess_your_multiple_pms(move_pton(d['src']), move_pton(d['dest'])) assert found #assert not d['hitting'] or n!=1 or found.is_hitting mf.add(found) #mf.append(found) n = n -1; assert mf.is_leagal_to_pickup_dice() if pickupdice: print 'pickupdice', pickupdice mf.pickupdice() print mf.board p, m = encode(mf.board) elif b.is_leagal_to_roll(b.on_action): if cube == 'no double' and dice: b.rolled = (int(dice[0]), int(dice[1])) elif 'Double' in cube: pass print b p, m = encode(b) else: assert False pass #else case of if new: assert len(p) == 14 assert len(m) == 12 value = {"status": True, "gnubgid": "%s:%s"%(p, m)} j = '%s(%s);'%(q['callback'][0], simplejson.dumps(value)) print >>stdout, j print >>sys.stderr, 'sending:' ,j start_response("200 OK", [('Content-Type','text/javascript')]) return [stdout.getvalue()]
def xgid2gnubg_Festival2009QuizQ07_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-A--b-D-D--BeB---c-e-AA---:0:0:1:66:0:0:3:0:8') gnubgid.decode(from_gnubgid, '4HPwAQbB85gBCg','cAkbAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_Festival2009QuizQ06_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-B-BCaC-BB--b-ab-a-c-bb-aA:0:0:1:21:4:2:1:5:10') gnubgid.decode(from_gnubgid, '2ZwsAwKzczYAQA','8AmlACAAIAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_Festival2009QuizQ05_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '--BBCBC-a-----A----cBce-c-:0:0:1:32:0:0:3:0:8') gnubgid.decode(from_gnubgid, '5zsHQAC22wECAw','cIkJAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_Festival2009QuizQ09_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '-aa-B-DBB--AdB--ab-d-b--B-:0:0:1:51:0:0:3:0:10') gnubgid.decode(from_gnubgid, 'mGfhASiYt5EBMA', 'cIkGAAAAAAAA') self.assertEqual(from_gnubgid, from_xgid)
def xgid2gnubg_itikawa_SecondWorstRoll_test(self): from_xgid = BoardEditor() from_gnubgid = BoardEditor() xgid.decode(from_xgid, '---CBbB-B----E-a--bcbcb-A-:1:1:1:21:0:1:0:5:10') gnubgid.decode(from_gnubgid, '7HYjAAPczOADIA','UQmlABAAAAAA') self.assertEqual(from_gnubgid, from_xgid)