Hi.
I’m new to this Lua thing, and i’m having some trouble.
I’ve programmed before (in Java), so usually i know what i am doing.
This piece of code is somehow not working. I have no idea why.
It’s a Tic tac toe AI, that should choose a random place to make it’s turn.
The first if-statement works, but after “playersTurn = true; computersTurn = false” nothing happens.
Please help.
if computersTurn == true and row1[1] == 0 and row1[2] == 0 and row1[3] == 0 and row2[1] == 0 and row2[2] == 1 and row2[3] == 0 and row3[1] == 0 and row3[2] == 0 and row3[3] == 0 then playersTurn = true; computersTurn = false randomPlacement = math.random(1, 8) if randomplacement == 1 then row1[1] = 2 end if randomplacement == 2 then row1[2] = 2 end if randomplacement == 3 then row1[3] = 2 end if randomplacement == 4 then row2[1] = 2 end if randomplacement == 5 then row2[3] = 2 end if randomplacement == 6 then row3[1] = 2 end if randomplacement == 7 then row3[2] = 2 end if randomplacement == 8 then row3[3] = 2 end end