# -*- coding: utf-8 -*-
"""
Created on Thu Oct 14 11:56:08 2021

@author: JASSIMRAN
"""

import chess
def move():
    moves=[]
    gamestate=[]
    turn = 0
    board = chess.Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')#initialize the board
    print(board)
    while board.legal_moves != 0:# the game will end if there's no legal move for one player
        turn = turn +1
        print('Turn number {}'.format(turn))
        #b = board.piece_map()   #where the piece is<a dictionary>
        if turn%2 != 0:
            print('white turn')
        else:
            print('black turn')
        a = board.legal_moves

        print(a)
        i = input('your move: ')
        j=0
        if turn%2 != 0:
            moves.append(i)
        else:
            moves.append(i)
        move = chess.Move.from_uci(str(board.parse_san(i)))
        board.push(move)
        print(board)
        
    k=0
    for j in range(turn):
          if j%2 == 0:
              gamestate[k]=chess.Board(str(k+1)+moves[j]+moves[j+1])
              k+=1
    
    return(i, gamestate)


def main():
    n = 1
    while n:
        turn, gs = move()
        if turn%2 !=0:
            print('black win')
        else:
            print('white win')
        n = 0
        new = input('type 1 if you want to start a new game')
        if new == 1:
            n = 1

main()

# ['1.d4Nf6' ]