445,918 Members | 2,258 Online
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

# tictactoe

 P: n/a I have come across this solution to a tic tac toe game. It basically checks who won the game: Is there a better more efficient way of testing if the tic tac toe has been won/lost or is over? Thanks in advance, ========================== function User_Won : boolean if (takenx (1) = true and takenx (2) = true and takenx (3) = true) and (takeny (1) = 1 and takeny (2) = 1 and takeny (3) = 1) or (takenx (4) = true and takenx (5) = true and takenx (6) = true) and (takeny (4) = 1 and takeny (5) = 1 and takeny (6) = 1) or (takenx (7) = true and takenx (8) = true and takenx (9) = true) and (takeny (7) = 1 and takeny (8) = 1 and takeny (9) = 1) or (takenx (1) = true and takenx (5) = true and takenx (9) = true) and (takeny (1) = 1 and takeny (5) = 1 and takeny (9) = 1) or (takenx (7) = true and takenx (5) = true and takenx (3) = true) and (takeny (7) = 1 and takeny (5) = 1 and takeny (3) = 1) or (takenx (1) = true and takenx (4) = true and takenx (7) = true) and (takeny (1) = 1 and takeny (4) = 1 and takeny (7) = 1) or (takenx (2) = true and takenx (5) = true and takenx (8) = true) and (takeny (2) = 1 and takeny (5) = 1 and takeny (8) = 1) or (takenx (3) = true and takenx (6) = true and takenx (9) = true) and (takeny (3) = 1 and takeny (6) = 1 and takeny (9) = 1) then who_won_game := "player 1" end if end User_Won function Computer_Won : boolean if (takenx (1) = true and takenx (2) = true and takenx (3) = true) and (takeny (1) = 2 and takeny (2) = 2 and takeny (3) = 2) or (takenx (4) = true and takenx (5) = true and takenx (6) = true) and (takeny (4) = 2 and takeny (5) = 2 and takeny (6) = 2) or (takenx (7) = true and takenx (8) = true and takenx (9) = true) and (takeny (7) = 2 and takeny (8) = 2 and takeny (9) = 2) or (takenx (1) = true and takenx (5) = true and takenx (9) = true) and (takeny (1) = 2 and takeny (5) = 2 and takeny (9) = 2) or (takenx (7) = true and takenx (5) = true and takenx (3) = true) and (takeny (7) = 2 and takeny (5) = 2 and takeny (3) = 2) or (takenx (1) = true and takenx (4) = true and takenx (7) = true) and (takeny (1) = 2 and takeny (4) = 2 and takeny (7) = 2) or (takenx (2) = true and takenx (5) = true and takenx (8) = true) and (takeny (2) = 2 and takeny (5) = 2 and takeny (8) = 2) or (takenx (3) = true and takenx (6) = true and takenx (9) = true) and (takeny (3) = 2 and takeny (6) = 2 and takeny (9) = 2) then who_won_game := "computer" end if end Computer_Won ================================================= Jul 23 '05 #1