import sys
from convertToFEN import convertToFEN
from boardInfo import BoardInfo

split = sys.argv[1]

inSrcFile = open(split + ".che-eng.0.che")
outSrcFile = open(split + ".che-eng.0attack.che", "w")

inTgtFile = open(split + ".che-eng.0.en")
outTgtFile = open(split + ".che-eng.0attack.en", "w")

for line in inTgtFile:
    outTgtFile.write(line)

boardInfoObj = BoardInfo()
for line in inSrcFile:
    words = line.split()
    print words
    #outSrcFile.write(line[index+6:])
    #print words
    EOPIndex = words.index("<EOP>")
    EOCIndex = words.index("<EOC>")
    currentBoard = words[:EOCIndex]
    previousBoard = words[EOCIndex + 1:EOPIndex]
    playerToMove = words[EOPIndex + 1]
    playerToMoveNext = boardInfoObj.complement(playerToMove)
    #print playerToMove
    squareToMove = words[EOPIndex + 4]
    #print squareToMove
    squareToMoveTo = words[EOPIndex + 5]