Let M be a finite positive integer. It's exact value is not known.
Suppose we have three classes of automaton, all of which accept a bit stream as input, produce a bit stream as output (one bit per input bit), and have a non-observable state, S, that is an integer coordinate on an infinite bidirectional 1D line:
- knightbots start with S = M. Whenever a
1
bit is inputted, knights move 2 units to the right (i.e. S is incremented by 2). Whenever a0
bit is inputted, knights move 1 unit to the left (i.e. S is decremented by 1). - knavebots start with S = -M. Whenever a
1
bit is inputted, knaves move 1 unit to the right. Whenever a0
bit is inputted, knaves move 2 units to the left. - jokerbots start randomly at either S = M or S = -M. On cromulent days, jokers move 1 unit right on a
1
input and 1 unit left on a0
input, but on non-cromulent days, jokers move 1 unit left on a1
input and 1 unit right on a0
input. You have no idea whether or not the current day is cromulent, and there's really no way to find out.
After each input, the automata output either a 1
if they have moved into the state S = 0, or a 0
otherwise.
Simple Problem (for "Correct Answer" Credit)
You are given an automaton that is either a knightbot, a knavebot, or a jokerbot, but you don't know which of the three. The automaton is guaranteed to be in its starting state. You can input bits to the automaton and observe its output, but otherwise you cannot observe its state or inner workings. Also note that you cannot "reset" the automaton.
Your task is to produce an algorithm that is mathematically guaranteed to properly classify the automaton as a knight, knave, or joker using an input sequence of finite length.
Your solution should include a (reasonably) detailed description of your algorithm, as well as a guaranteed (although not necessarily tight) upper bound on required input length as a function of M.
Challenge Problem (for 100 Bonus Rep!)
Instead of the aforementioned jokerbots, consider jesterbots:
- jesterbots start with S start randomly at either S = M or S = -M
- jesterbots have a secondary state, b, which assumes the value of the most-recently-inputted bit. The initial value of b is
0
. - jesterbots have a tertiary state, D, which takes on the values
1
or-1
, and may be treated as a direction. The initial value of D is1
. - on cromulent days, jesterbots move in the direction of D (i.e. increment S by D) iff an input bit matches b (the previous input bit), or else stand still and about face (multiply D by
-1
) - on non-cromulent days, jesterbots move in the direction of D iff an input bit does not match b, or else stand still and about face
- after each input, the jesterbot outputs a
1
if it has moved into the state S = 0, or a0
otherwise
Your task is identical to that for the simple problem, only substituting jester(bot) for joker(bot) in the task description.
I will award 100 bounty rep to the correct, defensible solution to this challenge problem that has the strictest upper input length bound (in terms of $\mathcal{O}\left( M\right)$), or to the earliest solution in the case of a tie.
Good luck automating. :)
M
. You are correct in observing that it is a computer science puzzle, however. ;) $\endgroup$M
? $\endgroup$