|
-
Feb 17th, 2010, 10:21 AM
#1
[RESOLVED] Game Of Life
Several weeks ago someone asked about this and I became intrigued. Since then I have made 3 different versions, one console, two forms. I kept the last one, and continue to work on it. It is stable, with a not very refined front end, so if anyone would like me to post it I will.
It includes about 130 automaton.
Reference - http://en.wikipedia.org/wiki/Conway's Game of Life
update - 3/18/2010 - Restart. When completed I'll post in the codebank and place a link here.
update - 2/28/2010 - Getting closer.
update 3/1/2010 - better drawing.
Last edited by dbasnett; Mar 18th, 2010 at 06:00 PM.
-
Feb 17th, 2010, 10:57 AM
#2
Re: Game Of Life
I'd like to see it posted, just to see how the logic flow of the program actually works.
-
Feb 17th, 2010, 11:31 AM
#3
Re: Game Of Life
Just so you know, the program takes the resources and converts them to a file in my documents.
Last edited by dbasnett; Feb 18th, 2010 at 10:38 AM.
-
Feb 18th, 2010, 07:04 AM
#4
Re: Game Of Life
@formless - if you look at the program, you might wonder why I approached the file handling in the manner I did.
I am an old programmer, so old that I remember when memory was not abundant, and you didn't have an option to read the entire file, as lines, into memory. So I did it just to see if I still had it. It would have been easier to read the entire file.
-
Feb 18th, 2010, 08:19 AM
#5
Re: Game Of Life
Heh, I made one too a few days ago just for the fun of it. Posted it in the codebank. Mine doesn't include any automaton yet though, but you can save and load grids, and it supports different grid and cell sizes and it remembers the grid before you play it, so it resets when you stop it (though you can also pause it).
It's probably not the most efficient, but it works flawlessly for relatively small grids (< 100 rows/columns) and a little slow for larger grids.
http://www.vbforums.com/showthread.php?p=3731969
-
Feb 18th, 2010, 10:47 AM
#6
Re: Game Of Life
Well, as usual, I found some flaws after I posted. So I deleted that and added the new version here.
I'll re-post the attachment when I am happy 
My PC is not the fastest, and I am seeing 30+ life changes per second with some pretty complex patterns like:
BTW - I am drawing a grid of 269 x 269 with a block size of 3 x 3 squares.
Code:
#Life 1.05
#D Rake for the Breeder
#D
#D Uses a different puffer train
#D than the other rakes.
#N
#P 7 -12
.******
*.....*
......*
*....*
..**
#P 11 -4
**
.**
**
*
.
*
**
.**
**
#P 6 -6
..*
.*
**
*.*
.*
.
.
.
.*
*.*
**
.*
..*
#P 7 8
..**
*....*
......*
*.....*
.******
#P -4 -16
..**
*....*
......*
*.....*
.******
#P -4 12
.******
*.....*
......*
*....*
..**
#P -29 -13
..*
*...*
.....*
*....*
.*****
#P -29 9
.*****
*....*
.....*
*...*
..*
#P -89 -11
..*
*...*
.....*
*....*
.*****
#P -89 7
.*****
*....*
.....*
*...*
..*
Last edited by dbasnett; Feb 19th, 2010 at 06:20 PM.
-
Feb 18th, 2010, 11:37 AM
#7
Re: Game Of Life
I am working on exposing world wrap and block size. If anyone is interested I'll post it when I am done.
-
Feb 20th, 2010, 01:45 PM
#8
Re: Game Of Life
I'll re-post the entire project when I stop changing it.
-
Feb 23rd, 2010, 07:13 PM
#9
Re: Game Of Life
The FPS calculation is off. Will fix it, and any other errors, later.
Also working on some basic drawing.
Last edited by dbasnett; Feb 25th, 2010 at 10:22 AM.
-
Feb 25th, 2010, 06:36 PM
#10
Re: Game Of Life
What kind of format is the file stored in?
-
Feb 25th, 2010, 07:32 PM
#11
Re: Game Of Life
 Originally Posted by minitech
What kind of format is the file stored in?
The file is a dump of all the resources. Each resource in the file starts with Chr(0)#D
The name is next, then lines of the pattern.
-
Feb 26th, 2010, 08:53 AM
#12
Re: Game Of Life
 Originally Posted by dbasnett
The file is a dump of all the resources. Each resource in the file starts with Chr(0)#D
The name is next, then lines of the pattern.
The patterns can be in Life 1.05 or 1.06 format.
-
Feb 27th, 2010, 05:35 PM
#13
Re: Game Of Life
What is the format though? I don't know what the Life 1.05/06 formats are.
-
Feb 27th, 2010, 07:09 PM
#14
Lively Member
Re: Game Of Life
Hi I was wondering if anyone had tried to write any code for the Game of life in a console app.
-
Feb 27th, 2010, 10:10 PM
#15
Re: Game Of Life
Format
http://psoup.math.wisc.edu/mcell/ca_...ml#Life%201.05
basically they are text files with a few control commands starting with #.
* = on
. = off
Here is a sample named glider
***
*..
.*.
-
Feb 28th, 2010, 12:23 PM
#16
Re: Game Of Life
See post #1 in this thread for the latest version. Crude drawing and life birth/survival control added.
Warning, I have allowed the cell size to be 1. On my PC that is a grid of 839 x 839 (703,921 cells). It can get pretty slow at those sizes, but some beautiful patterns can be created with low birth rates.
Enjoy.
-
Feb 28th, 2010, 01:41 PM
#17
Last edited by dbasnett; Mar 18th, 2010 at 05:57 PM.
-
Feb 28th, 2010, 01:59 PM
#18
Re: Game Of Life
Using the CellularAutomaton Module from the screen version, here is a console application.
Code:
Module Module1
Dim theWorld As New CellUniverse(Console.LargestWindowHeight - 16, True) 'create world wrapped
Dim LDP As New List(Of CellXYState) 'store the states
Sub Main()
Console.SetWindowSize(theWorld.Size + 2, theWorld.Size + 2) 'set the window size
Dim ptrn As New List(Of String) 'our pattern - glider
ptrn.Add("#! -10 -10") 'non standard - global offset x y
ptrn.Add("***")
ptrn.Add("..*")
ptrn.Add(".*")
theWorld.LoadPattern(ptrn) 'load the pattern
LDP = theWorld.GetTick() 'get all on pixels
drawgrid() 'draw the grid
drawpoints() 'draw the points
Dim s As ConsoleKeyInfo
s = Console.ReadKey 'wait for user input (Enter key)
Do
LDP = theWorld.NextGeneration() 'get the next generation
drawpoints() 'draw the points
s = Console.ReadKey 'wait for enter
Loop While s.Key = ConsoleKey.Enter 'if not eneter key - end
End Sub
Sub drawpoints()
For x As Integer = 0 To LDP.Count - 1 'loop through all the points returned
Console.SetCursorPosition(LDP(x).X, LDP(x).Y) 'move the cursor
If LDP(x).State Then 'check state
'on
Console.Write("*")
Else
'off
Console.Write(".")
End If
Next
Console.SetCursorPosition(0, Console.WindowHeight - 1)
End Sub
Sub drawgrid() 'draw grid representing worlds
Console.Clear()
For y As Integer = 0 To theWorld.Size
For x As Integer = 0 To theWorld.Size
Console.SetCursorPosition(x, y)
Console.Write(".")
Next
Next
Console.SetCursorPosition(0, Console.WindowHeight - 1)
End Sub
End Module
-
Mar 1st, 2010, 12:44 PM
#19
Re: Game Of Life
1. This should be moved to the Code Bank
2. Just when you think all is well you find
Code:
#D Replicator - Nathan Thompson
#R 23/36
#P -2 -2
.OOO
O...
O...
O...
I think I have it fixed, but ....
-
Mar 18th, 2010, 05:56 PM
#20
Re: [RESOLVED] Game Of Life
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|