|
|
|||||||
| About Us | Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
The game of life 'C' Project
WARNING!!!
If you're not interested in C or programming, leave this thread now. This is for computer geeks only.Anyway, the school I'm currently attending gave out a cool project in my CMSC 201 class where I had to make a "Game of life." For a complete project description, visit this page, http://www.csee.umbc.edu/courses/und...2/projects/p2/ . Now I'm not asking you guys to help me (besides, it's too late to give in the project). I just want to know if anyone can reproduce some nifty looking code using the program. BTW, you are gonna need a file full of ones and zeros. I want to see who can come up with the best algorithim. ![]() Good luck! And don't go off-topic! (No pun intended)
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 Last edited by AtomicFeline; November 28th, 2002 at 02:07. |
|
|
|
|
|
#2 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
hehe... Can I get a moderator to move this to the Programming Section?
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 |
|
|
|
|
|
#3 (permalink) |
|
Administrator
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Nov 2001
Location: Kuala Lumpur, Malaysia.
Posts: 7,686
|
>> hehe... Can I get a moderator to move this to the Programming Section?
Done.
__________________
Kellicros' DeviantArt |
|
|
|
|
|
#4 (permalink) |
|
Banned
Join Date: Oct 2001
Location: Soviet Canuckistan
Posts: 0
|
Looks interesting. If I hadn't spent 10 hours coding today already, I might be breaking out my compiler right now.
![]() But alas, my assignment was due, and I spent a long time working on it. Now I am tired and sleepy.
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
Would it help if I posted my completed code?
[EDIT] - How would I go about attaching it?
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 Last edited by AtomicFeline; November 28th, 2002 at 14:23. |
|
|
|
|
|
#6 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
Nevermind. I found out. And don't be afraid to look at the code; it's well commented.
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 |
|
|
|
|
|
#8 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
Actually, yes. The "game of life" has been made a billion times, but it is still fun to make. You may have heard it by the name of Lifegen, NextGen, or simply the "game of life." I want to see if someone can make some mean looking code.
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 Last edited by AtomicFeline; November 28th, 2002 at 17:50. |
|
|
|
|
|
#10 (permalink) |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2002
Location: Vienna/Austria/Europe
Posts: 1,168
|
bad style:
<pre> int boolean = FALSE; </pre> boolean is a type (like int or float) in other programming languages, should not be a variable name. ValidateNeighbors does next to nothing, but takes a whole page on the screen. AddNeighbors takes 73 lines for something that could be easily written in 2 lines. Instead of using 2 arrays alternately, you copy the whole array for every iteration. Sorry if this is a bit harsh, but it looks like someone was very busy creating lots of code, as if you were paid per line of code. Look at ammoqlife.c: Granted, I was a bit lazy with comments, but it's a total of 91 lines. I use 2 arrays alternately, so I don't have useless copy operations. My arrays are larger so they include an invisible border of zeroes; this way I don't need range checking for the board. Input is done in strings like that: <pre> X X X XXXX </pre> This way I can use the output of the game as an input for the next game. Maximum number of cycles and output interval are command line parameters. (You see, I arbitrarily changed the input format a little so a non-programmer cannot use it unmodified for your assignment. There is nothing wrong the way your program does the input.).
__________________
If you think my English is bad, wait till you read my Polish. Last edited by ammoQ; November 28th, 2002 at 23:00. |
|
|
|
|
|
#13 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
Good job, AmmoQ. But then again, I'm still in college, and I haven't been in a course that teaches optimization.
BTW, the array with zeros as the boarders was probably the thing that sped up the program the most. By doing that, you had the right to simply add all the neighbors without checking. I didn't get it when you use two arrays alternatly. Can you explain a little? (My class webpage said that the program required copying arrays. Although I wish I thought of several of the things you did.) [EDIT] - Oh, I get it! You made the calculations and applied it right into the array that you are going to print. That way, you don't need to copy the changed array into another one. It makes me wonder why I got a good grade on the project. And you're right about the boolean thing. I at least have potential, right?
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 Last edited by AtomicFeline; November 29th, 2002 at 14:33. |
|
|
|
|
|
#14 (permalink) |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2002
Location: Vienna/Austria/Europe
Posts: 1,168
|
Hey, you did a good job! Your program works well and it is readable and well documented.
It's just that in some parts you wrote lots of code for very simple operations. But sometimes it takes a lot of experience to see the short way. Keep on learning, I'm pretty sure you have potential!
__________________
If you think my English is bad, wait till you read my Polish. |
|
|
|
|
|
#15 (permalink) | |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2002
Location: Vienna/Austria/Europe
Posts: 1,168
|
Quote:
__________________
If you think my English is bad, wait till you read my Polish. |
|
|
|
|
|
|
#16 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
How do you know which array to display then? First you change one array using the original and then you change the original using the changed one, do you modulus the amount of times you use the algorithm by two and if it's one then display one array and if it's zero then display the other? (Sorry for reviving the thread, but I really want to understand).
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 |
|
|
|
|
|
#17 (permalink) |
|
Emu author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2002
Location: Vienna/Austria/Europe
Posts: 1,168
|
it's these lines:
<pre> s=!s; ... output(currentTime, b[s]); </pre> the first line toggles s between 1 and 0; the second generates the output from the array choosen by s.
__________________
If you think my English is bad, wait till you read my Polish. |
|
|
|
|
|
#18 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
Interesting. If 's' is 1, then !s would be zero, right? Pretty cool.
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 |
|
|
|
|
|
#19 (permalink) |
|
Single
![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2002
Location: Norway
Posts: 667
|
I was able to create something in Delphi. and it works! if anyone wants the source, then ask me.
I added a random button to generate X-es (1's and 0's) at random.
__________________
This is my new improved sig. |
|
|
|
|
|
#20 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() Join Date: Aug 2001
Location: Maryland USA
Posts: 569
|
Delphi? Never used it. Can you show a bit of the source code?
__________________
Feline Visit my deviantart page: http://atomicfeline.deviantart.com 1.4 Ghz T-Bird Athlon PNY Geforce4 TI4400 AGP 128 Meg DDR 512 Megs DDR ram Ensoniq Audio PCI 32X CD-ROM Windows XP SP 1 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|