In GDScript you have randi() and randf(). Every time your player moves, simply use one of those methods and define your rule to start the battle sequence. For instance, if you want to set a chance of fight to 1/10, you can write:
if (randi()%10)==0:
start_fight()