Bots playing a counting game

Python 2, 295 291 290 bytes

from random import*
n=input()
r=range(n)
p=r[:]
b=[1]*n;s='%02d'
def P(l):print'|%s|'%'|'.join(l)
P(s%-~j for j in r)
x=0
while sum(b)>1:i=p.pop(0);g=choice(range(x+1,11)[:3]or[11]);P([2*'x '[b[j]],s%g][j==i]for j in r);x=g%11;b[i]=g<11;p+=[i]*b[i]
print'Bot #%d is the winner'%-~b.index(1)

Try it online!

  • -1 byte, thanks to Kevin Cruijssen

JavaScript (Node.js), 269 245 240 233 232 231 bytes

  • thanks to @Kevin Cruijssen for reducing by 1 byte
N=>{for(S=d=[],D=n=i=0;D<N-1;){for(R=n>8?1:(n>7?2:3)*Math.random()+1|0;R--;)S+="|"+[...Array(N)].map((x,I)=>i^I?d[I]?"xx":"  ":++n>9?n:"0"+n).join`|`+`|
`
for(n>10&&(d[i]=++D,n=0);d[i=++i%N];);}return S+`Bot #${i+1} is the winner`}

Try it online!


C (clang), 288 283 282 266 bytes

f(n){int i,j,p[99]={},m,k,x;for(i=j=k=0;k<n;printf("|%02d",k++));for(puts("|"),m=n;x=i>7?10-i:3,i=x?clock()%x-~i:0,m>1;){for(k=~0;++k<n;printf(p[k]?"|xx":k-j?"|  ":"|%02d",i?i:11));puts("|"),!i&&m--*p[j]++;do j++,j%=n;while(p[j]);}printf("Bot #%d is the winner",j);}

Try it online!

Bots are 0 indexed.

Following will do 1-indexed for+2 bytes

f(n){int i,j,p[99]={},m,k,x;for(i=j=k=0;k<n;printf("|%02d",++k));for(puts("|"),m=n;x=i>7?10-i:3,i=x?clock()%x-~i:0,m>1;){for(k=~0;++k<n;printf(p[k]?"|xx":k-j?"|  ":"|%02d",i?i:11));puts("|"),!i&&m--*p[j]++;do j++,j%=n;while(p[j]);}printf("Bot #%d is the winner",j+1);}