home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / life / life.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  23.8 KB  |  766 lines

  1. VERSION 2.00
  2. Begin Form Matrix 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Mini Life"
  6.    ClientHeight    =   2985
  7.    ClientLeft      =   1080
  8.    ClientTop       =   1770
  9.    ClientWidth     =   3000
  10.    Height          =   3675
  11.    Icon            =   LIFE.FRX:0000
  12.    Left            =   1020
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   2985
  17.    ScaleWidth      =   3000
  18.    Top             =   1140
  19.    Width           =   3120
  20.    Begin PictureBox Picture1 
  21.       Height          =   255
  22.       Index           =   64
  23.       Left            =   2640
  24.       ScaleHeight     =   225
  25.       ScaleWidth      =   225
  26.       TabIndex        =   63
  27.       Top             =   2640
  28.       Width           =   255
  29.    End
  30.    Begin PictureBox Picture1 
  31.       Height          =   255
  32.       Index           =   63
  33.       Left            =   2280
  34.       ScaleHeight     =   225
  35.       ScaleWidth      =   225
  36.       TabIndex        =   62
  37.       Top             =   2640
  38.       Width           =   255
  39.    End
  40.    Begin PictureBox Picture1 
  41.       Height          =   255
  42.       Index           =   62
  43.       Left            =   1920
  44.       ScaleHeight     =   225
  45.       ScaleWidth      =   225
  46.       TabIndex        =   61
  47.       Top             =   2640
  48.       Width           =   255
  49.    End
  50.    Begin PictureBox Picture1 
  51.       Height          =   255
  52.       Index           =   61
  53.       Left            =   1560
  54.       ScaleHeight     =   225
  55.       ScaleWidth      =   225
  56.       TabIndex        =   60
  57.       Top             =   2640
  58.       Width           =   255
  59.    End
  60.    Begin PictureBox Picture1 
  61.       Height          =   255
  62.       Index           =   60
  63.       Left            =   1200
  64.       ScaleHeight     =   225
  65.       ScaleWidth      =   225
  66.       TabIndex        =   59
  67.       Top             =   2640
  68.       Width           =   255
  69.    End
  70.    Begin PictureBox Picture1 
  71.       Height          =   255
  72.       Index           =   59
  73.       Left            =   840
  74.       ScaleHeight     =   225
  75.       ScaleWidth      =   225
  76.       TabIndex        =   58
  77.       Top             =   2640
  78.       Width           =   255
  79.    End
  80.    Begin PictureBox Picture1 
  81.       Height          =   255
  82.       Index           =   58
  83.       Left            =   480
  84.       ScaleHeight     =   225
  85.       ScaleWidth      =   225
  86.       TabIndex        =   57
  87.       Top             =   2640
  88.       Width           =   255
  89.    End
  90.    Begin PictureBox Picture1 
  91.       Height          =   255
  92.       Index           =   57
  93.       Left            =   120
  94.       ScaleHeight     =   225
  95.       ScaleWidth      =   225
  96.       TabIndex        =   56
  97.       Top             =   2640
  98.       Width           =   255
  99.    End
  100.    Begin PictureBox Picture1 
  101.       Height          =   255
  102.       Index           =   56
  103.       Left            =   2640
  104.       ScaleHeight     =   225
  105.       ScaleWidth      =   225
  106.       TabIndex        =   55
  107.       Top             =   2280
  108.       Width           =   255
  109.    End
  110.    Begin PictureBox Picture1 
  111.       Height          =   255
  112.       Index           =   55
  113.       Left            =   2280
  114.       ScaleHeight     =   225
  115.       ScaleWidth      =   225
  116.       TabIndex        =   54
  117.       Top             =   2280
  118.       Width           =   255
  119.    End
  120.    Begin PictureBox Picture1 
  121.       Height          =   255
  122.       Index           =   54
  123.       Left            =   1920
  124.       ScaleHeight     =   225
  125.       ScaleWidth      =   225
  126.       TabIndex        =   53
  127.       Top             =   2280
  128.       Width           =   255
  129.    End
  130.    Begin PictureBox Picture1 
  131.       Height          =   255
  132.       Index           =   53
  133.       Left            =   1560
  134.       ScaleHeight     =   225
  135.       ScaleWidth      =   225
  136.       TabIndex        =   52
  137.       Top             =   2280
  138.       Width           =   255
  139.    End
  140.    Begin PictureBox Picture1 
  141.       Height          =   255
  142.       Index           =   52
  143.       Left            =   1200
  144.       ScaleHeight     =   225
  145.       ScaleWidth      =   225
  146.       TabIndex        =   51
  147.       Top             =   2280
  148.       Width           =   255
  149.    End
  150.    Begin PictureBox Picture1 
  151.       Height          =   255
  152.       Index           =   51
  153.       Left            =   840
  154.       ScaleHeight     =   225
  155.       ScaleWidth      =   225
  156.       TabIndex        =   50
  157.       Top             =   2280
  158.       Width           =   255
  159.    End
  160.    Begin PictureBox Picture1 
  161.       Height          =   255
  162.       Index           =   50
  163.       Left            =   480
  164.       ScaleHeight     =   225
  165.       ScaleWidth      =   225
  166.       TabIndex        =   49
  167.       Top             =   2280
  168.       Width           =   255
  169.    End
  170.    Begin PictureBox Picture1 
  171.       Height          =   255
  172.       Index           =   49
  173.       Left            =   120
  174.       ScaleHeight     =   225
  175.       ScaleWidth      =   225
  176.       TabIndex        =   48
  177.       Top             =   2280
  178.       Width           =   255
  179.    End
  180.    Begin PictureBox Picture1 
  181.       Height          =   255
  182.       Index           =   48
  183.       Left            =   2640
  184.       ScaleHeight     =   225
  185.       ScaleWidth      =   225
  186.       TabIndex        =   47
  187.       Top             =   1920
  188.       Width           =   255
  189.    End
  190.    Begin PictureBox Picture1 
  191.       Height          =   255
  192.       Index           =   47
  193.       Left            =   2280
  194.       ScaleHeight     =   225
  195.       ScaleWidth      =   225
  196.       TabIndex        =   46
  197.       Top             =   1920
  198.       Width           =   255
  199.    End
  200.    Begin PictureBox Picture1 
  201.       Height          =   255
  202.       Index           =   46
  203.       Left            =   1920
  204.       ScaleHeight     =   225
  205.       ScaleWidth      =   225
  206.       TabIndex        =   45
  207.       Top             =   1920
  208.       Width           =   255
  209.    End
  210.    Begin PictureBox Picture1 
  211.       Height          =   255
  212.       Index           =   45
  213.       Left            =   1560
  214.       ScaleHeight     =   225
  215.       ScaleWidth      =   225
  216.       TabIndex        =   44
  217.       Top             =   1920
  218.       Width           =   255
  219.    End
  220.    Begin PictureBox Picture1 
  221.       Height          =   255
  222.       Index           =   44
  223.       Left            =   1200
  224.       ScaleHeight     =   225
  225.       ScaleWidth      =   225
  226.       TabIndex        =   43
  227.       Top             =   1920
  228.       Width           =   255
  229.    End
  230.    Begin PictureBox Picture1 
  231.       Height          =   255
  232.       Index           =   43
  233.       Left            =   840
  234.       ScaleHeight     =   225
  235.       ScaleWidth      =   225
  236.       TabIndex        =   42
  237.       Top             =   1920
  238.       Width           =   255
  239.    End
  240.    Begin PictureBox Picture1 
  241.       Height          =   255
  242.       Index           =   42
  243.       Left            =   480
  244.       ScaleHeight     =   225
  245.       ScaleWidth      =   225
  246.       TabIndex        =   41
  247.       Top             =   1920
  248.       Width           =   255
  249.    End
  250.    Begin PictureBox Picture1 
  251.       Height          =   255
  252.       Index           =   41
  253.       Left            =   120
  254.       ScaleHeight     =   225
  255.       ScaleWidth      =   225
  256.       TabIndex        =   40
  257.       Top             =   1920
  258.       Width           =   255
  259.    End
  260.    Begin PictureBox Picture1 
  261.       Height          =   255
  262.       Index           =   40
  263.       Left            =   2640
  264.       ScaleHeight     =   225
  265.       ScaleWidth      =   225
  266.       TabIndex        =   39
  267.       Top             =   1560
  268.       Width           =   255
  269.    End
  270.    Begin PictureBox Picture1 
  271.       Height          =   255
  272.       Index           =   39
  273.       Left            =   2280
  274.       ScaleHeight     =   225
  275.       ScaleWidth      =   225
  276.       TabIndex        =   38
  277.       Top             =   1560
  278.       Width           =   255
  279.    End
  280.    Begin PictureBox Picture1 
  281.       Height          =   255
  282.       Index           =   38
  283.       Left            =   1920
  284.       ScaleHeight     =   225
  285.       ScaleWidth      =   225
  286.       TabIndex        =   37
  287.       Top             =   1560
  288.       Width           =   255
  289.    End
  290.    Begin PictureBox Picture1 
  291.       Height          =   255
  292.       Index           =   37
  293.       Left            =   1560
  294.       ScaleHeight     =   225
  295.       ScaleWidth      =   225
  296.       TabIndex        =   36
  297.       Top             =   1560
  298.       Width           =   255
  299.    End
  300.    Begin PictureBox Picture1 
  301.       Height          =   255
  302.       Index           =   36
  303.       Left            =   1200
  304.       ScaleHeight     =   225
  305.       ScaleWidth      =   225
  306.       TabIndex        =   35
  307.       Top             =   1560
  308.       Width           =   255
  309.    End
  310.    Begin PictureBox Picture1 
  311.       Height          =   255
  312.       Index           =   35
  313.       Left            =   840
  314.       ScaleHeight     =   225
  315.       ScaleWidth      =   225
  316.       TabIndex        =   34
  317.       Top             =   1560
  318.       Width           =   255
  319.    End
  320.    Begin PictureBox Picture1 
  321.       Height          =   255
  322.       Index           =   34
  323.       Left            =   480
  324.       ScaleHeight     =   225
  325.       ScaleWidth      =   225
  326.       TabIndex        =   33
  327.       Top             =   1560
  328.       Width           =   255
  329.    End
  330.    Begin PictureBox Picture1 
  331.       Height          =   255
  332.       Index           =   33
  333.       Left            =   120
  334.       ScaleHeight     =   225
  335.       ScaleWidth      =   225
  336.       TabIndex        =   32
  337.       Top             =   1560
  338.       Width           =   255
  339.    End
  340.    Begin PictureBox Picture1 
  341.       Height          =   255
  342.       Index           =   32
  343.       Left            =   2640
  344.       ScaleHeight     =   225
  345.       ScaleWidth      =   225
  346.       TabIndex        =   31
  347.       Top             =   1200
  348.       Width           =   255
  349.    End
  350.    Begin PictureBox Picture1 
  351.       Height          =   255
  352.       Index           =   31
  353.       Left            =   2280
  354.       ScaleHeight     =   225
  355.       ScaleWidth      =   225
  356.       TabIndex        =   30
  357.       Top             =   1200
  358.       Width           =   255
  359.    End
  360.    Begin PictureBox Picture1 
  361.       Height          =   255
  362.       Index           =   30
  363.       Left            =   1920
  364.       ScaleHeight     =   225
  365.       ScaleWidth      =   225
  366.       TabIndex        =   29
  367.       Top             =   1200
  368.       Width           =   255
  369.    End
  370.    Begin PictureBox Picture1 
  371.       Height          =   255
  372.       Index           =   29
  373.       Left            =   1560
  374.       ScaleHeight     =   225
  375.       ScaleWidth      =   225
  376.       TabIndex        =   28
  377.       Top             =   1200
  378.       Width           =   255
  379.    End
  380.    Begin PictureBox Picture1 
  381.       Height          =   255
  382.       Index           =   28
  383.       Left            =   1200
  384.       ScaleHeight     =   225
  385.       ScaleWidth      =   225
  386.       TabIndex        =   27
  387.       Top             =   1200
  388.       Width           =   255
  389.    End
  390.    Begin PictureBox Picture1 
  391.       Height          =   255
  392.       Index           =   27
  393.       Left            =   840
  394.       ScaleHeight     =   225
  395.       ScaleWidth      =   225
  396.       TabIndex        =   26
  397.       Top             =   1200
  398.       Width           =   255
  399.    End
  400.    Begin PictureBox Picture1 
  401.       Height          =   255
  402.       Index           =   26
  403.       Left            =   480
  404.       ScaleHeight     =   225
  405.       ScaleWidth      =   225
  406.       TabIndex        =   25
  407.       Top             =   1200
  408.       Width           =   255
  409.    End
  410.    Begin PictureBox Picture1 
  411.       Height          =   255
  412.       Index           =   25
  413.       Left            =   120
  414.       ScaleHeight     =   225
  415.       ScaleWidth      =   225
  416.       TabIndex        =   24
  417.       Top             =   1200
  418.       Width           =   255
  419.    End
  420.    Begin PictureBox Picture1 
  421.       Height          =   255
  422.       Index           =   24
  423.       Left            =   2640
  424.       ScaleHeight     =   225
  425.       ScaleWidth      =   225
  426.       TabIndex        =   23
  427.       Top             =   840
  428.       Width           =   255
  429.    End
  430.    Begin PictureBox Picture1 
  431.       Height          =   255
  432.       Index           =   23
  433.       Left            =   2280
  434.       ScaleHeight     =   225
  435.       ScaleWidth      =   225
  436.       TabIndex        =   22
  437.       Top             =   840
  438.       Width           =   255
  439.    End
  440.    Begin PictureBox Picture1 
  441.       Height          =   255
  442.       Index           =   22
  443.       Left            =   1920
  444.       ScaleHeight     =   225
  445.       ScaleWidth      =   225
  446.       TabIndex        =   21
  447.       Top             =   840
  448.       Width           =   255
  449.    End
  450.    Begin PictureBox Picture1 
  451.       Height          =   255
  452.       Index           =   21
  453.       Left            =   1560
  454.       ScaleHeight     =   225
  455.       ScaleWidth      =   225
  456.       TabIndex        =   20
  457.       Top             =   840
  458.       Width           =   255
  459.    End
  460.    Begin PictureBox Picture1 
  461.       Height          =   255
  462.       Index           =   20
  463.       Left            =   1200
  464.       ScaleHeight     =   225
  465.       ScaleWidth      =   225
  466.       TabIndex        =   19
  467.       Top             =   840
  468.       Width           =   255
  469.    End
  470.    Begin PictureBox Picture1 
  471.       Height          =   255
  472.       Index           =   19
  473.       Left            =   840
  474.       ScaleHeight     =   225
  475.       ScaleWidth      =   225
  476.       TabIndex        =   18
  477.       Top             =   840
  478.       Width           =   255
  479.    End
  480.    Begin PictureBox Picture1 
  481.       Height          =   255
  482.       Index           =   18
  483.       Left            =   480
  484.       ScaleHeight     =   225
  485.       ScaleWidth      =   225
  486.       TabIndex        =   17
  487.       Top             =   840
  488.       Width           =   255
  489.    End
  490.    Begin PictureBox Picture1 
  491.       Height          =   255
  492.       Index           =   17
  493.       Left            =   120
  494.       ScaleHeight     =   225
  495.       ScaleWidth      =   225
  496.       TabIndex        =   16
  497.       Top             =   840
  498.       Width           =   255
  499.    End
  500.    Begin PictureBox Picture1 
  501.       Height          =   255
  502.       Index           =   16
  503.       Left            =   2640
  504.       ScaleHeight     =   225
  505.       ScaleWidth      =   225
  506.       TabIndex        =   15
  507.       Top             =   480
  508.       Width           =   255
  509.    End
  510.    Begin PictureBox Picture1 
  511.       Height          =   255
  512.       Index           =   15
  513.       Left            =   2280
  514.       ScaleHeight     =   225
  515.       ScaleWidth      =   225
  516.       TabIndex        =   14
  517.       Top             =   480
  518.       Width           =   255
  519.    End
  520.    Begin PictureBox Picture1 
  521.       Height          =   255
  522.       Index           =   14
  523.       Left            =   1920
  524.       ScaleHeight     =   225
  525.       ScaleWidth      =   225
  526.       TabIndex        =   13
  527.       Top             =   480
  528.       Width           =   255
  529.    End
  530.    Begin PictureBox Picture1 
  531.       Height          =   255
  532.       Index           =   13
  533.       Left            =   1560
  534.       ScaleHeight     =   225
  535.       ScaleWidth      =   225
  536.       TabIndex        =   12
  537.       Top             =   480
  538.       Width           =   255
  539.    End
  540.    Begin PictureBox Picture1 
  541.       Height          =   255
  542.       Index           =   12
  543.       Left            =   1200
  544.       ScaleHeight     =   225
  545.       ScaleWidth      =   225
  546.       TabIndex        =   11
  547.       Top             =   480
  548.       Width           =   255
  549.    End
  550.    Begin PictureBox Picture1 
  551.       Height          =   255
  552.       Index           =   11
  553.       Left            =   840
  554.       ScaleHeight     =   225
  555.       ScaleWidth      =   225
  556.       TabIndex        =   10
  557.       Top             =   480
  558.       Width           =   255
  559.    End
  560.    Begin PictureBox Picture1 
  561.       Height          =   255
  562.       Index           =   10
  563.       Left            =   480
  564.       ScaleHeight     =   225
  565.       ScaleWidth      =   225
  566.       TabIndex        =   9
  567.       Top             =   480
  568.       Width           =   255
  569.    End
  570.    Begin PictureBox Picture1 
  571.       Height          =   255
  572.       Index           =   9
  573.       Left            =   120
  574.       ScaleHeight     =   225
  575.       ScaleWidth      =   225
  576.       TabIndex        =   8
  577.       Top             =   480
  578.       Width           =   255
  579.    End
  580.    Begin PictureBox Picture1 
  581.       Height          =   255
  582.       Index           =   8
  583.       Left            =   2640
  584.       ScaleHeight     =   225
  585.       ScaleWidth      =   225
  586.       TabIndex        =   7
  587.       Top             =   120
  588.       Width           =   255
  589.    End
  590.    Begin PictureBox Picture1 
  591.       Height          =   255
  592.       Index           =   7
  593.       Left            =   2280
  594.       ScaleHeight     =   225
  595.       ScaleWidth      =   225
  596.       TabIndex        =   6
  597.       Top             =   120
  598.       Width           =   255
  599.    End
  600.    Begin PictureBox Picture1 
  601.       Height          =   255
  602.       Index           =   6
  603.       Left            =   1920
  604.       ScaleHeight     =   225
  605.       ScaleWidth      =   225
  606.       TabIndex        =   5
  607.       Top             =   120
  608.       Width           =   255
  609.    End
  610.    Begin PictureBox Picture1 
  611.       Height          =   255
  612.       Index           =   5
  613.       Left            =   1560
  614.       ScaleHeight     =   225
  615.       ScaleWidth      =   225
  616.       TabIndex        =   4
  617.       Top             =   120
  618.       Width           =   255
  619.    End
  620.    Begin PictureBox Picture1 
  621.       Height          =   255
  622.       Index           =   4
  623.       Left            =   1200
  624.       ScaleHeight     =   225
  625.       ScaleWidth      =   225
  626.       TabIndex        =   3
  627.       Top             =   120
  628.       Width           =   255
  629.    End
  630.    Begin PictureBox Picture1 
  631.       Height          =   255
  632.       Index           =   3
  633.       Left            =   840
  634.       ScaleHeight     =   225
  635.       ScaleWidth      =   225
  636.       TabIndex        =   2
  637.       Top             =   120
  638.       Width           =   255
  639.    End
  640.    Begin PictureBox Picture1 
  641.       Height          =   255
  642.       Index           =   2
  643.       Left            =   480
  644.       ScaleHeight     =   225
  645.       ScaleWidth      =   225
  646.       TabIndex        =   1
  647.       Top             =   120
  648.       Width           =   255
  649.    End
  650.    Begin PictureBox Picture1 
  651.       Height          =   255
  652.       Index           =   1
  653.       Left            =   120
  654.       ScaleHeight     =   225
  655.       ScaleWidth      =   225
  656.       TabIndex        =   0
  657.       Top             =   120
  658.       Width           =   255
  659.    End
  660.    Begin Menu MenuFile 
  661.       Caption         =   "&File"
  662.       Begin Menu FileExit 
  663.          Caption         =   "E&xit"
  664.       End
  665.    End
  666.    Begin Menu MenuRun 
  667.       Caption         =   "&Restart"
  668.       Enabled         =   0   'False
  669.    End
  670.  Dim LifeState(64) As Integer
  671. Sub FileExit_Click ()
  672.   End
  673. End Sub
  674. Sub Form_Load ()
  675.   'Sets the cellular automata matrix to an initial random (50%) state of existence.
  676.   Randomize
  677.   CurrentColor = QBColor(Int(Rnd * 16)) 'Add some variety to the initial color
  678.   For I% = 1 To 64
  679.     Picture1(I%).backcolor = CurrentColor  'Sets the cell color for the initial state
  680.     Picture1(I%).Visible = -1 * CInt((Rnd))
  681.   Next I%
  682. End Sub
  683. Sub Form_Resize ()
  684.   Main
  685. End Sub
  686. Sub Main ()
  687.   'The real action is here.
  688.   'The "Game of Life" rules are public domain.
  689.   'This Visual Basic adaptation by Rick Wagner (CIS 76427,2611) is given to the public by the author.
  690.   'Thanks to all the MSLANG Forum Visual Basic section who have uploaded code or given assistance
  691.   'through messages.
  692.   'The form for this sample/demo was created with an 800 x 600 16 color machine. Please let me
  693.   'know if there are problems with the form at other resolutions. I know I have to redo forms
  694.   'for 8414/A because of 1) system fonts are different and 2) bitmaps are smaller. There are
  695.   'none of those in this sample, but I moved the project window over so VGA types can see it.
  696.   'This sample program exhibits all the classic forms of the "Game of Life:" blinkers, squares, etc.
  697.   'Expanding the picture box array size and applying this code to it should work fine.
  698.   'Note: To implement really large matrices you may find better performance in using a pair of 2D integer arrays to
  699.   '      hold alternating state vectors for the matrix, one for the current generation, one for the next.
  700.   '      Using 2D matrices will make dealing with "ghost" cells easier.
  701.   MenuRun.Enabled = -1                    'Enables the "Restart" menu option
  702.   Do While Flag% = 0                      'Flag turns true when all cells are dead.
  703.     CurrentColor = QBColor(Int(Rnd * 16)) 'Add some variety to the colors, and trace the loop visually.
  704.     np% = DoEvents()                      'Lemme outta here... (otherwise you get a real secure system).
  705.     'This loop establishes the sums of living neighbors for each cell
  706.     'and assigns future (next cycle) life states based on the "Game of Life" rules.
  707.     For I% = 1 To 64                      'A small (8 x 8) matrix implemented with a one dimensional control array.
  708.       SumNeighbs% = 0                      'Initialize the sum of neighbors (non-border cells can have 8 neighbors).
  709.       If I% - 9 > 0 Then                                                    'These conditions exclude nonexistent picture boxes.
  710.         If Picture1(I% - 9).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  711.       End If
  712.       If I% - 8 > 0 Then
  713.         If Picture1(I% - 8).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  714.       End If
  715.       If I% - 7 > 0 And Int(I% / 8) <> I% / 8 Then                          'Excludes from right column cells the touch of ghosts
  716.         If Picture1(I% - 7).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  717.       End If
  718.       If I% - 1 > 0 And Int((I% + 7) / 8) <> (I% + 7) / 8 Then              'Exclude from left column cells the touch of ghosts
  719.         If Picture1(I% - 1).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  720.       End If
  721.       If I% + 1 < 65 And Int(I% / 8) <> I% / 8 Then                         'Excludes from right
  722.         If Picture1(I% + 1).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  723.       End If
  724.       If I% + 7 < 65 And Int((I% + 7) / 8) <> (I% + 7) / 8 Then             'Excludes from left
  725.         If Picture1(I% + 7).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  726.       End If
  727.       If I% + 8 < 65 And Int((I% + 7) / 8) <> (I% + 7) / 8 Then             'Excldes from left
  728.         If Picture1(I% + 8).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  729.       End If
  730.       If I% + 9 < 65 And Int(I% / 8) <> I% / 8 Then                         'Excludes from right
  731.         If Picture1(I% + 9).Visible = -1 Then SumNeighbs% = SumNeighbs% + 1
  732.       End If
  733.       'These are the "Game of Life" rules:
  734.       If SumNeighbs% < 2 Then LifeState(I%) = 0
  735.       If SumNeighbs% = 2 And Picture1(I%).Visible = -1 Then LifeState(I%) = -1
  736.       If SumNeighbs% = 2 And Picture1(I%).Visible = 0 Then LifeState(I%) = 0
  737.       If SumNeighbs% = 3 Then LifeState(I%) = -1
  738.       If SumNeighbs% > 3 Then LifeState(I%) = 0
  739.     Next I%
  740.     np% = DoEvents()
  741.     'This loop assigns visibility (aliveness) depending on states assigned above.
  742.     SumStates% = 0                           'Used to detect total death
  743.     For I% = 1 To 64
  744.       Picture1(I%).backcolor = CurrentColor  'Sets the cell color for the current cycle
  745.       If LifeState(I%) = -1 Then
  746.         Picture1(I%).Visible = -1
  747.       Else Picture1(I%).Visible = 0
  748.       End If
  749.       SumStates% = SumStates% - LifeState(I%)
  750.       Next I%
  751.     If SumStates% = 0 Then Flag% = -1
  752.   Loop
  753.   MsgBox "They're all dead!"
  754. End Sub
  755. Sub MenuRun_Click ()
  756.   'Turn 'em all off to make the initialization look plainer.
  757.   For I% = 1 To 64
  758.     Picture1(I%).Visible = 0
  759.   Next I%
  760.   'Set the cellular automata matrix to a random (50%) state of existence.
  761.   For I% = 1 To 64
  762.     Picture1(I%).Visible = -1 * CInt((Rnd))
  763.   Next I%
  764.   Main
  765. End Sub
  766.