Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Share Worlds (http://www.alice.org/community/forumdisplay.php?f=6)
-   -   Tic-Tac-Toe! (http://www.alice.org/community/showthread.php?t=3548)

GameKid 11-04-2011 03:05 PM

Very nice! I played a few games with my sister.
Maybe someday you could add an AI to play against.
Until then: Four stars.

cacho5230 05-28-2012 01:06 AM

[QUOTE=Dameria;14028]I got the idea from another user about 2 days ago to make a tic-tac-toe game, and I have just now finished it fully! I am very proud of this game I created because as far as I know there are no flaws. This includes no multiple wins, no playing after someone won, and so on. It even surprisingly works on both Alice 2.2 and Alice 2.0!

So here it is. I even have a few ideas for a Tic-Tac-Toe 2.0 (hey that rhymes!), in which more things will be added.

Please tell me what you think about the game, tell me if there is anything I missed, or maybe some ideas for 2.0, thanks!

[b]Download Tic-Tac-Toe 2.0 below for the latest and best version.[/b]
[i]I have taken the first version of Tic-Tac-Toe off because it has been getting more views than version 2.0 just because it is the first in the list. I do not want this to happen, so I have moved the version 1 download to the post where I originally introduced version 2.0, just in case you do want to download it.[/i][/QUOTE]

[B]ESPANISH
Hola, tiene un problema el tic-tac-toe . cuando un jugador gana no se marca en el scoreboard[/B]
----------
[B]ENGLISH
Hello, you have a problem tic-tac-toe. when a player wins is not marked on the scoreboard.
please help[/B]

cedricdosss 11-19-2012 03:31 PM

Tic-Tac-Toe
 
Very nice and well done. I enjoyed it at work now with coworker.
Do you do it for fun?

Dameria 11-19-2012 06:03 PM

No I don't play it very often. I made it mostly as a challenge for myself to see if I could. I am very proud of it though. Thank you for trying it! :)

stylo 11-22-2012 10:22 AM

Very nice game, I'm playing it, if I find errors I'll report here. Thanks.

taeweas 11-30-2015 06:47 PM

tic tac toe
 
2 Attachment(s)
So I used your game as a template, because I did not want to completely just rip you off for my project. I am not fully competent with alice and therefore wanted to dumb it down a little bit as I think my teacher would know if I did. I just do not understand how you determine which players turn it is. :confused::confused::confused: Here are 2 kind of infant projects, one using the text boxes like you did, and the other using colors instead of x's and o's. Where can I go from here? Btw, props on your game, very very cool. Any help is greatly appreciated!

Dameria 11-30-2015 10:06 PM

Hello taeweas and welcome to the forums!

First off, I have to apologize for the way that I programmed this game. As an undergraduate college student about to get his degree in Computer Science, I am wincing as I look back at this programming. It's disgusting code-wise; completely unorganized, inefficient, and non-intuitive. Back when I made this I had little understanding of object oriented code design. Enough of my self-pity though, I'll try to help you understand what I did.

First of all, in my program if you scroll down to the bottom of the Events board you can see that I have an event with the condition "When the world starts, do" followed by the method "scoreboardBackground.setNames". To see this method, you have to maximize the "Scoreboard" object group in the objects window under the Play button. In this folder you will see an object "scoreboardBackground" that you can click on. In the window directly below the objects window you should see the text "scoreboardBackground's details". This is the details window. There should be 3 tabs under this text: properties, methods, and function. Click on "methods" and you will see all of the methods available for this object. I chose to create a method under this object and call it "setNames", you should see it at the top of the methods tab. Press the "edit" box next to the method to open the code.

In the scoreboardBackground.setNames method you can see the code I used to ask the user to set their name using the message boxes when you first run the program. At the very bottom of this method you will see a command to run "world.randomTurn". That randomTurn method is unique in that it is the only global method that I created (for some reason). If you click on the "world" object at the very top of the objects section and click to edit the "randomTurn" method in the world's methods section, you can see the strange code that I created to select the first player's turn. It basically chooses an integer, either 0 or 1 (for some reason I had it generate a 3 or 4, then subtracted by 3??? I'm strange) and assigns that number to the global variable "playerTurn" (found in the "world" object's properties tab). The method now decides that it's O's turn if a 0 is randomly generated or X's turn if a 1 is generated. It then changes the text property of the "turnText" object (found in the object folder "PlayersTurn") to either O or X, whichever "world.playerTurn" is randomly set to. This text is displayed in the gray "Players Turn" square of the world.

If you thought that was the confusing part, you were wrong. If you look at the events, you will see that every clickable square has an event that is triggered when said square is clicked, each calling a different method.[INDENT]In hindsight, I could have made this into a single event with a single global method by creating an object list through the world's properties tab -> create new variable -> Object + checkbox for List, but I didn't learn how to do this until later in my Alice days.[/INDENT]Anyways... each of these methods pretty much do the same thing, they set the corresponding text within the box to either O or X, depending on whose turn it is by using "world.playerTurn" as the conditional, and then it either calls the method "winText.Player X Won" or "winText.Player O Won!" (don't ask my why O has an exclamation at the end while X doesn't, I don't know why. Maybe I like player O more?). These method names are deceiving though because they don't actually mean that the player has won, but rather it is a method to check to see [B]if[/B] the player won. Within these methods are "if" condition blocks checking every single possible combination that would indicate a win; so any diagonal, horizontal, or vertical combination of that player's symbol (O or X) would indicate a win, I think there are 8 possible combinations. If a win is detected, it will show the winning text and background that has been hiding this entire time, flash the winning texts, increment the winner's score, and run the method "winText.playAgain" to ask you if you want to play again.

Sorry about the bad code and for this giant mess of a post. I hope it wasn't too confusing and that it helps you make your own game. I am willing to take a look at your progress and give help if you have any specific questions. Just reply here with your questions and updated project and I'll give feedback.

taeweas 12-03-2015 12:10 PM

1 Attachment(s)
Thanks for your help! Here is what I have so far, I'm just having trouble implementing the lists to make one global method. Im trying to keep it simple as well....Thanks for the feedback


All times are GMT -5. The time now is 07:10 PM.

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.