diff --git a/tools/board2Bitboard.py b/tools/board2Bitboard.py
new file mode 100755
index 0000000000000000000000000000000000000000..3056ea3a098b3a5846ea2dcad184f69941084670
--- /dev/null
+++ b/tools/board2Bitboard.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+#-*- encoding: utf-8 -*-
+
+def board2Bitboard(board):
+	"""
+	Convert a real board to its bitboard representation.
+	
+	:param board: a sequence of 1, 2 and 3 that tells how many fish are in every tile. A character that isn't 1, 2 or 3 is considered water. Newlines, pipes and spaces are ignored.
+	:type board: str
+	"""
+	board = board.replace("\n", "")
+	board = board.replace("|", "")
+	board = board.replace(" ", "")
+	print(board)
+	
+	if len(board) != 60:
+		print("Warning: board is not 60 char long!")
+	ones = 0
+	twos = 0
+	threes = 0
+	for c in board:
+		if c == '1':
+			ones |= 1
+		elif c == '2':
+			twos |= 1
+		elif c == '3':
+			threes |= 1
+		ones = ones << 1
+		twos = twos << 1
+		threes = threes << 1
+	ones = ones >> 1
+	twos = twos >> 1
+	threes = threes >> 1
+	return (ones, twos, threes)
+	
+if __name__ == "__main__":
+	try:
+		while True:
+			board = input("Enter board: ")
+			ones, twos, threes = board2Bitboard(board)
+			print("one_fish: {}\ntwo_fish: {}\nthree_fish: {}".format(ones, twos, threes))
+	except KeyboardInterrupt:
+		print("\nMay the fish be with you.")
diff --git a/tools/gui.py b/tools/gui.py
index 9066a562e1f0ac0c7b62cc20a411ff2a56679d93..7be949bcae18614eb4f823566da4c93edfc12b56 100755
--- a/tools/gui.py
+++ b/tools/gui.py
@@ -13,24 +13,22 @@ if __name__ == "__main__":
 			#READ
 			readloop = True
 			comments = []
-			json_data = []
+			json_data = ""
 			brackets_count = 0
 			while readloop:
 				line = program.stdout.readline()
-				#print(line)
-				if line.startswith("{"): #in json or entering json
-					brackets_count += 1
-				if brackets_count > 0: #We are in the middle of json data
-					json_data.append(line)
+				print(line)
+				line = line.replace("Red move: ", "")
+				line = line.replace("Blue move: ", "")
+				if line.startswith("{"): #Reading json
+					json_data = line
 				else:
 					comments.append(line)
-				if line.startswith("}"):
-					brackets_count -= 1
 				if line == "\n":
 					readloop = False
 			#PRINT STATE
 			print("Comments: {}".format(''.join(comments)))
-			state = json.loads(''.join(json_data))
+			state = json.loads(json_data)
 			drawState.drawBitboard(state["bitboards"]["onefish"],state["bitboards"]["twofish"],state["bitboards"]["threefish"])
 			print("Red penguins (Red score: {}, Total moves: {} [0..{}])".format(state["score"]["red"], state["nb_moves"]["red"], state["nb_moves"]["red"]-1))
 			for i in range(4):
@@ -45,6 +43,8 @@ if __name__ == "__main__":
 				move = input("Enter Blue move: ")
 			program.stdin.write(move+"\n")
 			program.stdin.flush()
+	except BrokenPipeError:
+		print("Game end")
 	except KeyboardInterrupt:
 		print("\nMay the fish be with you.")
 	finally: