http://img.photobucket.com/albums/v6...Cymon/logo.gifButtons (hey, you come up with a better name then...)
The game in my sig, as I said, is a smaller, stripped down version of a bigger program. The code has been formated in a less readable format so it fits in as few lines as possible. I actually made 2 version of this. The other version is 7 lines, has better looking graphics, but only 1 solution. However, this actually makes a better intro game, so I'll post it here: Code:
#define z printf Code:
**********...** ...** ... Code:
******** +===+ +===+ +===+ Well, the 5 line version below looks a bit different but plays similarly. I'll repost the code here incase I change my sig: Code:
int n,d[2],m[9]={27,7,54,73,186,292,216,448,432};p(){int c=6,k=0;puts("");for(;c Code:
789 *.. Code:
7.. *.. So there you go, an explination of my sig and a teaser for future programs to come. Feedback is welcome and if you all like it I'll post more of my super-cool C programs. For anyone who wants a more readable version of the game, here it is: Code:
/* Buttons Code:
**bd = rand () % 0x01FE + 1; Code:
**bd = rand () % 0x01FE + 1; goal[lv] = rand () % 0x01FF; |
Please post a few more.
Did you try to optmize your programs for speed as well or merely fo as small as possibl ? You don't mention the header files that are needed and getche isn't available at my place. |
<div class='quotetop'>QUOTE(Data @ Jun 5 2006, 10:12 AM) [snapback]234432[/snapback]</div>
Quote:
Header files are unnecessary. everything is kept in the single file. just be sure to name it with a .c instead of .cpp and every complier I've used can handle it. (Even M$, although I've only complied in a windows environment. If your complier is different, let me know.) As for getche(), that is a non-standard function. But all of my programs are designed so that getche () can be replaced with the ANSI standard getchar() and (1) still funciton and (2) not consume any more space. (I leave a space after getche_ for the extra letter in getchar every time.) No, my programs are not optimized for speed. For programs as small as this that's kind of silly. Besides, I'm not very good at optimizing for speed. more programs to come... |
So, which one to continue with? I'll start with a small one and move on to a somewhat bigger one, then let you all choose.
Jumping Balls (please hold back the grade school snickering) What inspired this little programming spree was when I found a couple of old books of BASIC programs that I would read in High School. Of course, by High School BASIC was a thing of the past, so all I could do was read the programs an imagine how cool it'd be to play them. So when I found the entire text of both books online years later I decided that I would like to finally see these programs run. Only, instead of whipping out gwBASIC (or whatever) I'd convert the programs in it to C! One of these programs I found such a suscinct way of expressing in C that I decided to see if it would fit in a sig. It did, and in 3 lines no less: Code:
main(){char b[11]="\toooo.OOOO";int e=5,n,t=0;puts("\t123456789");puts(b);for(;n In a a perfect game you can win in 24 moves. How well can you do? Below is the full, more readable, and longer more compelte version Code:
/* Jumping Balls |
Interesting how compact source code can be, even though I have a different view about what "minimal" source code is.
What I would like to know is how long it would take you to complete such a transformation on code that you have not seen before? |
<div class='quotetop'>QUOTE(Eagg @ Jun 9 2006, 12:03 AM) [snapback]235363[/snapback]</div>
Quote:
Which is a perfect segway into the next program. Robot Escapehttp://img.photobucket.com/albums/v6...llerRobots.gif The instructions are in the game, so just read down a few lines to see them: Code:
/* Robot Escape Code:
Stunned... Press ENTER I wanted to see how small I could get it. My goal was 1K, less than 1024 characters. After much work I got it. But oh the sacrifices that had to be made: Code:
#define q(a)(a)*(a) In the 1k version there is technically no winning condition, so you can play until you are overwhelmed by sheer numbers. But Robotescape1k has a fixed max number of enemies on screen which, by the way, is 98 enemies and you makes 99. I was so crammed for space that adding one more digit to that number would have put me over. You exceed the maximum if you make it to level 24, which will consequenly crash the game. This however is an highly difficult thing to do, so consider the game beaten if you make it that far. The 1k restriction also introduced a bug concerning the conditions of winning a level where it checks to see if all the robots are dead before checking if you are. In other words, if the last robot(s) kill themselves upon you, you still win and move on to the next level. Ah well, such is the price of this sort of pursuit. However, it can be a strange sort of satisfying to win by kamikaze / jihad / whatever. .:EDIT:. CRA...UD. I wrote this ages ago and just noticed in the last line that "if(w)" can be removed, saving me 5 characters meaning I could take the game up to 9999999 on screen characters, more than the screen can handle, erradicating the level 24 cap. Meh, screw it. I never survived past level 16 myself anyways. |
I would give a Toe to understand this.. :wallbash:
|
Poll at the end of this post, don't forget to vote!
<div class='quotetop'>QUOTE(U-Boat Commander David @ Jun 9 2006, 04:25 PM) [snapback]235479[/snapback]</div> Quote:
Sound like too much work? Hey, you wanted to give up a toe. If I just take the pinky toe you have to learn how to walk all over. You think you don't need it, but it's got so much to do with balance. Trust me, typing a few tried and tested programs is easier than learning how to walk again. So what program should I do next? Maybe I'll let the people decide. Here's the list of possible choices:
|
May I ask why you chose C and it's old-fashioned procedural programming paradigm over more modern ones such as OO? Mind you, I can appreciate the beauty in an obfuscated piece of C-code (although as a Java guy, I really hate doing memory managment myself), I was just curious.
|
4 in a row please.
Interrested in seeing the ai part especially. Reup OO is a way solving the problem. not the way. there is nothing wrong with procedural programming I think. OO was overrated in its hype. (which fortuntaly has a passed a bit) |
As I recall I didn't say there was anything against procedural programming, only that it was more old-fashioned then OO. I'm also aware that it's not the only and best way. I was merely asking about guesst preference.
Maybe we sould start a 'which paradigm rocks donkey-balls' thread to discuss the benefits of each one? |
Boys, now, let's calm down. No paradgm bashing here.
@ Reup, you haven't voted. I chose plain C because it's a place to start. In fact, it's where I started. I was esentally going back to my roots. The plan was for me to write a few programs in C, then move on to CPP. However, it didn't last that long. When I started getting ready to do Wumpus in CPP, an exelent program to do OO, and life got in the way. That was a few months ago. Some day, soon I hope, I'll be able to finish what I started and show some CPP programs. Then I'm going to start simple graphical programs, then take over the world. |
Well, I've gotten a single vote and that's probably going to be it. So here you go, by popular request:
Four in a Row This was a algorithm adapted directly from a BASIC program and is uniquely frustrating because I've played it tons of times and only beaten it once. The page in the link for the BASIC program above explains a little bit about the procedure the computer takes when making a move. I'll explain a bit after the code. So without further ado: Code:
/* 4inarow How the computer makes a move. First of all, the board data is maintained in strings so that outputting the board is simply a matter of coughing it up. At the top there is an array called v that has a bunch of wierd number in it. Those numbers are the ranking assigned to the successfull creation of 1 in a row, 2 in a row, 3 in a row, and (altho unnecessary because it's an automatic "take it") 4 in a row for enemy first, then self. The compmove routine is called when it's the computer's turn to move. It virutally drops it's oppoenets (your) pieces in each slot, and adds up the rank of each move. Then it virtually drops it's own pieces into each slot and adds up the rank of each of those moves. Assuming that it didn't find that any move made 4 in a row (either pass), in which case it automaticly does that move, it then compares all the possible moves and chooses the highest scorer. And as usual, I already see things I'd do to change it. Ah well, that's programming for you. So come one, come on. Let's choose the next one. One responce with a choice, one program till we're done.
|
Okay. Now do 'joust' :D
Btw, where you say logarithm, don't you mean algorithm? :unsure: |
<div class='quotetop'>QUOTE(Reup @ Jun 13 2006, 06:56 AM) [snapback]236324[/snapback]</div>
Quote:
So, Joust you say, eh? This game was another taken from a BASIC game of the same name (from the second book of BASIC programs). It's kind of a choose your own story with a weighted random. On some of the BASIC programs I converted my attempt was to duplicate the algorithm of the original game exactly, so as to experience the game as it was meant to be played. On this one, however, I couldn't resist making a few small improvements. First of all, the original game had a bug that would allow you to choose defense options that were not shown if you knew their number. Fixed. Also in this one, if you mightaly unseat your opponent your next opponent (unless it's the fearless black night) will bow out. Buy why am I just talking about the game, I should show it to you: Code:
/* Joust Code:
Joust Next?
|
Quote:
And I vote for 3DMaze to be posted here next. ^_^ |
Hey, 13 out of 40 in a competition where no morons are allowed isn't bad. You were doing well just to get in.
3DMaze This is a real cool one. Taken from yet another entry in the International Obvscated C-Code Contest (another exelent place to find C-Code examples written by people better than me). Sean Barrett's winning 1991 entry drew an ascii representation of a first person view through a maze. For the maze the program read it's own code in and used the whitespaces for floor. Clever, but not very dynamic. So I decided to make a random maze generator and attach it to the drawing algorithm. This meant I had to take code that was not formatted for reading and reformat it with variables with understandable names and everything. It was an interesting way to figure out how this extremely clever routine worked. The final result is uber-cool and looks like this: Code:
****\****************************************** / Code:
/* 3DMaze The constants WALL, UNSEEN, SEEN, TRAVL, and EXIT are for the map. When the maze is generated you have WALLs and UNSEEN everywhere and EXIT at the end. As you see an area UNSEEN becomes SEEN and as you go there the spot you stand on becomes TRAVL. That way at the end you can see what path you took through the maze. The maze generating algorithm doesn't make paths through the maze or anything. It just makes sure you can get anywhere from anywhere else one and only one way. It connectes two spaces with a numbered path. If two paths are connected the higher number over rides the other path so that if it wanto to join two areas it only needs to be sure they aren't of the same path, meaining a loop would be generated. A hole is punched in the left side for the exit. I had considered having a square maze, dropping the player in the exact middle, and punching one hole in any of the outside walls, meaning you could wander the wrong direction for a long time before getting out. But I decided against that for a straight east to west progression to make it less diabolical. Besides, a square map of more than 11x11 would not show well on the map printout. This game is so cool I absolutely recomend downloading DevCPP and playing this one. It's a hoot. I wanted to include the executable here, but the boards don't allow it. But you have the code, so go on with you. So there is 3DMaze. What's next?
|
Awari, Awari! (since I don't know what a learning a(?)lgorithm is, and would like to see :D )
|
I don't want to post two in one day, so I'll just say (1) thanks, I missed that one. And (2) did you even play the maze game yet? Tell me what you thought of it.
|
http://img.photobucket.com/albums/v6...ymon/Awari.gifAwari
Awari is an ancient African counting game. Each player has 6 places with 3 markers or stones in each to start and an empty home. A move is made by taking all the markers from any non-empty place on your side, then sowing the markers one at a time in a counter-clockwise direction around the board. If the last marker sown lands in your home then you get a second move. (No more than two moves in one turn.) If the last marker is sown in an empty spot and the spot opposite is not empty then you capture the last marker and all the markers in the opposite spot. When either side is empty then the game is finished. Another conversion of a BASIC program of the same name. In the original the board was layed out left to right, more like one would play it in real life. I thought that was a bit confusing so I wrote a new version (just this morning) which layed things out top to bottom. I'm not sure it's that much better so I kept the original version but commented it out. So here we go... Code:
/* Awari */ The list gets shorter every time! This time I added one I had forgotten however.
|
<div class='quotetop'>QUOTE(guesst @ Jun 14 2006, 11:52 PM) [snapback]236864[/snapback]</div>
Quote:
This games will be very useful tomorrow at school, and will certainly make the 10 year olds also studying C++ with me have some fun...and ask the teachers how they were made again and again and again. Poor teachers. Oh, and are the games made in C, or C++? In C++, I had to add an extra library for getche for the game to work, and I also got the warning that int main(void) should return a value. Couldn't you have used void main instead of int main(void)? Mugwump is what I would like to be posted next. (meanwhile I have to try the other games) |
Hi im kinda new to this, but you recommended this thread to me in one of the game threads, i think othello, so im about as nooby as a noob can possibly noob, so bear with me here. :D I reckon this would be the most amazing thing to be able to do, and to able to do it good would be awesome. But everyone has to start off somewhere, dont they? Anyways,
i have a few questions to ask you. First of all, in the tutorial they gave me in with the C++ program guides me through the "Hello World" program and ive already typed it in and compiled it and everything, but every time i try to run it I see the command prompty kinda box pop up for a fraction of a second then just disappear. And it does this everytime. So i went a bit further to find out about loops and put a neverending loop in, and it worked perfectly, the box came up and a neverending greeting to the world flashes down the screen. But i cant work out how to do the simple one line one. Any hints? Secondly, ive been through a couple of the programs you have posted here but every single one is rejected by the compiler, and of course, having not even been able to configure the Hello World program correctly, I cant work out what is wrong with them. On a smaller note could you try to explain the integers and floats a bit more coz i cant make head nor tail of them. Thanx :) |
<div class='quotetop'>QUOTE(#BlakhOle# @ Jun 16 2006, 01:30 PM) [snapback]237123[/snapback]</div>
Quote:
Code:
#include<stdio.h> <div class='quotetop'>QUOTE(#BlakhOle# @ Jun 16 2006, 01:30 PM) [snapback]237123[/snapback]</div> Quote:
<div class='quotetop'>QUOTE(#BlakhOle# @ Jun 16 2006, 01:30 PM) [snapback]237123[/snapback]</div> Quote:
|
So much to reply to! Warms my heart.
All of the programs posted here are in ANSI standard C, that is to say, not C++. If you want to eliminate some of the problems your complier is having with them, Abi79, save the files with a .C extention (not .cpp which is probably the default) and the compiler will (generally) compile it slightly differently. @#BlakhOle# I assume you're using DevCPP that I recomended at the start. Yes, "hello world" does come and go quickly. The problem is that when the program runs it opens a window, does the output, and closes the window before you get a chance to see what happened. There are two ways around this. One is to add the line Code:
**getch();getch(); PS, Albi79, your hello world is not technically C++ code. It's a kind of bastardized hybred. A proper C++ program would use streams like this: Code:
#include <iostream> Back to #BlakhOle#'s question, as for getting the programs here to work the first thing to do when you compile them if they don't run is look at the frame that pops up at the bottom. It will give you any warnings or errors that may be impeeding the execution of the program. If you can't make heads or tails of them tell us which program you're running and post the error here and we'll see if we can't help out. Ah, floats and ints. Well, there is a simple answer and a more complicated answer to that. Most books will take the complicated answer, explaining the inner workings of your computer and whatnot. I'll take the simple one. char, int, and long are all the same thing in that they can be used to store only whole numbers, that is to say no decimals, no fractions. 1, 2, 3, 100, 121, etc. The difference in them is that a char can only hold number less than 256 if unsigned or between -127 and 128 if signed. It's very limited but works for certian things very well. Ints can hold bigger numbers than a char. Use them for your regular counting. Longs are for when you may need a really big number. If you try to put a number that's too big into a variable that can't hold it all sorts of wonky thinks can happen. float and double are for holding numbers that may have decimal values. 1.1, 5.6, 10057.3, 3.14159, etc. Decimal points are a tricky thing for a computer to handle, so it's recomended that if you can do the job with whole numbers not to use floats as you're only going unnecessarly bog down your computer. Well folks, I have an eye appointment, so that's all the time I have for now. Maybe I'll do mugwump later, maybe not until tomorrow. If you have any more questions, you know where to find me. Ta |
<div class='quotetop'>QUOTE(Abi79 @ Jun 16 2006, 01:47 AM) [snapback]237089[/snapback]</div>
Quote:
|
Ok lets see whats worked here... first of all, C++ doesnt seem to like the getch(); command much, the compiler log comes up with
Quote:
The program you fixed from abi also worked pretty well, dunno how though. :P Apart from that all seems well, except from the fact i still dont know what everything means. Back to the HELP file i guess... PS @abi: Actually i dont hate C++, but i might like it a bit more if it was a bit more self explanatory :bleh: |
Got time for some quick responces. You never confirmed which compiler you're using. It would be helpful in the future to know what program you're working form.
As for getch() being no-go, okay, try getchar() or my personal favorate getche(). Getch is a non-standard function so it behaves differently, if it's there at all, between different compliers. Getchar is the standard version that all of my programs are written to be compatible with. However getche, unline getchar, doesn't wait until you hit the enter key before moving on. Getche will just take one character and run with it. void main () is possible on some compilers, but is extremely bad form like plix said. Always have int main() and to be completely compliant alway use return(0) at the end of the program to indicate a successful run. (Potentially you could exit with a non-zero value to pass information like error messages to external programs, but that's mostly a Unix thing.) So, to sum up:
Mugwump This is a good game to show the difference between ints and floats that we were just talking about above. In 101 BASIC games and it's successor there were numerious hide and seek games played on a grid where by various means the player was given hints as where to find whatever ridiculous creature they were hunting for. Of all of them Mugwump was perhaps the most intersting of them. Instead of directional hints this game gives the distance to your targets. In an improvement over the original this one sorts the resultant distances so you don't know which ones are for which any more. Also, there's a timing loop that simulates a distance reading machine of some sorts with the output. Check it out. Code:
/* Mugwump Hunt If you change the constants NUM and SIZE at the start of the program you can easily adjust the difficulty of the game. Enjoy! And the winner for best supporting gaffer is...
|
<div class='quotetop'>QUOTE(#BlakhOle# @ Jun 17 2006, 06:36 AM) [snapback]237264[/snapback]</div>
Quote:
As for guesst, Hammurabi, Hammurabi! :D |
http://img.photobucket.com/albums/v6.../hammurabi.gifHammurabi
Not feeling like typing much today. But your wish is my command. Once again this is a BASIC program that got the C treatment. Follow the link if you want to know more. .:EDIT:. I'm feeling like typing more now. While I realize no one is going to take the time to read this, I'm posting it any ways. Hammurabi borrows it's name from the Babylonia ruler who is famous for setting up a standard of laws and punishments. By "setting up a standard" I mean he literally built an 8 foot tall black stone monument, clearly meant to be placed in the center of town. There was no excuse for not knowing the laws in Hammurabi's reign, because they were before you day and night. In this way it was believed that Hammurabi kept order in his town. Now it's your chance. See if you can expand your land and grow your population in a 20 year reign as king in this exciting simulation game. Code:
/* Hammurabi Keep 'em comming
|
Oooh, Awari! My dad has a beautiful Awari board he got when he was in Africa - 's a great game.
|
@Beefonthebone - You should try this one. I think you'll find that even before it starts learning (which it only does when it loses) it'll regularly teach you a thing or two about playing the game. It's quite fun.
Without provocation or invition I will choose the next game, since no one cast a vote. Plus if all goes well I won't have time tomorrow... Stars/Trap/Letter Guess Oh yeah, 3 in one today. These games are all kind of variations on a theme. The sort of "guess what I'm thinking" games that entertained me so as a child. I figured no one would vote for these so I'm picking them before they're the last left on the field. The benifit to these games is they are extremely simple and therefore extremly short. This is the sort of game that if you're writing your first game you'd want to write. (Not sure that came out ...good.) Two out of three of these are adapted from BASIC programs. I've linked the book that I got them from before, so I'm not going to worry about it now. I cracked all of these out in about a day. The challange was to not make them all look like I just edited a few lines between them. As they stand I'm not sure how successful I was at that. They all consist of only a main function and a few loops. They were just so small it seemed unnecessary to strech them out more than that. They are also so abstract that, besides "Stars" I had nothing with which to make an illustration of. I haven't made illustrations for all of them, but the point is how would I even illustrate the first two? Ah well, here we go: Letter Guess. This is the "higher/lower" sort of hint system. There exists a well defined method for finding the subject in question in the least number of guesses, so the game will actually tell you in the end if you took too long. Technical note, I had actually inlined the BEFORE/AFTER bit, but took it out because as simple as the program is I didn't want to confuse new programmers with what is really a pretty odd looking bit of code. Code:
/* Letter Guess Game Code:
/* Trap Code:
/* Seeing Stars */
|
Cel Life, John Conway's Life was awesome.
|
Battleship looks good.
|
@Abi79, you've gotten to pick the last few. I'm letting Blood-piggy choose. (Besides, he was first.) If no-one steps up after this one, then you're in the queue.
Cell Life A Google search for John Conway's Game of life will provide more information on this than you ever wanted to know. (Wiki is also a good source) Without taking up too much space, John Conway came up with a game that seems simple but in the end has proven to be the playground for the intelectual. The game is played on a grid, like a checker board. Markers are placed on the board. Then every "generation" the pieces live, die, or are born according to a simple set of rules:
Here's a screenshot of a small three player game in action: Code:
**12345 Code:
************111111111122222 Winning this game is a challange. Every turn the players rotate through who goes first. Going first is not an advantage because it's all to easy for your opponent to turn a birth into an overcrowing after they've seen what you're doing. However, this was the only way to insure that the game is played fair since, in this form, having everyone choose their move unseen isn't possible. Both methods have their advantages. You can set the game for 4 computer players and just watch it go. This in and of itself is not uninteresting to see. But if you can master predicting the next generation just feel your brain grow. Silly me, I haven't given you the code yet! Code:
/* Cell Life This is a game that would probably be better suited to something more graphical. In this form it's a bit hard to play. But then again, if you're the sort of person for whom Conway's Game of Life holds your interest something like console graphics is no turn off. Abi put in a vote for Battleship next, and since i love my regurar reader (wish I could put an 's' there) that'll probably be next, but feel free to queue up your preference :
|
Sorry, I've been at school all week, so I've been unable to update with this program. But maybe absense has mad all yawl's hears go fonder. So you should be very excited to finally have...
Battleship This is the biggest program that I have to contribute. However, it is a game that should need little introduction. Battleship. Place your ships, hunt theirs, hope you win. The computer plays against you on this one. The routine for choosing where to shoot is not the best out there, but it's not entirely stupid either. Here's what the game looks like in play: Code:
Your shot coordinates : f9 So why don't we just get to the code: Code:
/* Batttleship (R) Now, if a clever programmer out there want to try to make a smaller version of this, go say for it. I'm actually disapointed with how humongus this is. This, Awari, and Cell I wish I could reduce a bit. Now is when I beg you for you support. How do you support this great project? Just choose a program from the following list and tell me you want to play it. Because as long as this has got your support we're not stopping until the list is empty:
|
There's a small lil' problem...or maybe two problems.
1. Even if I've saved the file as a *.c, when I tried to run it in BorlandC++ for DOS, I got the following error message: "Lvalue required" at Code:
: bd[s.x + d * step.x][s.y + d * step.y].pship = c + 1; Setup: auto At the fleet screen, I couldn't see any of my ships. I've ignored that and chosed to attack c5. Of course I missed (I always lose in games :P ), and the computer started it's turn. But nothing happened. Following the using of the ingenious key combo CTRL+Break, I managed to see that the computer entered a loop. Code:
int hit_no_sink (int x, int y) { Code:
if (hit_no_sink (c.x,c.y)) {** What might cause the problem? |
I guess this means I have to install Borland compiler. I know it workes in DevC++ because the screenshot you see is taken from an on-the-fly compile of the exact code that got copy/pasted into the post.
It's true, tho, that not all compilers are the same. I've known this for some time. I can't promise I'll be able to get to this any time soon, so until then, what's your next vote for the project? |
Sorry for the late reply. I was a bit busy. :(
Anyway, my next vote is Black Box. |
I'm trying to make up for all the things I promised I'd do but haven't yet done. I'm such a slacker and Cymon's Games has suffered.
Not that anyone but Abi79 even cares. But, in Pennance I bring you today: BlackBox Unfortunately there are better games I could have done my pennance with. This game isn't particularly cool to see played. To get the most out of it you should really play with a piece of graph paper next to you to take notes on. The purpose of the game is to discover the location of 6 spots in a 10x10 field. You can't see the field (it's covered) but you can shoot rays into it and observe where they exit, which will tell you likely places where the spots can be found. The game actually contains pretty detailed instructions on how the ray reacts to the spots, so I'm gonna let it do all the talking: Code:
/* Blackbox or AtomSweeper This is a game of solitare where the object is to perfect your technique to get the most acurate reading with the fewest hints. If you find 6 spots on a 10x10 field not to your liking, the code is very happy, if you change a few constants at the top, to customize for you. Now, I know it's been a while, but the problem was I didn't have my programs with me, and darned if I was going to waste my weekends with my wife and kids on the computer. But now I have the programs with me at school and nothing better to do all day long, so expect the rest of the list to fly by. Only a few left. Make your choice or, if no one chooses, I'll choose for you. But as always, I love your feedback!
|
Sorry for answering so late, but something happened to my Internet connection. The good part is that today, when I called the customer support, the one who responded actually knew what I was talking about, and in 30 minutes my connection started working again. Romanian Data Systems rocks. :P
I choose...FlashCards. Me likey math. :D |
<div align="center">FLASH CARDS</div>
The name says it all. This is a perfect oporutinty to practice your basic math skills, addition, subraction, multplication and division. At the end of your session (defined in length by the NUM constant) your score will be added up and you will be assigned a grade. Flash Cards uses binary data, encoded in decimal form, to make the shapes of the form. Take the data listed in the shape array at the top of the program, write them out in binary form (1's and 0's) and stack them on top of each other to see how it works. The drawline routine is the one that decodes the data sent to it. A line variable is loaded with what each of the 6 characters per line will be. Then it looks for that numbered shape in the shape array and uses that data to output the numbers. #20 is blank, because #0 is the number 0, so that #1 can be 1 and so on. After 0-9 comes the plus sign, the minus sign, ect, two equals signs, the strike icon (for when you get an answer wrong), three icons for when you get an answer right, and finally the blank space. For fun, change the data in the shape array and see if you can't make your own style of numbering! Code:
/* Flash Cards Code:
****v = (rand () < RAND_MAX / 2); Code:
****v = 1;
|
You love us? Oh, my... *faints* :P
As for this program, I was pretty impressed by the flag made out of "right" and the numbers made out of, well numbers. (I would have made them all by hand :D ) Still, it took me some time to understand that those were numbers...but I got it in the end, when I switched from Full Screen to Window. Another friend of mine had the same problem with the Maze. He just couldn't understand what those lines (the wall) were. :P (and he had never heard before of Fog of War, so he didn't even know why the map wasn't revealed to him; poor guy...) As for the next program...Hangman is what I choose. |
<div align="center">HangMan</div>
Now, whenever I'm at a loss for words, the worst that happens is I make a fool of myself. However, in HangMan being at a loss for words is a life and death stuation. In this game the "graphics" are designed so to take up the fewest lines of code. Consequently it can be said that they suck. In order to see a fully hanged man you need to tilt your head 90 degrees to the left. Here is what the fully hung man looks like: Code:
****************** O || If you don't like the way the graphic looks you can re-write the drawgallows() routine yourself to draw the gallows according to how much of the player is left. 10 is hung, 0 is empty. Post your drawgallows routine here if you make one! (I know I'd love to see a better one.) Code:
/* Hangman And NEXT?
|
Woohoo, finally some motivation to get back into c/c++. If I may say this in my case at all. I donŽt believe that I ever came way further than the silly "Hello World" program :whistling:
Indeed I got a little bit deeper into C of course. But I never made programming to a great passion although I always liked to. Maybe I was to layzy and easygoing, maybe I was absorbed with other things. "Anytime I will try to program every day a little" I thought to myself. And who knows: probably IŽll get my spurs in here. In any case I have to take my hat off to Guesst :kosta: |
And if you write something, anything silly, dumb, creative, or awesome, post it here. That's what I started this project for.
I've been thinking I want to start up the Cymon's Games website in the next year or so. These games will be the first, but hopefully there will be enough people submitting that by the time they run out I'll have a ready flow of incomming programs. So who knows, DonCorleone, you may be the first, getting in on the ground floor of the future new thing on the Internet. Actually, it's a little below the ground at the moment. And it may never be built up. But stay tuned. |
Well, since no one voulenteered a game they'd like to see, it's my turn to pick. And I pick...
<div align="center">http://img.photobucket.com/albums/v6...mon/rotate.gifRotate</div> Remember those little sliding puzzles where you'd win when all the pieces were in order? I loved those games. I was a wiz at them. This game has a similar concept. Once again I must kaotao to the BASIC program this game draws inspiration from. A 4x4 block of letters have been scrambled. In order to unscramble them you rotate 4 at a time clockwise. Thus there are 9 overlapping areas of rotation centered between each block of 4 letters. Code:
********A B C D A proper scrambling routine would take an unscrabled board and rotate pieces randomly. However, this game doesn't do that. This game's rotation routine just drops the pieces randomly on the board. Consequently it is possible to have an unwinnable situation if you limited yourself to just rotating pieces. So a bonus move has been added that will allow you to swap two pieces, like taking the stickers off the rubix cube. But to make it more game like the two pieces being swapped must be adjacent and you only get to do it once (you won't ever need more than that). Code:
/* Rotate Well, Cymon's original games is drawing near it's end. There are only 3 of the original 18 programs left. So what do you want to see next?
|
Quote:
And now I pick Pickup Piles. *goes back to doing math exercises; I've got an important exam next year* |
Pickup Piles
Before you is a pile and your opponent. You can only take a certian number of pieces, and you have to take at least a certian number. Maybe you want to be the one to take the last piece. Maybe you want to take everything but the last piece. So many things to keep track of, do you have the mind to win? The frustrating thing about this game is the outcome is almost always predictable from the first move, if at least one player knows what they are doing. Thus the only way to actually win is to stack the deck in your favor. Where this game gets fun is the endless variations it provides. Playing with the settings and getting good at this game is what it's about. When you get the hang of the game and figure out what the trick is take your skill to family and friends, maybe even play this it in the bar and make <strike>a few dollars</strike> some new friends. Seeing how the computer plays a perfect game can teach you the trick. It is of course mathematical in nature, so bone up on your division skills. The computer plays a perfect game but every so often, depending on the difficulty level, it will just make a shot in the dark random move that may or may not be the right move. This can also be part of the fun, catching the computer's mistakes. Code:
/* Pickup Pile */
|
You're missing Minesweeper (at least) in the original list! :wink:
I did it with Python, somebody PM me if you want to see it. (o_O) |
Feel free to post it here or make your own thread for it.
Minesweeper in a console ap? I guess it could be done, but the input process would be tedious at best. |
Acey Ducey, Acey Ducey! :D
|
<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 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?) |
Quote:
Quote:
Quote:
|
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. |
<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 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 This game too is a BASIC adapatation. Here's the full version: Code:
/* Reverse 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):
|
Hurkle, Hurkle, where is Hurkle? :D
|
<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 However, there's hope that in your home the hurkle will find more love than he has found in mine. |
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...
|
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 |
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. |
<div class='quotetop'>QUOTE(Nitro @ Feb 21 2007, 11:15 AM) [snapback]280318[/snapback]</div>
Quote:
Basically anything considered bad practice at "good programming". This is no rant on your stuff Guesst, I enjoy your pieces. Code hacks are a bit like art... nobody claims that art needs to be userfriendly. |
<div class='quotetop'>QUOTE(Eagg @ Feb 23 2007, 03:40 AM) [snapback]280573[/snapback]</div>
Quote:
Quote:
Basically anything considered bad practice at "good programming". This is no rant on your stuff Guesst, I enjoy your pieces. Code hacks are a bit like art... nobody claims that art needs to be userfriendly. [/b][/quote] I'm a bit slow. I was busy in February. I'm still busy, but avoiding doing something else I really should be doing. Anyways, I took no offence on your comments Eagg, but Nitro has a point. My code isn't very well comented and it was designed to be shared. However, the reason for that was not well commented is that I had intended to release these to be typed in by the reader. I took my inspiration from old books of BASIC games that did the same thing (referenced several times in previous threads). As such I didn't want some would be programmer to get frustrated when he learned that 50% of what he typed was unnecessary when he finally learned what a comment was. Ah, who am I kidding. I was never good at commenting anyways. |
Cymon's Games has a new home on the web
It's unbelievable, but since this thread these programs have actually evolved into a full blown website. If you liked these programs please consider helping me promote my website.
You can see a teaser at: http://cymonsgames.retroremakes.com/ and a few clicks later you can see what it'll actually look like, or you can skip to it by going to http://cymonsgames.retroremakes.com/#main Thanks all for your support! |
The current time is 08:49 PM (GMT) |
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.