-
Aug 9th, 2020, 11:29 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] conway"s game of life
Does anyone have or know of a WORKING game of life for 2010. the one I found on the web don't seem to work!
Thanks
George
-
Aug 9th, 2020, 11:31 PM
#2
Re: conway"s game of life
You could always try to address the specific issues you're having, or even write something yourself from scratch.
-
Aug 10th, 2020, 03:28 AM
#3
Re: conway"s game of life
https://ericlippert.com/2020/04/13/life-part-1/ is the start of an ongoing series all about the topic, code is C# but the blogs themselves are fascinating.
-
Aug 10th, 2020, 07:31 AM
#4
Re: conway"s game of life
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 10th, 2020, 08:45 AM
#5
Thread Starter
Hyperactive Member
Re: conway"s game of life
.paul. I have copied and pasted the code from https://social.technet.microsoft.com...e-of-life.aspx
what must I do to run the program? not at all good with classes. the zip file seems to be for 2019
Code:
Imports System.Threading
''' <summary>
''' Extended DataGridView
''' DoubleBuffered. Restricts user selection of cells to facilitate seamless highlighting line drawing.
''' </summary>
''' <remarks></remarks>
Public Class exDGV
Inherits DataGridView
Dim WM_LBUTTONDOWN As Integer = &H201
Dim WM_LBUTTONDBLCLK As Integer = &H203
Dim WM_KEYDOWN As Integer = &H100
Public Sub New()
Me.DoubleBuffered = True
End Sub
Protected Overrides Sub OnRowPrePaint(ByVal e As System.Windows.Forms.DataGridViewRowPrePaintEventArgs)
e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus
MyBase.OnRowPrePaint(e)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_LBUTTONDBLCLK OrElse m.Msg = WM_KEYDOWN OrElse m.Msg = WM_LBUTTONDOWN Then
Return
End If
MyBase.WndProc(m)
End Sub
End Class
Public Class Animation
Private gridControl As exDGV
Private cellValues(99)() As Integer
Public cancelled As Boolean = False
Public Sub New(ByVal dgv As exDGV)
Me.gridControl = dgv
For r As Integer = 0 To 99
ReDim cellValues(r)(99)
Next
End Sub
Private Sub clear()
For r As Integer = 0 To 99
For c As Integer = 0 To 99
cellValues(r)(c) = 0
Next
Next
End Sub
Private Sub repaint()
If cancelled Then Return
For r As Integer = 0 To 99
For c As Integer = 0 To 99
If cellValues(r)(c) > 0 Then
gridControl.Rows(r).Cells(c).Style.BackColor = Color.Black
Else
gridControl.Rows(r).Cells(c).Style.BackColor = Color.White
End If
Next
Next
End Sub
Public Sub setSeed(ByVal x As Integer)
cancelled = True
clear()
Select Case x
Case 1 'diamond
For r As Integer = 47 To 48
For c As Integer = 49 To 50
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 49 To 50
For c As Integer = 49 To 50
cellValues(r)(c) = -1
Next c
Next r
For r As Integer = 49 To 50
For c As Integer = 51 To 52
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 51 To 52
For c As Integer = 49 To 50
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 49 To 50
For c As Integer = 47 To 48
cellValues(r)(c) = 1
Next c
Next r
Case 2 'square
For r As Integer = 48 To 51
For c As Integer = 48 To 51
cellValues(r)(c) = 1
Next c
Next r
Case 3 'cross
For r As Integer = 47 To 48
For c As Integer = 47 To 48
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 47 To 48
For c As Integer = 51 To 52
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 49 To 50
For c As Integer = 49 To 50
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 51 To 52
For c As Integer = 47 To 48
cellValues(r)(c) = 1
Next c
Next r
For r As Integer = 51 To 52
For c As Integer = 51 To 52
cellValues(r)(c) = 1
Next c
Next r
End Select
cancelled = False
repaint()
cancelled = True
End Sub
Public Sub animate(ByVal index As Integer)
cancelled = False
Dim l As Integer = 0
Dim t As Integer = 0
Dim r As Integer = 0
Dim b As Integer = 0
Select Case index
Case 1, 3
t = 47
b = 52
l = 47
r = 52
Case 2
t = 48
b = 51
l = 48
r = 51
End Select
Dim g As Integer = 2
Do While Not cancelled
For y As Integer = t To b
For x As Integer = l To r
If cancelled Then
Return
End If
If cellValues(y)(x) > 0 AndAlso cellValues(y)(x) < g Then
grow(g, y, x)
End If
Next x
Next y
'Pause for 50 milliseconds
Thread.Sleep(50)
For y As Integer = t To b
For x As Integer = l To r
If cancelled Then
Return
End If
If cellValues(y)(x) > 0 AndAlso cellValues(y)(x) < g Then
Dim count As Integer = surrounding(y, x)
If count < 2 Then
cellValues(y)(x) = -1
ElseIf count > 3 Then
cellValues(y)(x) = -1
End If
End If
Next x
Next y
'Pause for 50 milliseconds
Thread.Sleep(50)
For y As Integer = t To b
For x As Integer = l To r
If cancelled Then
Return
End If
If cellValues(y)(x) = -1 Then
Dim count As Integer = surrounding(y, x)
If count = 3 Then
cellValues(y)(x) = 1
End If
End If
Next x
Next y
'Pause for 50 milliseconds
Thread.Sleep(50)
t -= 1
l -= 1
b += 1
r += 1
g += 1
If t < 0 OrElse l < 0 Then
cancelled = True
End If
repaint()
Loop
End Sub
Private Sub grow(ByVal g As Integer, ByVal r As Integer, ByVal c As Integer)
If r > 0 Then
If cellValues(r - 1)(c) = 0 Then
cellValues(r - 1)(c) = g
End If
If c > 0 Then
If cellValues(r - 1)(c - 1) = 0 Then
cellValues(r - 1)(c - 1) = g
End If
End If
If c < 99 Then
If cellValues(r - 1)(c + 1) = 0 Then
cellValues(r - 1)(c + 1) = g
End If
End If
End If
If c > 0 Then
If cellValues(r)(c - 1) = 0 Then
cellValues(r)(c - 1) = g
End If
End If
If c < 99 Then
If cellValues(r)(c + 1) = 0 Then
cellValues(r)(c + 1) = g
End If
End If
If r < 99 Then
If cellValues(r + 1)(c) = 0 Then
cellValues(r + 1)(c) = g
End If
If c > 0 Then
If cellValues(r + 1)(c - 1) = 0 Then
cellValues(r + 1)(c - 1) = g
End If
End If
If c < 99 Then
If cellValues(r + 1)(c + 1) = 0 Then
cellValues(r + 1)(c + 1) = g
End If
End If
End If
End Sub
Private Function surrounding(ByVal r As Integer, ByVal c As Integer) As Integer
Dim count As Integer = 0
If r > 0 Then
If cellValues(r - 1)(c) > 0 Then
count += 1
End If
If c > 0 Then
If cellValues(r - 1)(c - 1) > 0 Then
count += 1
End If
End If
If c < 99 Then
If cellValues(r - 1)(c + 1) > 0 Then
count += 1
End If
End If
End If
If c > 0 Then
If cellValues(r)(c - 1) > 0 Then
count += 1
End If
End If
If c < 99 Then
If cellValues(r)(c + 1) > 0 Then
count += 1
End If
End If
If r < 99 Then
If cellValues(r + 1)(c) > 0 Then
count += 1
End If
If c > 0 Then
If cellValues(r + 1)(c - 1) > 0 Then
count += 1
End If
End If
If c < 99 Then
If cellValues(r + 1)(c + 1) > 0 Then
count += 1
End If
End If
End If
Return count
End Function
End Class
Last edited by georgesutfin; Aug 10th, 2020 at 08:54 AM.
-
Aug 10th, 2020, 09:36 AM
#6
Re: conway"s game of life
The zip file is VS2017
If you create a new project in VS2010, delete your initial Form1, then use add existing item to add
Animation.vb
exDGV.vb
Form1.vb
frmProgress.vb
From my VS2017 zipped project
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 10th, 2020, 10:44 AM
#7
Thread Starter
Hyperactive Member
Re: conway"s game of life
Thank you .paul. I've got it working
George
-
Nov 23rd, 2023, 04:37 AM
#8
Re: [RESOLVED] conway"s game of life
you might want to try searching for a more recent or updated version of the game
or write your own. The basics of the game are not that difficult...
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
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
|