Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with Tic-Tac-Toe Script
- mrrobotrobot
-
Scratcher
2 posts
Help with Tic-Tac-Toe Script
I am making a tic-tac-toe game, where the board is an irregular shape, and a player starts as an O and moves around the boards, pushing around Xs and Os, forming a line of three Os without making a line of Xs.
I need help detecting a line of 3 either horizontally or vertically, not diagonally. By the way, the player will be part of the line of Os if that helps.
I haven't tried any code, although I would not like to use lists as there will be multiple levels, each with different maps.
Thank you in advance!
I need help detecting a line of 3 either horizontally or vertically, not diagonally. By the way, the player will be part of the line of Os if that helps.
I haven't tried any code, although I would not like to use lists as there will be multiple levels, each with different maps.
Thank you in advance!
Last edited by mrrobotrobot (Nov. 2, 2025 23:40:48)
- Sebatho
-
Scratcher
74 posts
Help with Tic-Tac-Toe Script
Are you recreating the Google Doodle game Tic-Tac-Go? I think lists are the best way to do this as you can have a different list for each level so each list will have the total amount of tiles that the level has (also keep a long string variable line of each item because the items in a list will override and the original positions will be lost so have a script that adds each character in the starting variable so that it can then add that to the list so the starting position is always the same and never gets overridden), including ones that can't be accessed if they're blocked by a wall as long as there is a tile on that row/column so that the amount of items in each list will be much easier to work with. Each item will be an O, X, or empty. You update the positions of each item after each move starting from the top left, going right, and then going down one space and all the way to the left after getting to the end of a row to record the positions, which will require a finished movement and push system to do that and to check if there's a line of Os or Xs, I made a system for you that does this: https://scratch.mit.edu/projects/1237044383
Full explanation for how the system works is in the description and inside the project with comments. I hope this is what you wanted! ^^
Full explanation for how the system works is in the description and inside the project with comments. I hope this is what you wanted! ^^
- mrrobotrobot
-
Scratcher
2 posts
Help with Tic-Tac-Toe Script
Are you recreating the Google Doodle game Tic-Tac-Go?Yes!
Also, Thank you so much!
Last edited by mrrobotrobot (Nov. 4, 2025 01:36:23)
- Discussion Forums
- » Help with Scripts
-
» Help with Tic-Tac-Toe Script

