function [root, final_node] = runMCTS(x0, dgrid, grid_end, acc_max, dt_max, position_adjacency_factor, state_knots)
    


lat = BuildLattice(x0, dgrid, grid_end, acc_max, dt_max, position_adjacency_factor, state_knots);

root = MCTSNode(MCTSNode.empty(0), [0, 0], [x0; x0], 0, lat.state_knots_index(1,:), lat);

do_stop = false;
cnt = 1;
while ~do_stop && cnt < 1000
    [~, final_node] = root.selection();
    if ~isempty(final_node)
        do_stop = true;
    end
    
    cnt = cnt+1;
end

figure
hold on
ax = gca;
lat.plotVertices(ax);
root.plotTree(ax);
final_node.plotBranch(ax);