Computer Science Canada Playing Card Engine |
Author: | Flikerator [ Fri Nov 11, 2005 6:45 pm ] | ||
Post subject: | Playing Card Engine | ||
I was planning on making a Poker game, and decided to make this. I don't have that many rems, but its pretty easy to understand. Anytime you want to shuffle the deck call shuffle. Anytime you want to deal cards out to the players call Handout. If you are unsure how something works just ask. Also feel free to improve it. This can be used for any standard card game. By that I mean a game that uses a regular 52 card deck. If you'd like a multiple deck game I could change the engine a bit. But really, its not that hard.
|
Author: | ZeroPaladn [ Mon Nov 14, 2005 9:51 am ] |
Post subject: | |
very cool. I could never figure out how to use the true and false syntax in turing, i just use 1's and 0's for it . Ive allways wondered how people make card games in turing, maybe this wil shed some light on it... |
Author: | Mr. T [ Mon Nov 14, 2005 2:42 pm ] | ||
Post subject: | Alex's Opinion | ||
It's probably best you start getting familiar with booleans (or true or false statements, as you put it) because it is a very powerful programming tool. Think of it as an on or off switch, where true = on and false = off. If you've taken a Compsci course, you'll probably know this is quite similar to way a computer works at a machine code level. Anyway, here is an example showing the effectiveness of booleans.
|
Author: | Flikerator [ Mon Nov 14, 2005 4:06 pm ] |
Post subject: | |
if 1 = num then elsif 2 = num end if In oder for each if statement to "pass" (run the lines of code) it must be true. Unless you have a not= or ~=, then it checks if its false. var check : boolean := true if check then end if See how you didnt have to put = or anything? Because it already has the value of true or false, and doesnt need to do a comparasin. You could put if check = true, or check = false if you want to make it easier to see, untill you get used to it. if ~check then That if statement will run when check is false. (~true) Not the most simple, or easy to read tutorial on booleans, but hopefully you get the just of them |
Author: | GlobeTrotter [ Mon Nov 14, 2005 4:10 pm ] |
Post subject: | |
For the playing card engine, look into using records and fewer global variables. It make for much better formatting. For example, have a record for each card, and have a procedure shuffle that takes in an array of cards and shuffles them. |
Author: | Cervantes [ Mon Nov 14, 2005 4:19 pm ] | ||||
Post subject: | |||||
A minor detail: Flikerator wrote: In oder for each if statement to "pass" (run the lines of code) it must be true. Unless you have a not= or ~=, then it checks if its false. No, it still always checks for truth. You have to look at the entire condition, including any nots, as being tested for truth.
This is evaluated for truth. The expression (or condition)
evaluates to false, so the else block is entered, rather than the if block. |
Author: | codemage [ Mon Nov 14, 2005 11:19 pm ] | ||||
Post subject: | |||||
A shortcut for booleans is that they don't even technically have to be evaluated for true in Turing (and several languages.) ie for var flag : boolean := true
is the same as
Which *I* think is a nice little shortcut. Purists will say that the previous method is better programming though. |
Author: | Flikerator [ Sun Nov 20, 2005 2:48 pm ] | ||||
Post subject: | |||||
codemage wrote: A shortcut for booleans is that they don't even technically have to be evaluated for true in Turing (and several languages.)
ie for var flag : boolean := true
is the same as
Which *I* think is a nice little shortcut. Purists will say that the previous method is better programming though. if flag then Is the better one, seems better in my opinion. I mentioned that method above already though =P |
Author: | ZeroPaladn [ Mon Nov 21, 2005 10:18 am ] |
Post subject: | |
ah, i get it now. thanks guys. |