:Lbl N
:Disp "NUMBER OF BALLS?"
:Input N
:If N≤0:Then
:Goto N
:End
:
:For(I,1,N,1)
:randInt(1,8)→L1(I)
:randInt(1,16)→L2(I)
:If randInt(0,1)=0:Then
:1→L3(I)
:Else
:-1→L3(I)
:End
:If randInt(0,1)=0:Then
:1→L4(I)
:Else
:-1→L4(I)
:End
:End
:
:ClrHome
:For(I,1,N,1)
:Output(L1(I),L2(I),"O")
:End
:
:Repeat 0
:For(I,1,N,1)
:L1(I)→A
:L2(I)→B
:L3(I)+L1(I)→L1(I)
:If L1(I)=0:Then
:2→L1(I)
:1→L3(I)
:End
:If L1(I)=9:Then
:7→L1(I)
:-1→L3(I)
:End
:L4(I)+L2(I)→L2(I)
:If L2(I)=0:Then
:2→L2(I)
:1→L4(I)
:End
:If L2(I)=17:Then
:15→L2(I)
:-1→L4(I)
:End
:Output(A,B," "
:Output(L1(I),L2(I),"O")
:End
:End