first thing i’d do is clean up all the “A”,“B” or “Bob”,“Bill” or “X”,“O” that make this thread hard to follow (or it that just me? :D) so let’s at least define an array of names you can look up by their index (1 or 2, per Lua convention of 1-based array indices):
names = {"A","B"}
next, i’d rigorously define how I’m going to number the first and subsequent turns (because it’ll matter if you’re using modulo, else your sequence might be “out of phase” by one). let’s again adopt Lua’s 1-based convention, so that the first turn is 1, and so on.
so,… you have a “sequence” that is four long, with each subpair of two returning one of two values [1,2] that are essentially “half” (*) of the turn sequence value [1,2,3,4]. reading that back with our “math glasses” on gives: modulo by four, divide by two. (* taking integer result of course AND fixing up all the -1’s and +1’s along the way as required by the 0-based modular math given the 1-based indices elsewhere)
function whose(turn) return math.floor((turn-1)%4/2)+1 end
then (finally) you can do a mock run through a loop of turns to print out player names
for turn = 1,20 do print(names[whose(turn)]) end
that should give you your AABBAABBAABB…, hth