public void gameMainLoop(GameInstance gameInstance) throws InterruptedException{
    
    GameBoard gameBoard = gameInstance.getGameBoard();

    
    HashMap<GamePieceName, ArrayList<BoardLocation>>  moveSet;
    Move nextMove;
    Player player;
    while (!gameInstance.isGameOver()){
      
      for (PlayerName playerName: new PlayerName[]{PlayerName.WHITE, PlayerName.BLACK} ) {
        
        player = gameInstance.getPlayer(playerName);
        System.out.println(player.getColor() + "'s turn");

        moveSet = LegalMoveCalculator.getLegalMovesForPlayer(gameBoard, player.getColor());
        if (moveSet.size()==0){
          gameInstance.setGameOver(true);
          
          System.out.println( playerName+ " has no legal moves");
          boolean checkmate;
          if(LegalMoveCalculator.isKingInCheck(gameBoard, playerName)==null){
            checkmate = false;
          } else {
            checkmate = true;
          }
          System.out.println("Game over " + (checkmate? "Checkmate" : "Stalemate"));
          break;
        }
        nextMove = player.takeTurn(moveSet, gameBoard);
        gameBoard.makeMove(nextMove);
        gameBoard.verifyBoardAndIndex();
        gameBoard.updateMoveHistory(nextMove);
        Thread.sleep(1000);
        GameGuiUtils.asciiOutput(gameBoard);
        GameGuiUtils.printMoveHistory(gameBoard);
      }
      
    } 
  }