Computer Science Canada mini-contest: No selection-structure Tic-Tac-Toe |
Author: | Insectoid [ Sun Apr 19, 2009 6:39 pm ] |
Post subject: | mini-contest: No selection-structure Tic-Tac-Toe |
Well, I've had an idea bouncing around in my head to create a game of Tic-Tac-Toe with no conditionals. That means no if-statements, case-statements, exit-statements, etc. The only selection you can use is in the case of for loops, for example; for (int i = 0, i>= 5, i++){ } Being the lazy bum I am, I haven't gotten around to it. However, I believe that clever use of hashes, math, and binary should do the trick. So I'm challenging you guys to do this (mostly so I can see the finished product without actually doing it). The requirements: -it must have a visual display. Be it ASCII or 3-D, it must have a graphical representation of where the X's and O's are. -it must follow standard 3x3 tic-tac-toe rules -it must be multiplatform (Turing is okay, it runs perfectly on Wine and Crossover) -it must not use and conditionals, except in the case of for loops as shown above -it must display the name/player number of the winner when a player wins -it need not have a mouse implementation, you may enter the location of your X or O via coordinates. Have fun! Winner gets 1000 bits (unless I don't have that many...) EDIT: The winner is the person who makes the most interesting program, and has the most awesome code (judged by me) |
Author: | saltpro15 [ Sun Apr 19, 2009 7:00 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
damn that's a challenge... I'll give it a shot, how long do we have? |
Author: | Insectoid [ Sun Apr 19, 2009 7:03 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
You have until whenever I say so, aka whenever I get bored of waiting. And those for loop conditionals can only be used in counted loops. A 'do this X many times' loop. No sneaky rule-bending allowed. |
Author: | saltpro15 [ Sun Apr 19, 2009 7:21 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
hehe very well, I'll be getting ready for ECOO all this week, so I'll have some time to start it hopefully |
Author: | Nick [ Sun Apr 19, 2009 7:44 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
Done Python style
also Saad caught me cheating so this doesn't count, oh well |
Author: | Brightguy [ Mon Apr 20, 2009 8:54 am ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
Done Javascript style. Probably would work in Internet Explorer, but I know it doesn't support XHTML, and I'm sick and tired of working around IE.
|
Author: | Insectoid [ Mon Apr 20, 2009 3:37 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
wew, brightguy, that's fancy. I'm gonna have to ask somebody who understands javascript to look it over for cheating (not that I accuse you, but because you may have coded some in by habit). God, javascript's method names are so ridiculously long it's harder to understand than one with short names (ie ruby/python). EDIT: Neither submissions handles cat's game. Definitely points for that. |
Author: | Insectoid [ Mon Apr 20, 2009 4:09 pm ] | ||
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe | ||
Just a question;
Does that big return statement mean 'return (1 and 2 and 3) or (3 and 4 and 5) or (6 and 7 and 8)...'? |
Author: | Nick [ Mon Apr 20, 2009 4:27 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
Quote: EDIT: Neither submissions handles cat's game. Definitely points for that. mine does.... |
Author: | Alexmula [ Mon Apr 20, 2009 5:23 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
|
Author: | Insectoid [ Mon Apr 20, 2009 5:24 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
no. |
Author: | richcash [ Mon Apr 20, 2009 6:10 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
Here is an unspectacular Tic Tac Toe with no conditionals in Turing. I might polish the display if I have more time.
|
Author: | The_Bean [ Mon Apr 20, 2009 7:34 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
Python 2.5.4:
|
Author: | CodeMonkey2000 [ Mon Apr 20, 2009 8:29 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
I'm waiting for someone to write this in BF. Hehehe. |
Author: | richcash [ Mon Apr 20, 2009 9:38 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
insectoid wrote: Just a question;
Yes, but he is using them as bitwise operators not boolean operators, so he is not using selection directly.
Does that big return statement mean 'return (1 and 2 and 3) or (3 and 4 and 5) or (6 and 7 and 8)...'? @The_Bean, good job but I would consider the function filter a conditional/selection method. In fact, you can probably replace every single if statement by using filter trivially. @Nick, do you mind telling us why your code is supposedly invalid (I don't read python well). |
Author: | matt271 [ Tue Apr 21, 2009 5:31 am ] | ||
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe | ||
enter the quardenents from 0 to 2 separated by spaces. should look like: Quote: 0 0
X _ _ _ _ _ _ _ _ 0 1 X O _ _ _ _ _ _ _ 1 1 X O _ _ X _ _ _ _ 0 2 X O O _ X _ _ _ _ 2 2 X O O _ X _ _ _ X X wins |
Author: | Nick [ Tue Apr 21, 2009 1:36 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
richcash @ Mon Apr 20, 2009 9:38 pm wrote: @Nick, do you mind telling us why your code is supposedly invalid (I don't read python well).
I used a for i in range (x): loop as an if x: statement ex:
|
Author: | matt271 [ Tue Apr 21, 2009 4:21 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
no comment on my solution? |
Author: | richcash [ Tue Apr 21, 2009 4:59 pm ] | ||||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||||
Nick wrote: I used a for i in range (x): loop as an if x: statement
Ah, I see, I somehow missed that.
ex:
matt271 wrote: no comment on my solution? ( Looks good to me, though I don't have a compiler at the moment to test it. However :
|
Author: | matt271 [ Tue Apr 21, 2009 6:00 pm ] | ||||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||||
my bad :] i fixed it ty
and in java!
|
Author: | Nick [ Wed Apr 22, 2009 2:54 am ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
here's a comment, where's cat's game and where's the code that stops you from playing where one's already played? |
Author: | matt271 [ Wed Apr 22, 2009 3:46 am ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
what is cats game? and nothing stops u from playing where some1 already played. also nothing stops u from giving a point off the 3x3 grid and nothing stops u from playing after u already won (but the java one will tell u the game is already over ) i guess i could come up w/ some real clever way to do those but i still think i won, i want the bits (what r bits anyways?) its all for fun :] |
Author: | matt271 [ Wed Apr 22, 2009 4:22 am ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
there i did it in c this time:
input ur moves the same output is liek this Quote: 1 1
_ _ _ _ X _ _ _ _ 0 1 _ O _ _ X _ _ _ _ 0 0 X O _ _ X _ _ _ _ 0 2 X O O _ X _ _ _ _ 2 2 X O O _ X _ _ _ X X wins! 0 0 X _ _ _ _ _ _ _ _ 1 0 X _ _ O _ _ _ _ _ 0 1 X X _ O _ _ _ _ _ 1 1 X X _ O O _ _ _ _ 0 2 X X X O O _ _ _ _ X wins! 2 2 _ _ _ _ _ _ _ _ X 0 0 O _ _ _ _ _ _ _ X 2 1 O _ _ _ _ _ _ X X 0 2 O _ O _ _ _ _ X X 1 1 O _ O _ X _ _ X X 0 1 O O O _ X _ _ X X O wins! 1 1 _ _ _ _ X _ _ _ _ 1 1 Sorry not valid move my friend _ _ _ _ X _ _ _ _ 0 1 _ O _ _ X _ _ _ _ |
Author: | OneOffDriveByPoster [ Wed Apr 22, 2009 9:19 am ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
matt271 @ Wed Apr 22, 2009 4:22 am wrote:
I don't know about the contest judge, but this looks like cheating. An array of function pointers? That's not a selection statement? Really? |
Author: | Insectoid [ Wed Apr 22, 2009 12:55 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
I dunno how that works (not knowing any C) but if OneOffDriveByPoster thinks it's cheating, I'll trust him. Anyway, if anyone wants to vote on a submission, PM me. Don't vote for your own, it's not cool. |
Author: | richcash [ Wed Apr 22, 2009 1:48 pm ] |
Post subject: | Re: RE:mini-contest: No selection-structure Tic-Tac-Toe |
matt271 @ Wed Apr 22, 2009 3:46 am wrote: what is cats game? When the game ends in a draw.
matt271 @ Wed Apr 22, 2009 3:46 am wrote: and nothing stops u from playing where some1 already played.
In my opinion you need to fix those things to make it valid. Also, if the person enters an invalid move (or enters a cell that's already filled) it should still be their turn, but the board should not change.
and nothing stops u from playing after u already won (but the java one will tell u the game is already over ) i guess i could come up w/ some real clever way to do those insectoid wrote: Anyway, if anyone wants to vote on a submission, PM me. Don't vote for your own, it's not cool. The contest is closed already? The only two completely valid submissions so far are mine and Brightguy's, until matt disallows letting a player enter a cell that's already occupied (since that is a rule of TTT) and Nick, The_Bean get rid of their use of selection. |
Author: | matt271 [ Wed Apr 22, 2009 2:41 pm ] |
Post subject: | Re: RE:mini-contest: No selection-structure Tic-Tac-Toe |
richcash @ Wed Apr 22, 2009 2:48 pm wrote: In my opinion you need to fix those things to make it valid. Also, if the person enters an invalid move (or enters a cell that's already filled) it should still be their turn, but the board should not change.
i did fix that in my latest submission insectoid @ Wed Apr 22, 2009 1:55 pm wrote: I dunno how that works (not knowing any C) but if OneOffDriveByPoster thinks it's cheating, I'll trust him.
its not cheating its not a conditional statement its just a very clever way to call functions its no dif then when i said printf(msg[blah]); |
Author: | OneOffDriveByPoster [ Wed Apr 22, 2009 2:55 pm ] |
Post subject: | Re: RE:mini-contest: No selection-structure Tic-Tac-Toe |
matt271 @ Wed Apr 22, 2009 2:41 pm wrote: its no dif then when i said printf(msg[blah]); Absolutely not. This can alter control flow (as opposed to the data). |
Author: | matt271 [ Wed Apr 22, 2009 4:05 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
but the point was to find a way to build the game w/out condition statements, not w/out flow. if u say anything that can alter flow is a conditional statement, then any clever way to build the game is a conditional statement. what if u wrote it in basic and used clever numbers to represent X and O then said GOTO X blah this was supposed to be a fun lil challenge but now its turning un-fun |
Author: | OneOffDriveByPoster [ Wed Apr 22, 2009 10:11 pm ] | ||
Post subject: | Re: mini-contest: No selection-structure Tic-Tac-Toe | ||
Cat's game and invalid move checking included.
|
Author: | Insectoid [ Thu Apr 23, 2009 4:03 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
No, the contest isn't closed. I'm just accepting votes over PM to help me decide who wins. When you PM me, include who you're voting for and why their submission is the best. |
Author: | matt271 [ Thu Apr 23, 2009 6:51 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
has any1 voted for me? :] |
Author: | saltpro15 [ Thu Apr 23, 2009 7:54 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
yeah, sorry insectoid but I really need to get ready for ECOO and do my homework, I don't have the time for this. I wish i did though |
Author: | Insectoid [ Thu Apr 23, 2009 7:58 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
Awh, oh well, saltpro. Nobody has voted yet, matt. |
Author: | Insectoid [ Sat Apr 25, 2009 6:31 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
All right, looks like all the submissions are in. Contest Closed! Vote on your favorite submission via PM to me! Be sure to include why you voted for that submission! |
Author: | bugzpodder [ Sun Apr 26, 2009 8:58 am ] |
Post subject: | Re: RE:mini-contest: No selection-structure Tic-Tac-Toe |
insectoid @ Mon Apr 20, 2009 3:37 pm wrote: wew, brightguy, that's fancy. I'm gonna have to ask somebody who understands javascript to look it over for cheating (not that I accuse you, but because you may have coded some in by habit). God, javascript's method names are so ridiculously long it's harder to understand than one with short names (ie ruby/python).
EDIT: Neither submissions handles cat's game. Definitely points for that. ROFL |
Author: | matt271 [ Thu Apr 30, 2009 12:04 am ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
i vote for myself i feel my clever use of an array is in no way even close to a switch statement |
Author: | matt271 [ Thu May 07, 2009 2:11 pm ] |
Post subject: | RE:mini-contest: No selection-structure Tic-Tac-Toe |
what happened to this contest? u got any more interesting contests |