![]() |
#51 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() Acey Ducey, Acey Ducey!
|
||
![]() ![]() |
|
![]() |
#52 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2005
Location: Aurora, United States
Posts: 606
|
![]() <div align="center">Acey Deucy</div>
Silly game, fun game. This is a game that you could play yourself with a deck of cards and a pile of M&Ms. The game is played by dealing two cards and choosing whether the next card delt will be between the first two. If the third card is between the first two you win 15 points. If not you only lose 10. If you don't like your odds and decide to forfit looking at the third card you automaticly lose 5. But like most card games this game is cruel, for while it seems like the scoring is to your advantage you will more often than not find yourself in the hole and struggling to climb out. Code:
/* Acey Duecy * by Joseph Larson * Inspired by a BASIC game by Bill Palmby /* as found in 'BASIC Computer Games' edited by David H. Ahl (c) 1978 */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <ctype.h> #define GAIN 15 #define LOSS 10 #define FORFIT 5 #define START 100 #define WIN 200 #define LOSE 0 int score = START; void intro(void) { **printf("\nAcey Duecy\n""----------\n" **"Acey Ducey is played by having the computer deal out two cards. The\n" **"player then decides on whether the next card chosen will be between the\n" **"first two dealt, Aces high.\n\n" **"You start out with %d points. If the third card is between the first to\n" **"you gain %d points. If not you lose %d points. If you decide not to see\n" **"the third card you'll automaticly lose %d points\n\n" **"You win the game if you can get to %d points. But if your points drop\n" **"below %d it is game over for you.\n\n", ** START, GAIN, LOSS, FORFIT, WIN, LOSE); **srand(time(NULL)); } void showcard(int c) { **if (c <= 10) printf("%d", c); **else switch (c) { ****case 11 : printf("Jack"); break; ****case 12 : printf("Queen"); break; ****case 13 : printf("King"); break; ****case 14 : printf("Ace"); **} } void playhand(void) { **int card1,card2,card3; **char yn[50]; **printf("Here are your first two cards:\n\n\t"); **card1 = rand() % 13 + 2; **do { ****card2 = rand() % 13 + 2; **} while (card1 == card2); **showcard(card1); **printf("\t"); **showcard(card2); **printf("\n\n"); **if (abs(card1-card2) == 1) { ****printf("Oh, tough luck. There's no card between those two.\n"); ****printf("\nSorry. You lose %d points", LOSS); ****score -= LOSS; **} else { ****printf ("Do want to see the third card? "); ****do { ******printf ("(y\\n) "); ******scanf ("%s",yn); ****} while (tolower(yn[0]) != 'y' && tolower(yn[0]) != 'n'); ****if (tolower(yn[0]) == 'y') { ******printf("\nHere is the third card\n\n\t"); ******do card3 = rand() % 13 + 2; ******while ((card3 == card1) || (card3 == card2)); ******showcard(card3); ******if (((card1 < card3) && (card3 < card2)) ******|| ((card2 < card3) && (card3 < card1))) { ********printf("\n\nCongratulations. You win.\n"); ********score += GAIN; ******} else { ********printf("\n\nSorry. You lose %d points", LOSS); ********score -= LOSS; ******} ****} else { ******printf ("Nothing ventured, nothing gained, %d points lost.\n", FORFIT); ******score-= FORFIT; ****} **} **printf("\nScore : %d.\n", score); } int playagain(void) { **char input; **if (score >= WIN || score <= LOSE) return 0; **printf("\nDo you wish to continue? (y\\n) "); **while (!isalnum (input = getchar())); **if (tolower (input) != 'n') return 1; **else return 0; } int main(void) { **intro(); **do playhand(); **while (playagain()); **if (score >= WIN) printf ("Congratulation! You WIN!\n"); **if (score <= LOSE) printf ("Sorry, try again!\n"); **printf ("Thanks for playing!\n"); **exit (0); } That's how I found out that VC++ makes executables that are more than 10x the size of the same code compiled in DevC++. Yet another reason to not love M$. This is not a true dealing alogrythm. Instead, a number between 1 and 13 is just picked out of the air, and as long as it's not the same as any of the numbers picked in that hand before it, it's valid and thrown into the game. Clever programers could adjust the game so that it's a more acurate dealing simulation that reshuffles after a certian number of hands or a certian number of cards are left in the deck. Whether or not you choose to fix the dealing alogrythm, another simple fix would be to update showcard() to actually draw cards (with randomly chosen suits if the card dealing alogrythm isn't fixed). Now there's only one left. I'll wait a few days and finish off Cymon's Games with Reverse. Strangely enough Reverse is another program I've reduced down to sig size, which is where this whole thread started. So that makes the beginning like the end. I didn't choose the order, but it seems fitting. Maybe I'll even change my sig in honor of this thread. But it's not over. Now the programs are in your hands. Can you improve them? Can you make them prettier, more acurate, or more fun? If you do, post your improvements here! (By the way, why hasn't anyone asked about the sparse illustrations that have accompanied these programs? Haven't yawl noticed them?) |
||
![]() ![]() |
|
![]() |
#53 | |||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() Quote:
Quote:
Quote:
|
|||
![]() ![]() |
|
![]() |
#54 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2005
Location: Aurora, United States
Posts: 606
|
![]() Yeah, it compiles. In DevC++, as long as you save it as a .c file it works just fine. It give you a few warnings because it says that you aren't including the necessary files, but it will find them and complie the program anyways. There are defaults in C that you don't NEED to #include, but it's good coding practice to. Stdio.h, conio.h, math.h, ctype.h... pretty much any of the basic ones. If it's a custom made header file or library you'll need to #include it, but the rest it's usually smart enough to find on it's own.
I'm pretty sure it works in VC++ as well the same way. That's been a stapel of the international obfscated C code contest for ages. Did you ask about the illustrations? I'll have to go check. |
||
![]() ![]() |
|
![]() |
#55 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2005
Location: Aurora, United States
Posts: 606
|
![]() <div align="center">Reverse</div>
This game is a simple solitare game. There were a few of these that I made, games that sort of weave a pattern down the screen as you solve them and in the are not all together unpleasant to look at. (Jumping Balls was another and Corral, which may appear here at a future date) Take a look at the overall astetic of the game as it progresses: Code:
13 12**4**2**5**7 11**8**1 10**6**3 16**9 14 15 ? 3 13 12**4**2**5**7 11**8**1 10**6**3 16 15 14**9 ? 4 13 12**4**2**5**7 11**8**1 10**6**3**9 14 15 16 ? 16 16 15 14**9**3**6 10**1**8 11**7**5**2**4 12 13 ? 13 16 15 14 13 12**4**2**5**7 11**8**1 10**6**3**9 ? 5 16 15 14 13 12**4**2**5**7 11**8**9**3**6 10**1 ? 16 1 10**6**3**9**8 11**7**5**2**4 12 13 14 15 16 ? 4 1 10**6**3**9**8 11**7**5**2**4 12 16 15 14 13 ? 4 1 10**6**3**9**8 11**7**5**2**4 12 13 14 15 16 ? 7 1 10**6**3**9**8 11**7**5 16 15 14 13 12**4**2 ? 15 1**2**4 12 13 14 15 16**5**7 11**8**9**3**6 10 ? 3 1**2**4 12 13 14 15 16**5**7 11**8**9 10**6**3 ? 14 1**2**3**6 10**9**8 11**7**5 16 15 14 13 12**4 ? 13 1**2**3**4 12 13 14 15 16**5**7 11**8**9 10**6 ? 7 1**2**3**4 12 13 14 15 16**6 10**9**8 11**7**5 ? 12 1**2**3**4**5**7 11**8**9 10**6 16 15 14 13 12 ? 6 1**2**3**4**5**7 11**8**9 10 12 13 14 15 16**6 ? 11 1**2**3**4**5**6 16 15 14 13 12 10**9**8 11**7 ? 10 1**2**3**4**5**6**7 11**8**9 10 12 13 14 15 16 ? 8 1**2**3**4**5**6**7 11 16 15 14 13 12 10**9**8 ? 9 1**2**3**4**5**6**7**8**9 10 12 13 14 15 16 11 ? 7 1**2**3**4**5**6**7**8**9 11 16 15 14 13 12 10 ? 7 1**2**3**4**5**6**7**8**9 10 12 13 14 15 16 11 ? 6 1**2**3**4**5**6**7**8**9 10 11 16 15 14 13 12 ? The object of this game is to order a list of numbers by reversing parts of the list. Because the game is at it's root so simple I made a sig version, which in honor of this posting is now my current sig. But I'll re-post it here incase my sig ever changes again: Code:
main(){long l[16],c,d,t;srand(time(0));for(t=d=c=0;c<16;c++){while(1<<(l[c]=rand ()%16+1)&d);d|=1<<l[c];}for (;c>0;printf ("%2d ",l[--c]));do{printf("? ");scanf( "%d",&d);if(d>1&&d<=16){for (c=0;c<(d/2);c++){l[c]^=l[d-c-1];l[d-c-1]^=l[c];l[c] ^=l[d-c-1];}t++;}for(c=16;c>0;printf("%2d ",l[--c]));for(c=0;c<15&&l[c]>l[c+1];c ++);}while(d&&c<15);if(d)printf("\nThank you for playing! Won in %d moves!",t);} This game too is a BASIC adapatation. Here's the full version: Code:
/* Reverse * by Joseph Larson 2005 * Inspired by a BASIC game of the same name by Peter Sessions * as found in 'BASIC Computer Games' edited by David H. Ahl (c) 1978 */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <time.h> #define X 16 int main (void) { **int list[X], c, d, turns; **long mask; **char yn; ** **srand (time(NULL)); **printf ("Reverse\n-------\n\n" ****"This is the game of Reverse. To win all you have to do is arrange a list\n" ****"of numbers (1 through %d) in numerical order left to right.\n" ****"To move, you input how many numbers from the right you want to reverse.\n" ****"You will no doubt like this game but, if you want to quit just input '0'\n" ****"as your move.\n\n", X); **do { ****mask = 0; ****for (c = 0; c < X; c++) { ******while (1 << (list[c] = rand () % X + 1) & mask); ******mask |= 1 << list[c]; ****} ****turns = 0; ****puts ("Here we go...\n"); ****do { ******putchar ('\t'); ******for (c = X; c > 0;) printf ("%2d ",list[--c]); ******printf ("\t? "); ******scanf ("%d", &d); ******if (d > 1 && d <= X) { ********for (c = 0; c < (d / 2); c++) { **********list[c] ^= list[d - c - 1]; **********list[d - c - 1] ^= list[c]; **********list[c] ^= list[d - c - 1]; ********} ********turns++; ******} else printf ("You can not reverse %d. Try again.\n", d); ******for (c = 0; c < X - 1 && list[c] > list [c + 1]; c++); ****} while (d && c < X - 1); ****if (d) { ******putchar ('\t'); ******for (c = X; c > 0;) printf ("%2d ",list[--c]); ******printf ("\n\nYou ordered the list in %d moves.\n", turns); ******if (turns > X * 2 - 3) ********printf ("But it shouldn't have taken more than %d moves.\n" , X * 2 - 3); ******if (turns <= X) ********puts ("Wow, you are either extremely good, or extremely lucky."); ****} ****printf ("\nWould you like to try another? (y/n) : "); ****while (!isalpha (yn = getchar ())); **} while (yn == 'y'); **puts ("Good bye for now then!"); **exit (0); } Well, that's it. But this is not the end! Cymon's Games may slow down for a while, but there are games that either need to be rewritten or written in the first place. Plus, I need to install Borland and try making my programs work on that. Any questions you have, any improvements, this topic isn't closed. Do you have your own games you want to contribute? Feel free! So what do you have to look forward to? Now, don't go requesting one or the other. I'll get to them when I get to them. But here's a few games: Complete but didn't make the list (usually because they're pretty lame):
|
||
![]() ![]() |
|
![]() |
#56 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() Hurkle, Hurkle, where is Hurkle?
|
||
![]() ![]() |
|
![]() |
#57 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: May 2005
Location: Aurora, United States
Posts: 606
|
![]() <div align="center">Hurkle</div>
I mentioned that this isn't that great a game. Well, at least it's short. So what is a Hurkle? Why do we hunt them and their cousins the mugwumps so? Why do these elusive prizes inspire such games of hide and seek? What does a hurkle or mugwump look like? In this game the Hurkle has evolved from it's original incarnation and has gained the power of flight. Thus you must find the hurkle not just in x and y, but in z as well. Code:
/* Hurkle hunt in 3D * by Joseph Larson 2005 * Inspired by a BASIC program by Bob Albrecht * as found in 'BASIC Computer Games' edited by David H. Ahl (c) 1978 */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <ctype.h> #define MG 10 #define SIZE 10 int main (void) { **int hx, hy, hz, x, y, z, c; **char yesno; **printf ("Hurkle Hunt in 3D\n\n" **"A hurkle is a cute little creature, that in this game can fly. The hurkle\n" **"is hiding in a region %d x %d x %d. After every guess your special hurkle\n" **"locator will tell you which way you need to go. Keep in mind that 1,1,1 is\n" **"the lowest northwest corner.\n", SIZE, SIZE, SIZE); **printf ("Input your move by typing the x then y then z coordinate seperated\n" **"by commas like \"1,2,3\"\n\n"); **srand (time (NULL)); **do { ****hx = rand () % 10 +1; ****hy = rand () % 10 +1; ****hz = rand () % 10 +1; ****printf ("The hurkle is ready."); ****for (c = 1; c <= MG && !(x == hx && y == hy && z == hz); c++) { ******printf ("\nWhere do you want to look? (X,Y,Z) : "); ******scanf ("%d %*c %d %*c %d", &x, &y, &z); ******printf ("The hurkle is "); ******if (y < hy) printf ("south"); ******if (y > hy) printf ("north"); ******if (x < hx) printf ("east"); ******if (x > hx) printf ("west"); ******if ((x != hx || y != hy) && z != hz) printf (" and "); ******if (z < hz) printf ("up"); ******if (z > hz) printf ("down"); ****} ****if (c <= MG) printf ("HERE!\nYou found the hurkle!\n\n"); ****else printf ("\nThats %d trys and you didn't find the hurkle.\n" ******"The hurkle was hiding at %d, %d, %d.\n\n", MG, hx, hy, hz); ****printf ("Would you like to play again? (y/n) "); ****while (!isalpha (yesno = getchar())); **} while (tolower (yesno) != 'n'); **printf ("Good bye for now!"); **exit (0); } However, there's hope that in your home the hurkle will find more love than he has found in mine. |
||
![]() ![]() |
|
![]() |
#58 | ||
Join Date: Feb 2006
Location: Velika Gorica, Croatia
Posts: 117
|
![]() I see that this is a dead thread, and even though I don't have any intentions on reviving it, I read all of it, and I just had to post this thankyou message. You see, I am an wannabe programmer, and at school, I'm trying to qualify myself on the ACSL, but lately I've been losing enthusiasm for learning and practising, and this thread was exactly what I needed to give me a little bumb ahead. After reading thru all of these programs, even though I work in c++ I understood most, I'm going to get to work, and advance to the recursion problems I just can't get... Again, thank you...
__________________
Founder of F.A.G., Free Abandonia Group |
||
![]() ![]() |
|
![]() |
#59 | ||
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2007
Location: ,
Posts: 35
|
![]() Thats really cool. My dad learned me Visual Basic and the BASIC dragon 64 uses. I have learned some Macromedia Actionscript to. And a bit GLBasic.
I'm 13 :P |
||
![]() ![]() |
|
![]() |
#60 | ||
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2007
Location: Nunspeet, Netherlands
Posts: 31
|
![]() These are some very nice examples. I didn't try them all, but the ones I tried all worked good.
I have only one piece of advice. If you write code with the purpose of sharing it, it is a good practice to add a lot of comment to the code, so others can read it easily. Especially when it is about complicated algorithms like the AI in some of the games. I also wrote a version of battleship in VB and it is nice to see that you use the same algorithm. |
||
![]() ![]() |
|
![]() |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Happy Birthday Guesst | Japo | Birthdays & Celebrations | 8 | 06-07-2007 09:50 AM |
Happy Birthday, Guesst | Shrek | Blah, blah, blah... | 10 | 08-07-2006 09:31 AM |
|
|
||
  |