Hello, i am currently making a tic-tac-toe game. i finished the mode playing with a human now i need to make a mode playing with a computer. Any ideas how i can make a code that randomlys select a button that isn’t disabled or already picked? thanks.
One idea is to have a data source set up with three rows like this:
X – O
– – O
X – –
Loop through the rows and find available blanks (“–”). Put those in a list of objects structured like this:
row: #
col: #
player: "–"
You can then choose a random item from that new list and place an X or O at the row/col position.
1 Like
This is good! I’ll let you know when i will find a code for this.
So i tried something but i don’t know how i could set like ‘‘case 9 which is a button’’ to a row.
Any updates?
Here the link, i could really use some help and sorry if it looks messy.