Welcome, Guest. Please login or register.

Author Topic: Recently downloaded TNT Basic  (Read 5443 times)

JamesVipond

  • Member
  • Posts: 83
Recently downloaded TNT Basic
« on: January 25, 2006, 04:57:55 PM »
Earlier this month I downloaded a copy of TNT Basic for Mac OS X, and have decided to start with a simple project: the Secret "X" game from The Price Is Right. I have already created some graphics and laid out the logic of the program, but I haven't written any code yet. Is there an efficient way to check for three in a row after the computer hides its X and the player places two or three more X's?
"He has big eyes ... and they're BLUE!"

-- a boy describing Bill Cullen on Child's Play

clemon79

  • Member
  • Posts: 27693
  • Director of Suck Consolidation
Recently downloaded TNT Basic
« Reply #1 on: January 25, 2006, 05:13:09 PM »
[quote name=\'JamesVipond\' date=\'Jan 25 2006, 01:57 PM\']Earlier this month I downloaded a copy of TNT Basic for Mac OS X, and have decided to start with a simple project: the Secret "X" game from The Price Is Right. I have already created some graphics and laid out the logic of the program, but I haven't written any code yet. Is there an efficient way to check for three in a row after the computer hides its X and the player places two or three more X's?
[snapback]108645[/snapback]
[/quote]
There's probably a way to do it more efficiently, but it seems that far and away the easiest way to code it would simply be to check the five possible lines on a Secret X board ('cuz you don't have to deal with the three verticals, right?) and see if one of them has all X's. Anything you write is gonna be some flavor of that anyhow, so I doubt from an efficiency standpoint it's going to make a difference.

That said, you know where the Secret X is, right? So if you know that, there are only at most three lines you have to check, and that only if the X is in the center. If it's on the top or bottom, you only have to check that horizontal line, because the rest of the board is irrelevant.

I'd guess you want to code the board as a 3 by 3 array, and you would just do something like:
XRow = RowWhereXIs
If ((([XRow, 1] = "X") and ([XRow, 3] = "X")) Or (((XRow = 2) And (([1, 1] = "X") and ([3, 3] = "X")) Or (([1, 3] = "X") and ([3, 1] = "X")))) Then
   AWinnarIsYou
Else
   PlayLoserHorns
« Last Edit: January 25, 2006, 05:35:34 PM by clemon79 »
Chris Lemon, King Fool, Director of Suck Consolidation
http://fredsmythe.com
Email: clemon79@outlook.com  |  Skype: FredSmythe

JamesVipond

  • Member
  • Posts: 83
Recently downloaded TNT Basic
« Reply #2 on: January 25, 2006, 09:31:56 PM »
Thank you for providing your code example for determining whether it's a win or a loss. I can adapt it to TNT Basic's treatment of arrays (one dimension, indexes start at zero). I still need to have the player place the X's, most likely with the mouse.
"He has big eyes ... and they're BLUE!"

-- a boy describing Bill Cullen on Child's Play

clemon79

  • Member
  • Posts: 27693
  • Director of Suck Consolidation
Recently downloaded TNT Basic
« Reply #3 on: January 25, 2006, 10:17:44 PM »
[quote name=\'JamesVipond\' date=\'Jan 25 2006, 06:31 PM\']Thank you for providing your code example for determining whether it's a win or a loss. I can adapt it to TNT Basic's treatment of arrays (one dimension, indexes start at zero). I still need to have the player place the X's, most likely with the mouse.
[snapback]108667[/snapback]
[/quote]
There have GOT to be multidimentional arrays in there. But one's fine, if that's all you know how to do. Number the boxes 0-8, the same logic applies.
Chris Lemon, King Fool, Director of Suck Consolidation
http://fredsmythe.com
Email: clemon79@outlook.com  |  Skype: FredSmythe

Matt Ottinger

  • Member
  • Posts: 13018
Recently downloaded TNT Basic
« Reply #4 on: January 25, 2006, 10:54:48 PM »
[quote name=\'clemon79\' date=\'Jan 25 2006, 06:13 PM\']
XRow = RowWhereXIs
If ((([XRow, 1] = "X") and ([XRow, 3] = "X")) Or (((XRow = 2) And (([1, 1] = "X") and ([3, 3] = "X")) Or (([1, 3] = "X") and ([3, 1] = "X")))) Then
   AWinnarIsYou
Else
   PlayLoserHorns
[/quote]
Hey look, Chris made a pretty box.

(This is all I got out of that post.)
This has been another installment of Matt Ottinger's Masters of the Obvious.
Stay tuned for all the obsessive-compulsive fun of Words Have Meanings.

clemon79

  • Member
  • Posts: 27693
  • Director of Suck Consolidation
Recently downloaded TNT Basic
« Reply #5 on: January 25, 2006, 11:11:58 PM »
[quote name=\'Matt Ottinger\' date=\'Jan 25 2006, 07:54 PM\']Hey look, Chris made a pretty box.

(This is all I got out of that post.)
[snapback]108672[/snapback]
[/quote]
Yeah, it's a convoluted statement, but I dig writing hellaciously long Boolean statements to evaluate stuff like that in one fell swoop instead of probably-easier-to-read-but-less-efficient nested-Ifs. :)
Chris Lemon, King Fool, Director of Suck Consolidation
http://fredsmythe.com
Email: clemon79@outlook.com  |  Skype: FredSmythe

bossjock967

  • Member
  • Posts: 455
  • Smiling politely.
Recently downloaded TNT Basic
« Reply #6 on: January 26, 2006, 10:27:16 AM »
[quote name=\'clemon79\' date=\'Jan 25 2006, 11:11 PM\']Yeah, it's a convoluted statement, but I dig writing hellaciously long Boolean statements to evaluate stuff like that in one fell swoop instead of probably-easier-to-read-but-less-efficient nested-Ifs. :)
[snapback]108674[/snapback]
[/quote]
That's code?  Where are the line numbers??  ;-)
Corey Dukes
The "Biggest Jerk" of the Game Show Forum

Clay Zambo

  • Member
  • Posts: 2065
Recently downloaded TNT Basic
« Reply #7 on: January 26, 2006, 10:38:24 AM »
[quote name=\'clemon79\' date=\'Jan 25 2006, 11:11 PM\']Yeah, it's a convoluted statement, but I dig writing hellaciously long Boolean statements to evaluate stuff like that in one fell swoop instead of probably-easier-to-read-but-less-efficient nested-Ifs. :)
[/quote]


I dig the Nested Ifs.  I have all their albums.
czambo@mac.com

JamesVipond

  • Member
  • Posts: 83
Recently downloaded TNT Basic
« Reply #8 on: January 26, 2006, 11:03:09 AM »
Evidently none of you has ever used Mac OS. TNT Basic (www.tntbasic.com) doesn't need line numbers, as it's supposed to be a simple programming language for both OS 9 and OS X.

I'm still in the early stages of programming my Secret "X" game. I have the logic for hiding the X in the center column and checking for a win, but I haven't yet been able to figure out how to have the player place X's on the board.
"He has big eyes ... and they're BLUE!"

-- a boy describing Bill Cullen on Child's Play

chris319

  • Co-Executive Producer
  • Posts: 10650
Recently downloaded TNT Basic
« Reply #9 on: January 26, 2006, 01:17:49 PM »
Quote
I haven't yet been able to figure out how to have the player place X's on the board.
Drag 'n' drop, baby.

parliboy

  • Member
  • Posts: 1756
  • Which of my enemies told you I was paranoid?
Recently downloaded TNT Basic
« Reply #10 on: January 26, 2006, 01:40:48 PM »
Don't know the language that's being used, but you could try to apply this as a magic square, only with fewer checks.  Set the values of your boxes in an order like this:

816
357
492

Each of the player's possible three X's are set with a starting value of a negative number (at least -3).  When a box is given / earned, the X's value changes to the corresponding box value.  When you're ready to see if the player won, you look at the value of the secret X (either 1, 5, or 9) and add it to:

The player's first and second X's
The player's second and third X's
The player's first and third X's

If any of those three sums add up to 15, the player wins.  If not, the player loses.

Initializing to -3 prevents situations like 9 + 6 + 0 = 15.

I'm running a flu and half out my head, so I may be missing something.  But I think this will work.
"You're never ready, just less unprepared."

clemon79

  • Member
  • Posts: 27693
  • Director of Suck Consolidation
Recently downloaded TNT Basic
« Reply #11 on: January 26, 2006, 01:59:42 PM »
[quote name=\'bossjock967\' date=\'Jan 26 2006, 07:27 AM\']That's code?  Where are the line numbers??  ;-)
[snapback]108707[/snapback]
[/quote]
Tell me about it. I've gotten used to the no-line-numbers thing when I took Pascal in high school, but over the last week or so I've been rewriting my Jeopardy Challenger in Visual Basic, and one of the strangest things for me is not even having to worry about using Begins or Ends or open/closed braces to set apart blocks of code. You just write a list of a statements. It's weird. Refreshing, and not having to worry about syntax as much makes coding fun, but it's weird.
[quote name=\'parliboy\' date=\'Jan 26 2006, 10:40 AM\']Don't know the language that's being used, but you could try to apply this as a magic square, only with fewer checks. 
[/quote]
That, sir, was a brilliant approach. I love it.
Chris Lemon, King Fool, Director of Suck Consolidation
http://fredsmythe.com
Email: clemon79@outlook.com  |  Skype: FredSmythe

parliboy

  • Member
  • Posts: 1756
  • Which of my enemies told you I was paranoid?
Recently downloaded TNT Basic
« Reply #12 on: January 26, 2006, 02:52:17 PM »
[quote name=\'clemon79\' date=\'Jan 26 2006, 01:59 PM\'][quote name=\'parliboy\' date=\'Jan 26 2006, 10:40 AM\']Don't know the language that's being used, but you could try to apply this as a magic square, only with fewer checks. 
[/quote]
That, sir, was a brilliant approach. I love it.
[snapback]108727[/snapback]
[/quote]

<shrug> I remembered reading about an alternate way to play Tic-Tac-Toe, where instead of placing X's and O's in a grid, each person chose numbers from 1-9 and added the choice to their "column", with the caveat being that each number could only be used once.  Make it so that you can add exactly three of your numbers together to get 15 and you win.  It's the exact same game, but presented so differently that people have trouble adapting to it.
"You're never ready, just less unprepared."