                ($td.data('y')),
                color)
 
+clean_board = ->
+  $('.go-board td').each (i, cell)->
+    $(cell).empty()
+
+update_ui_board = (board)->
+  clean_board()
+  all_fields_do board, (x, y, color)->
+    if (color == BLACK) || (color == WHITE)
+      set_move_on_ui_board create_stone(x, y, color)
+
 $ ->
   current_color = BLACK
   board_size = 9

  move = mcts(board, 100)
  play_stone(move, board)
  set_move_on_ui_board(move)
  print_board board

set_move_on_ui_board = (move)->
  $target_cell = $("table.go-board tr:nth-child(#{move.y + 1}) td:nth-child(#{move.x + 1})")

  $('.go-board td').click ->
    if $(this).is(':empty') && current_color == BLACK
        move = create_move_from_ui_move($(this), current_color)
        play_stone(move, board)
        update_ui_board(board)
        current_color = WHITE
        start_mcts(board)
        update_ui_board(board)
        current_color = BLACK

