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)

Dameria 12-07-2009 03:53 PM

Tic-Tac-Toe!
 
1 Attachment(s)
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.

If you do not understand how I programmed this, please see my explanation post here:
[url]http://www.alice.org/community/showthread.php?p=56924[/url][/i]

x2495iiii 12-07-2009 06:41 PM

Well Done! The only thing I could think of to add would be a cat's game notification. Good stuff!

Dameria 12-07-2009 06:51 PM

Thanks! But whats a cat's game notification?

I was thinking of adding these things into Tic-Tac-Toe 2.0:[LIST][*]An option at the end to play the game again, where it would reset everything back to default places and you could play again.[*]A scoring board telling which player has how many wins.[*]A box showing who's turn it is.[*]A method that would run at the start of every new game randomly picking the first player to start (and the players would know who is first from the "Player's Turn" box).[*]The colors of the X's or O's that the person won by will flash from red to black.[/LIST]
Do you think this is good so far? Should I make more things to add in, or should I just take out one of my ideas that I am planning to put in?

x2495iiii 12-07-2009 07:31 PM

A cat's game is a tie, where nobody wins.

And those ideas sound great, go ahead and add them all.

Dameria 12-09-2009 11:39 AM

Progress
 
Over the next week or so I am going to be working on Tic-Tac-Toe 2.0. I will be posting my progress here and I will edit this post whenever I finish a certain part of the game. Here is the progress on the game:
[LIST][*]A cat's game (tie) message. [b][COLOR="Green"]DONE[/COLOR][/b][*]An option at the end to play the game again, where it would reset everything back to default places and you could play again. [b][COLOR="Green"]DONE[/COLOR][/b][*]A scoring board telling which player has how many wins. [b][COLOR="Green"]DONE[/COLOR][/b][*]A box showing who's turn it is. [b][COLOR="Green"]DONE[/COLOR][/b][*]A method that would run at the start of every new game randomly picking the first player to start (and the players would know who is first from the "Player's Turn" box). [b][COLOR="Green"]DONE[/COLOR][/b][*]The colors of the X's or O's that the person won by will flash from red to black. [b][COLOR="Green"]DONE[/COLOR][/b][*]An option to enter the names of the people playing the game that would appear on the scoreboard. [b][COLOR="Green"]DONE[/COLOR][/b][/LIST]
When I am done with everything, I will post Tic-Tac-Toe 2.0. Until then feel free to download version 1 and try it. If you have any more ideas for version 2.0 or comments please reply to this thread. Thanks

Dameria 12-09-2009 04:43 PM

2 Attachment(s)
After working for about 5 hours today on this, I have finally created Tic-Tac-Toe 2.0!!! It has all of the add-ins listed in the above post, and I really hope that you enjoy it.

PLEASE tell me what you think by leaving a comment, I have worked very hard on this game, and although it was challenging at some times, I eventually got it all to work.

The only real thing that I want to change but cannot, is the number of wins text. When you get a win, instead of displaying "1", it displays "1.0", and so on. I cannot find how to turn this variable into an integer instead of a double. Other than that, everything else should work great. Tell me what you think!

[i]I will also provide the version 1 here for whoever wants to see it, but if you are just looking to play the game version 2 is much better.[/i]

x2495iiii 12-09-2009 06:32 PM

At the moment, it's impossible, unless you use a nested if/else if statement for each number and set the text directly to each number instead of the variable as a string (not worth it, in my opinion).

Nice job on the game! The work you put into it shows, good stuff!

Dameria 12-09-2009 07:03 PM

Thanks, I tried to make it as fun as possible, and I learned a lot while making some of my methods, and also used what I have learned to perfect them and make them run to the best of their ability.

rockstar442 12-09-2009 07:07 PM

hey i enjoyed it

dubastot 12-09-2009 07:10 PM

Another incredible world by Dameria. Suddenly I feel like I haven't made anything good for quite a while (probably because of school).

rockstar442 12-09-2009 07:15 PM

Dameria,x2495iiii they are inspiration to me there my idols in programming

Dameria 12-09-2009 08:56 PM

lol, thanks rockstar442, but I don't think I am going to every make a game as good as Resident Penguin. I am thinking of making a shooting game next though.

zarfang8 12-15-2009 08:11 PM

[QUOTE=Dameria;14150]When you get a win, instead of displaying "1", it displays "1.0", and so on.

[/i][/QUOTE]

Yeah, That happened in my Yahtzee game to, the dice would always show 1.0 instead of 1.

cooki3monst3r77 06-02-2010 07:35 PM

Bull
 
This dude stole this file from a classmate of mine and didnt even bother to change the fricken COLORS! Your a Lame O.

Dameria 06-02-2010 07:41 PM

Haha, woooow. Check the date of publication, I published this game waaaay before your classmate used it in class. I don't think I am the one you should be calling a thief.

I remember making this game step by step, and I believe I even made a version 1 before I made 2.0. Don't worry, I am not mad that your classmate stole my program and used it for his final or whatever he did, but you should just inform him that now you know that he did not actually do the program and that he stole it from me.

I published the game on 12-07-2009, even check page one of this thread and look at the date.

dubastot 06-02-2010 08:43 PM

I find this situation quite funny. I guess some people stand up for their friends and get others in trouble.

Dameria 06-02-2010 08:48 PM

[QUOTE=dubastot;21933]I find this situation quite funny. I guess some people stand up for their friends and get others in trouble.[/QUOTE]

Lol it is pretty funny. Im actually more proud that my game is good enough for people to steal for their programming class than I am mad that someone would steal my work that I spent hours on.

x2495iiii 06-03-2010 04:03 AM

Ha, nice. I wonder what program HE used for his final (it obviously wasn't a working calendar).

Honestly, sometimes I wonder if my old worlds are being stolen and used for other peoples' credit. I do believe I'll put a scripted command (can't be deleted by lazy students using everyday Alice) that flashes my name at the end of my worlds or something along those lines. Imitation is the greatest form of flattery, but thievery is nothing short of degrading and insulting, especially to the thief.
(Plus, the thought of outsmarting plagiarists is very appealing to me).

cooki3monst3r77 06-03-2010 01:30 PM

apology
 
I apologize. There was a misunderstanding between the friend and I. Apparently he got it from a teacher who couldnt explain how things worked on it and my friend was trying to turn it in as a project in my school, saying that he was the one that created it. Now I feel like a real douche. I am truly sorry. We are trying to recreate this tic tac toe in school and I am f#@#$# STUMPED. Even looking at your code. GOOD JOB.

Dameria 06-03-2010 04:06 PM

[QUOTE=cooki3monst3r77;21954]I apologize. There was a misunderstanding between the friend and I. Apparently he got it from a teacher who couldnt explain how things worked on it and my friend was trying to turn it in as a project in my school, saying that he was the one that created it. Now I feel like a real douche. I am truly sorry. We are trying to recreate this tic tac toe in school and I am f#@#$# STUMPED. Even looking at your code. GOOD JOB.[/QUOTE]

Its alright. I agree that my tic-tac-toe is hard to understand because I made almost all of the methods on separate objects, making you locate all of the methods by clicking on different objects. It is very efficient however because it does not use infinite loops, it only runs methods once you click on a square. I think that this is one of my best games so far, and other than the awkward method placements, it is my most well-programmed game.

So your teacher is assigning you to figure out how my tic-tac-toe works? Or is he making your class create a tic-tac-toe, and he has mine as an example that he cannot understand? It seems like a lot of teachers have been assigning their students to look at my work lately. First the collision detection and timer on my maze game, and now my tic-tac-toe game, I am flattered :)

x2495iiii 06-04-2010 01:26 AM

[QUOTE=cooki3monst3r77;21954]I apologize. There was a misunderstanding between the friend and I. Apparently he got it from a teacher who couldnt explain how things worked on it and my friend was trying to turn it in as a project in my school, saying that he was the one that created it. Now I feel like a real douche. I am truly sorry. We are trying to recreate this tic tac toe in school and I am f#@#$# STUMPED. Even looking at your code. GOOD JOB.[/QUOTE]

Very honorable of you.

chinchli57 12-04-2010 08:46 PM

folders in details window
 
Dameria I loved your dice game! Very nice and neat.
I am having to do a dice game and am trying to figure out how to include lists or arrays. When putting in all of the squares and numbers I ran out of room and can no longer see the details window! Not sure how to get that back, but what I wanted to know is this, on your dice game you put everything in it's own folder, how did you do that? Also, do you have to add the folder name when you are calling out a square for instance. This probably all sounds silly to you but I am new to Alice this semester. Thanks.

Dameria 12-04-2010 09:03 PM

[QUOTE=chinchli57;29155]Dameria I loved your dice game! Very nice and neat.
I am having to do a dice game and am trying to figure out how to include lists or arrays. When putting in all of the squares and numbers I ran out of room and can no longer see the details window! Not sure how to get that back, but what I wanted to know is this, on your dice game you put everything in it's own folder, how did you do that? Also, do you have to add the folder name when you are calling out a square for instance. This probably all sounds silly to you but I am new to Alice this semester. Thanks.[/QUOTE]

To add a folder you right click in the object list and press on the "Add Folder" option. You can then drag any options you want into that folder to organize the object panel like I did. By the way I do not have a dice game, I have a tic-tac-toe game. Lists and arrays are not that hard, and they do allow you to do everything you want with a lot less coding, but they can get tricky, so unless you have more than 10 objects that you all want to do the same type of thing, then I suggest you don't use lists. If there are more than 10, than you can, and you use the "For All in Order" a "For All Together" blocks on the bottom to call lists. You then use methods with parameters from there to do the action that you want to with that list.

Shibble 10-18-2011 11:13 AM

Not sure if you will read this because this thread is pretty old, but how did you manage to get the world.playerturn variable to the setSquare method. I have a assingment for school which looks a bit like this, but i can't seen to make a "universal" variable that changes througout the game.

Dameria 10-18-2011 01:24 PM

[QUOTE=Shibble;42526]Not sure if you will read this because this thread is pretty old, but how did you manage to get the world.playerturn variable to the setSquare method. I have a assingment for school which looks a bit like this, but i can't seen to make a "universal" variable that changes througout the game.[/QUOTE]

To make a universal variable you have to create the variable underneath the "World" tab in the object list, the one where every other object branches off of. If you create the variable here, it can be used in any method or object in the program. If you create the variable in any other object, then that variable will only work within that object's methods.

Shibble 10-18-2011 03:27 PM

[QUOTE=Dameria;42532]To make a universal variable you have to create the variable underneath the "World" tab in the object list, the one where every other object branches off of. If you create the variable here, it can be used in any method or object in the program. If you create the variable in any other object, then that variable will only work within that object's methods.[/QUOTE]

With "underneath" the world tab, do you mean, select World and then click variable. Or really create one underneath is so that it's stands on it's own.
(Sorry to bother you, but i'm new to this)

Edit : Looking at you're code, you have a world.playerTurn in your setsqaure method, but i just can't seem to get that to work. Alice won't let me drag the variable into a if/else stament.
[IMG]http://imageshack.us/photo/my-images/843/problemqs.png/[/IMG]
[URL=http://imageshack.us/photo/my-images/843/problemqs.png/][IMG]http://img843.imageshack.us/img843/7530/problemqs.png[/IMG][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

Dameria 10-18-2011 05:06 PM

[QUOTE=Shibble;42533]With "underneath" the world tab, do you mean, select World and then click variable. Or really create one underneath is so that it's stands on it's own.
(Sorry to bother you, but i'm new to this)

Edit : Looking at you're code, you have a world.playerTurn in your setsqaure method, but i just can't seem to get that to work. Alice won't let me drag the variable into a if/else statement.
[/QUOTE]

You should always be able to drag a world variable into an if/else statement. Just make sure you create the variable in the "world" tab and not in any other object. You click on "world" then you go to "variables" then you create a new variable, and that is a world variable. You can then drag and drop that variable into any if/else statement and compare whatever you want with it.

Shibble 10-19-2011 04:29 AM

Well i guess Alice is srewing me over then :P

I've been trying that the whole time, but it just won't let me. I'll keep trying ..

Dameria 10-19-2011 08:23 AM

[QUOTE=Shibble;42573]Well i guess Alice is srewing me over then :P

I've been trying that the whole time, but it just won't let me. I'll keep trying ..[/QUOTE]

If you want you could upload your file as a post here and I'll look it over when I get home and try to fix it. Just tell me what method and comment on the if/else statement that you are trying to get the variable into.

Also there are some glitches with using the copy/paste feature in Alice, make sure that the if/else statement is newly dragged into the code and not just a copy from somewhere else, that might do it.

Shibble 10-19-2011 02:05 PM

[QUOTE=Dameria;42575]If you want you could upload your file as a post here and I'll look it over when I get home and try to fix it. Just tell me what method and comment on the if/else statement that you are trying to get the variable into.

Also there are some glitches with using the copy/paste feature in Alice, make sure that the if/else statement is newly dragged into the code and not just a copy from somewhere else, that might do it.[/QUOTE]

Thanks for the offer, but i just managed to get it working :)

I used a fuction that keeps track of the variable. And i was able to combine that function with a variable within the method. Maybe a bit of a detour, but it works :)

Thanks again!

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 10:07 PM.

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