def roquegrande(cor): global tabuleiro if cor==0: tabuleiro[7][2]='R' tabuleiro[7][4]='°' tabuleiro[7][3]='T' tabuleiro[7][0]='°' if cor==1: tabuleiro[0][2]='r' tabuleiro[0][4]='°' tabuleiro[0][3]='t' tabuleiro[0][0]='°' desenha(tabuleiro) def roquepequeno(cor): global tabuleiro if cor==0: tabuleiro[7][6]='R' tabuleiro[7][4]='°' tabuleiro[7][5]='T' tabuleiro[7][7]='°' if cor==1: tabuleiro[0][6]='r' tabuleiro[0][4]='°' tabuleiro[0][5]='t' tabuleiro[0][7]='°' desenha(tabuleiro) def pegacoluna(letra): x = { 'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7 } return x.get(letra) def mover(mov): global tabuleiro y1=pegacoluna(mov[0]) x1=7-(int(mov[1])-1) y2=pegacoluna(mov[3]) x2=7-(int(mov[4])-1) tabuleiro[x2][y2]=tabuleiro[x1][y1] tabuleiro[x1][y1]="°" print x1,y1,x2,y2 desenha(tabuleiro) def desenha(tabuleiro): a='' nro=0 for x in tabuleiro: a=str(nro) + " " rr=0 for z in x: if (rr-nro)%2==0: if z=="°": z="·" a=a + " " + z rr=rr+1 nro=nro+1 print a def movimento(mov, cor): mais="" demais="" tipo="" if mov=="o-o" : #roque pequeno pass tipo = "roque pequeno" roquepequeno(cor) if mov=="o-o-o" : #roque grande pass tipo = "roque grande" roquegrande(cor) if mov[2:3]=='-': #movimento normal tipo= "movimento normal" if mov[2:3]=='x': tipo = "captura de peça" if mov[5:6]=="+": mais=" com cheque " if mov[6:7]=="+": demais="mate" if mov[2]<>"o": mover(mov) return tipo + mais + demais tabuleiro=[] tabuleiro.append(['t','c','b','d','r','b','c','t']) tabuleiro.append(['p','p','p','p','p','p','p','p']) tabuleiro.append(['°','°','°','°','°','°','°','°']) tabuleiro.append(['°','°','°','°','°','°','°','°']) tabuleiro.append(['°','°','°','°','°','°','°','°']) tabuleiro.append(['°','°','°','°','°','°','°','°']) tabuleiro.append(['P','P','P','P','P','P','P','P']) tabuleiro.append(['T','C','B','D','R','B','C','T']) import sys import os arquivo=sys.argv[1] arq=open(arquivo,"ro") for linha in arq.readlines(): if linha[0]<>";" and len(linha)>4: separ=linha.split(".") # print separ[0] + " ||| " + separ[1] # for d in separ: # print d nlance=separ[0] lance=separ[1] # print lance jogadas=lance.split("\n")[0].split(" ") # print len(jogadas) branca=jogadas[1] os.system('clear') print "branca " + branca + " " +movimento(branca,0) raw_input() if len(jogadas)>2: preta=jogadas[2] os.system('clear') print "preta " + preta + " " +movimento(preta ,1) else: preta="" raw_input()