VERSION 5.00 Begin VB.Form frmMain Caption = "Evolution" ClientHeight = 8415 ClientLeft = 60 ClientTop = 345 ClientWidth = 9990 LinkTopic = "Form1" ScaleHeight = 8415 ScaleWidth = 9990 StartUpPosition = 3 'Windows Default Begin VB.CommandButton Command1 Caption = "Command1" Height = 375 Left = 3420 TabIndex = 12 Top = 120 Width = 735 End Begin VB.TextBox txtLog Height = 1935 Left = 120 MultiLine = -1 'True TabIndex = 3 Top = 6360 Width = 9735 End Begin VB.CommandButton cmdStep Caption = "Step" Height = 315 Left = 840 TabIndex = 2 Top = 60 Width = 555 End Begin VB.CommandButton cmdStart Caption = "Start" Height = 315 Left = 60 TabIndex = 1 Top = 60 Width = 675 End Begin VB.Timer tmrMain Left = 9480 Top = 0 End Begin VB.Frame frmField Caption = "Evolution Field" Height = 5715 Left = 60 TabIndex = 0 Top = 540 Width = 9855 Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 7 Left = 8580 TabIndex = 11 Top = 4860 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 6 Left = 8580 TabIndex = 10 Top = 4200 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 5 Left = 8580 TabIndex = 9 Top = 3600 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 4 Left = 8580 TabIndex = 8 Top = 2940 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 3 Left = 8580 TabIndex = 7 Top = 2280 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 2 Left = 8580 TabIndex = 6 Top = 1620 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 1 Left = 8580 TabIndex = 5 Top = 1020 Width = 1215 End Begin VB.Label txtNote BeginProperty Font Name = "MS Serif" Size = 6 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 0 Left = 8580 TabIndex = 4 Top = 360 Width = 1215 End Begin VB.Shape ra_AI Height = 255 Index = 7 Left = 300 Shape = 2 'Oval Top = 4860 Width = 255 End Begin VB.Shape ra_AI Height = 255 Index = 6 Left = 300 Shape = 2 'Oval Top = 4200 Width = 255 End Begin VB.Shape ra_AI Height = 255 Index = 5 Left = 300 Shape = 2 'Oval Top = 3600 Width = 255 End Begin VB.Shape ra_AI Height = 255 Index = 4 Left = 300 Shape = 2 'Oval Top = 2940 Width = 255 End Begin VB.Shape ra_AI Height = 255 Index = 3 Left = 300 Shape = 2 'Oval Top = 2280 Width = 255 End Begin VB.Shape ra_AI Height = 255 Index = 2 Left = 300 Shape = 2 'Oval Top = 1620 Width = 255 End Begin VB.Line ra_Line Index = 6 X1 = 300 X2 = 9780 Y1 = 4500 Y2 = 4500 End Begin VB.Line ra_Line Index = 7 X1 = 300 X2 = 9780 Y1 = 5160 Y2 = 5160 End Begin VB.Line ra_Line Index = 5 X1 = 300 X2 = 9780 Y1 = 3900 Y2 = 3900 End Begin VB.Line ra_Line Index = 3 X1 = 300 X2 = 9780 Y1 = 2580 Y2 = 2580 End Begin VB.Line ra_Line Index = 4 X1 = 300 X2 = 9780 Y1 = 3240 Y2 = 3240 End Begin VB.Line ra_Line Index = 2 X1 = 300 X2 = 9780 Y1 = 1920 Y2 = 1920 End Begin VB.Line Laser BorderColor = &H000000FF& BorderStyle = 2 'Dash X1 = 120 X2 = 180 Y1 = 2280 Y2 = 2880 End Begin VB.Line ra_Line Index = 1 X1 = 300 X2 = 9780 Y1 = 1320 Y2 = 1320 End Begin VB.Shape ra_AI Height = 255 Index = 0 Left = 300 Shape = 2 'Oval Top = 360 Width = 255 End Begin VB.Shape ra_AI Height = 255 Index = 1 Left = 300 Shape = 2 'Oval Top = 1020 Width = 255 End Begin VB.Line ra_Line Index = 0 X1 = 300 X2 = 9780 Y1 = 660 Y2 = 660 End End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim laser_speed As Double Private Sub Command1_Click() Load ra_AI(8) ra_AI(8).Visible = True ra_AI(8).Left = 500 ra_AI(8).Top = 500 ra_AI(8).Width = 500 ra_AI(8).Height = 500 End Sub Private Sub Form_Load() tmrMain.Enabled = False tmrMain.Interval = 200 Laser.Visible = True Dim i As Integer Dim ai As Shape i = 0 For Each ai In ra_AI ai.Width = Rand(10, 200) ai.Height = ai.Width ai.Left = ra_Line(i).X1 + Rand(-40, 200) ai.Top = ra_Line(i).Y1 - ai.Height / 2 ai.Visible = True i = i + 1 Next End Sub Private Sub Form_Resize() Dim line As line frmField.Width = frmMain.Width - 255 For Each line In ra_Line line.X2 = frmField.Width - 75 txtNote(line.Index).Left = line.X2 - txtNote(line.Index).Width Next End Sub Private Sub tmrMain_Timer() Step End Sub Private Sub cmdStart_Click() If (tmrMain.Enabled = True) Then tmrMain.Enabled = False cmdStart.Caption = "Start" Else tmrMain.Enabled = True cmdStart.Caption = "Stop" End If End Sub Private Sub cmdStep_Click() Step End Sub Function Step() Dim ai As Shape Dim slowest As Shape Dim i As Integer ' move ai's ' kill the slowest one ' if hit, kill ' if any open ai's, pick one to dup+change ' move ai's ' speed is a function of "wind resistance", ie vertical width For Each ai In ra_AI ai.Left = ai.Left + ai.Height / 4 - ai.Width / 8 Next If (Rand(0, 100) < 50) Then ' x% chance of a kill ' kill slowest Set slowest = ra_AI(0) For Each ai In ra_AI If (ai.Left < slowest.Left) Then Set slowest = ai End If Next Laser.X2 = slowest.Left Laser.Y2 = slowest.Top + slowest.Height / 2 ' slowest.Visible = False ' killed ' check hits ' choose one to dup i = Rand(ra_AI.LBound, ra_AI.ubound) Do While ra_AI(i).Visible = False i = Rand(ra_AI.LBound, ra_AI.ubound) Loop ' clone and add random change slowest.Left = ra_AI(i).Left Dim new_width, new_height As Integer new_width = ra_AI(i).Width + Rand(-40, 40) If new_width < 5 Then new_width = 20 slowest.Width = new_width new_height = ra_AI(i).Height + Rand(-40, 40) If new_height < 5 Then new_height = 20 slowest.Height = new_height slowest.Top = ra_Line(slowest.Index).Y1 - slowest.Height / 2 slowest.Visible = True txtNote(slowest.Index).Caption = "#" & slowest.Index & ": H=" & slowest.Height & "; W=" & slowest.Width AddLog "Laser killed slowest #" & slowest.Index & " - Cloned #" & i & ": height=" & (ra_AI(i).Height - slowest.Height) & "; width=" & (ra_AI(i).Width - slowest.Width) End If End Function Function AddLog(text As String) txtLog = text & vbNewLine & txtLog End Function ' ######### Utilities ######### Public Function Rand(ByVal Low As Long, ByVal High As Long) As Long Rand = Int((High - Low + 1) * Rnd) + Low End Function