It's just a basic minmax. The main mistake it makes is that if it can find an assured path to getting you it doesn't care how many moves in the future it is (even if it could win this turn).
That said, the audience is 6 year olds so I don't really want it to play perfectly!
Yup, I'm going to build out the reverse play when I find time in the next few weeks hopefully! I'll try to remember to comment here :)
Quite probably you did just run up against a bug in it! I'd have to see the position though.
Great question on the maximal theoretical length. Being pedantic I'd imagine infinite if I just move a knight back and forth and you move a king back and forth. (Though I disallow repeat moves for interests sake)
I mean the maximal length if both players play perfectly.
If the Kings advance in the 1)"b", 2) "d" or "e", 3) "g" column in a synchronized way, they form an horizontal wall of 3 ranks that will trap the Knight at the bottom of the board. This takes 5 * 3 to go from "7" to "2" plus 1 movements to take the Knight, so in 5 * 3 +1 = 16 they should win, and the maximal amount of movements for the Knight is also 16.
This use a little of hand waving, so I may be missing some corner case or brilliant strategy for the Knight. I also may be missing some obvious strategy for the Kings to win earlier. So add a few question marks here and there in the provious paragraph.
> I'm going to build out the reverse play when I find time in the next few weeks hopefully!
That said, the audience is 6 year olds so I don't really want it to play perfectly!