Purely for the Dunctest
Dark Basic Pro - LIFE
Back to DarkBasicPro - Back to Life
REM Project: Life
REM Created: 15/09/05 8:53:26 PM
REM
REM ***** Main Source File *****
REM
REM Author: Dr Dunc
REM Initialization of screen for best performance
sync on : sync rate 60 : rem backdrop off : rem hide mouse
randomize timer()
#Constant MaxArraySize = 151
#Constant CellObjectOffset = 50
#Constant MaxPresets = 5
#Constant Clr_White = 4294967295
#Constant Clr_Black = -16711423
EndProg As Boolean
EndLoop As Boolean
TYPE typObjXYZFlt
X as Float
Y as Float
Z as Float
ENDTYPE
TYPE typ2D
X1 AS Integer
Y1 AS Integer
X2 AS Integer
Y2 AS Integer
ENDTYPE
TYPE t_PanelColumns
Fifth As Integer
Third As Integer
Half As Integer
Quarter As Integer
Spacer As Integer
ENDTYPE
TYPE t_Panel
PosX As Integer
PosY As Integer
SizeX As Integer
SizeY As Integer
BorderX As Integer
BorderY As Integer
RowSize As Integer
Columns As t_PanelColumns
ENDTYPE
TYPE t_Camera
Angle1 As Float
Angle2 As Float
Dist As Integer
PosX As Integer
PosY As Integer
PosZ As Integer
LookPoint As Integer
FOV As Integer
ENDTYPE
Dim LifeArray( 1, MaxArraySize, MaxArraySize ) As Integer
CurrentArray As Integer
OtherArray As Integer
DisplaySize As Integer
GridSize As Integer
DisplayXOffset As Integer
DisplayYOffset As Integer
LifeCycleCounter As Integer
CreateLife As Boolean
ThereAreCells As Boolean
ThereIsLife As Boolean
CellCntr As Integer
CellValue As Integer
CellLimit As Integer
CellHalfLimit As Integer
rem Splurgh variables
SphSize As Integer
SplgCntr As Integer
SplgCntr1 As Integer
SplgCntr2 As Integer
SplgX As Integer
SplgY As Integer
SplgX1 As Integer
SplgY1 As Integer
SplgX2 As Integer
SplgY2 As Integer
SplgTemp1 As Integer
SplgTemp2 As Integer
SplurghCount As Integer
SplurghIntensity As Integer
SplurghOffset As Integer
rem Panel variables
PTempX1 As Integer
PTempX2 As Integer
PTempX3 As Integer
PTempY1 As Integer
PTempY2 As Integer
PTempY3 As Integer
rem Dim CellColour( 512 )
Dim CellAmounts( 8 ) As Integer
Dim CellAmountsOrig( 8 ) As Integer
Dim CellBirth( 8 ) As Boolean
Dim CellDeviation( 8 ) As Integer
AllowGlobalDeviation As Boolean
AllowCellDeviation As Boolean
NeighboursEffect As Boolean
NeighboursAmount As Integer
ClearVisible As Boolean
NewLifeOnOld As Boolean
NumberOfCycles As Float
Panel As t_Panel
CamDetail As t_Camera
PresetType As Integer
Cntr As Integer
CntrX As Integer
CntrY As Integer
LCntrX As Integer
LCntrY As Integer
REM Show Life
SLCntrX As Integer
SLCntrY As Integer
SLTempX As Integer
SLTempY As Integer
SLTemp1 As Integer
SLTemp2 As Integer
SLTemp3 As Integer
REM Process Grid
PGTemp As Integer
PGCntrX As Integer
PGCntrY As Integer
Temp As Integer
Temp1 As Integer
Temp2 As Integer
Temp3 As Integer
Temp4 As Integer
TempX As Integer
TempY As Integer
TempX1 As Integer
TempY1 As Integer
TempX2 As Integer
TempY2 As Integer
RTemp As Float
RTemp1 As Float
RTemp2 As Float
RTemp3 As Float
YesNo As Boolean
TempStr As String
KeySt As Integer
MClk As Integer
MX As Integer
MY As Integer
Set Image Colorkey 255 , 255 , 0
NumberOfCycles = 0
rem CameraDist = SphSize * DisplaySize * 0.6
remstart
for Cntr = 0 to 512
Temp1 = 0
Temp2 = 0
Temp3 = 0
if Cntr < 128
Temp1 = Cntr
else
if Cntr < 255
Temp1 = 255 - Cntr
endif
endif
if Cntr > 128
if Cntr < 255
Temp2 = Cntr - 128
else
if Cntr < 383
Temp2 = 383 - Cntr
endif
endif
endif
if Cntr > 255
if Cntr < 383
Temp3 = Cntr - 255
else
if Cntr < 511
Temp3 = 511 - Cntr
endif
endif
endif
CellColour( Cntr ) = rgb( Temp1 , Temp2 , Temp3 )
next Cntr
remend
set text size 8
Panel.PosX = 10
Panel.PosY = 10
Panel.SizeX = Screen Width() / 5
Panel.SizeY = Screen Height() - Panel.PosY * 6
Panel.BorderX = 5
Panel.BorderY = 5
Panel.RowSize = 24
Panel.Columns.Fifth = Panel.SizeX / 5
Panel.Columns.Third = Panel.SizeX * 0.3
Panel.Columns.Half = Panel.SizeX / 2
Panel.Columns.Quarter = Panel.SizeX / 4
Panel.Columns.Spacer = Panel.SizeX * 0.03
Create Bitmap 1 , Panel.BorderX * 2 + Panel.SizeX , Panel.BorderY * 2 + Panel.SizeY
PresetType = 1
gosub _StartLife
gosub _SetUpCamera
EndLoop = 0
repeat
CurrentArray = OtherArray
OtherArray = Mod( CurrentArray + 1 , 2 )
NumberOfCycles = NumberOfCycles + 1
gosub _CheckMouse
gosub _ProcessGrid
gosub _ShowLife
sync
until EndLoop or EndProg
End
remstart
_ProcessGridDull:
ThereIsLife = 0
For LCntrX = 2 To GridSize - 1
For LCntrY = 2 To GridSize - 1
Rem Check cell rules for living
Temp = CheckCell( CurrentArray , LCntrX , LCntrY )
If LifeArray( CurrentArray , LCntrX , LCntrY ) > 0
ThereIsLife = 1
EndIf
If CreateLife = 0
Rem No Birth
If LifeArray( CurrentArray , LCntrX , LCntrY ) > 0
gosub _PG_AliveCell
Else
Rem Cell is not alive and no birth allowed
Temp = 0
rem LifeArray( OtherArray , LCntrX , LCntrY ) = 0
EndIf
Else
Rem Create Life
If NewLifeOnOld = 1
Rem Replace what ever is there
If NeighboursEffect = 1
Rem Use the Neighbours as an Effect
Temp = abs( CellAmounts( NeighbourCount ) + Temp )
Else
Rem Just create the life according to the CellAmount
Temp = ( abs( Temp ) / 100.0 ) * CellLimit
EndIf
Else
If LifeArray( CurrentArray , LCntrX , LCntrY ) = 0
Rem No life
If NeighboursEffect = 1
Rem Use the Neighbours as an Effect
NeighbourCount = ( Temp / ( CellLimit * 8.0 ) ) * 8.0 + 1.0
Temp = abs( CellAmounts( NeighbourCount ) + Temp )
Else
Rem Just set it to the CellAmount
Temp = ( Temp / 100.0 ) * CellLimit
EndIf
Else
Rem Don't replace a cell that is already alive
gosub _PG_AliveCell
EndIf
EndIf
EndIf
If Temp > CellLimit
Temp = CellLimit
EndIf
LifeArray( OtherArray , LCntrX , LCntrY ) = Temp
Next LCntrY
Next LCntrX
if AllowGlobalDeviation = 1
For LCntrX = 0 to 8
CellAmounts( LCntrX ) = CellAmountsOrig( LCntrX ) + ( Rnd( CellDeviation( LCntrX ) * 2 ) - CellDeviation( LCntrX ) )
Next LCntrX
endif
return
_PG_AliveCell:
Rem Cell is alive
If NeighboursEffect = 1
Rem Include the Neighbours as an Effect
NeighbourCount = ( Temp / ( CellLimit * 8.0 ) ) * 8 + 1
rem LifeArray( OtherArray , LCntrX , LCntrY ) = ( ( LifeArray( CurrentArray , LCntrX , LCntrY ) + CellAmounts( NeighbourCount ) + Temp ) / ( CellLimit * 3.0 ) ) * CellLimit
Temp = LifeArray( CurrentArray , LCntrX , LCntrY ) + CellAmounts( NeighbourCount ) + Temp
Else
Rem Just add the CellAmount
Temp = Temp + LifeArray( CurrentArray , LCntrX , LCntrY )
EndIf
Return
remend
_ProcessGrid:
ThereIsLife = 0
If AllowGlobalDeviation = 1
For PGCntrX = 0 to 8
CellAmounts( PGCntrX ) = CellAmountsOrig( PGCntrX ) + ( Rnd( CellDeviation( PGCntrX ) * 2 ) - CellDeviation( PGCntrX ) )
Next PGCntrX
EndIf
For PGCntrX = 2 To GridSize - 2
For PGCntrY = 2 To GridSize - 2
rem Check cell rules for living
PGTemp = CheckCell( CurrentArray , PGCntrX , PGCntrY )
rem Allow for each cell having a deviation
If AllowCellDeviation = 1
PGTemp = PGTemp + ( Rnd( CellDeviation( CellCntr ) * 2 ) - CellDeviation( CellCntr ) )
EndIF
rem Temp = Abs( CellAmounts( NeighbourCount ) + Temp )
If NeighboursEffect = 1
Rem Include the Neighbours as an Effect
PGTemp = PGTemp + ( CellValue / 8.0 ) * NeighbourAmount
EndIf
LifeArray( OtherArray , PGCntrX , PGCntrY ) = LifeArray( CurrentArray , PGCntrX , PGCntrY ) + PGTemp
rem Check for the bounds
If LifeArray( OtherArray , PGCntrX , PGCntrY ) < 0
rem Dead
LifeArray( OtherArray , PGCntrX , PGCntrY ) = 0
Else
If LifeArray( OtherArray , PGCntrX , PGCntrY ) > CellLimit
rem Max
LifeArray( OtherArray , PGCntrX , PGCntrY ) = CellLimit
EndIf
EndIf
If LifeArray( OtherArray , PGCntrX , PGCntrY ) > 0
ThereIsLife = 1
EndIf
Next PGCntrY
Next PGCntrX
Return
_ShowLife:
rem cls
rem SLTempX = object screen X( 1 )
rem SLTempY = object screen Y( 1 )
rem center text SLTempX , SLTempY , str$( DisplayXOffset ) + "," + str$( DisplayYOffset )
For SLCntrX = 0 To DisplaySize
For SLCntrY = 0 To DisplaySize
RTemp1 = CellLimit
SLTemp1 = CellObjectOffset + SLCntrX * DisplaySize + SLCntrY
SLTemp2 = ( LifeArray( CurrentArray , SLCntrX + DisplayXOffset , SLCntrY + DisplayYOffset ) / RTemp1 ) * SphSize * DisplaySize - ( SphSize * DisplaySize / 2 )
rem SLTemp2 = ( SphSize * DisplaySize ) * RTemp3
rem if SLTemp2 > 512 then SLTemp2 = 512
rem color object SLTemp1 , CellColour( SLTemp2 )
RTemp2 = ( LifeArray( CurrentArray , SLCntrX + DisplayXOffset , SLCntrY + DisplayYOffset ) / RTemp1 ) * SphSize * 3
rem Scale OBJECT SLTemp1 , RTemp2 , RTemp2 , RTemp2
Position Object SLTemp1 , Object position X ( SLTemp1 ) , SLTemp2 , Object position Z ( SLTemp1 )
Next SLCntrY
Next SLCntrX
ink rgb( 20 , 2, 255 ) , 0
box screen width() - 25 , 5 , Screen Width() - 5 , 25
if ThereIsLife = 1
ink rgb( 20 , 255 , 43 ) , 0
else
ink rgb( 23 , 144 , 60 ) , 0
endif
box screen width() - 23 , 7 , Screen Width() - 7 , 23
if object in screen( 1 )
center text Object Screen X( 1 ) , Object Screen Y( 1 ) , "."
endif
rem center text screen width() / 2 , 5 , str$( NumberOfCycles )
Return
_MakePanel:
Rem Make the Panel
set current bitmap 1
rem cls
box 0 , 0 , screen width() , screen height() , rgb( 10 , 20 , 71 ) , rgb( 46 , 74 , 42 ) , rgb( 20 , 30 , 71 ) , rgb( 46 , 54 , 52 )
Rem Top & Bottom borders
box 0 , 0 , Panel.BorderX * 2 + Panel.SizeX , Panel.BorderY , rgb( 6 , 34 , 200 ) , Clr_Black , rgb( 6 , 34 , 200 ) , Clr_Black
box 0 , Panel.SizeY , Panel.BorderX * 2 + Panel.SizeX , Panel.SizeY - Panel.BorderY , Clr_Black , rgb( 6 , 34 , 200 ) , Clr_Black , rgb( 6 , 34 , 200 )
Rem Left & Right borders
box 0 , 0 , Panel.BorderX , Panel.SizeY , Clr_Black , Clr_Black , rgb( 6 , 34 , 200 ) , rgb( 6 , 34 , 200 )
box Panel.BorderX * 2 + Panel.SizeX , 0 , Panel.SizeX + Panel.BorderX , Panel.SizeY , Clr_Black , Clr_Black , rgb( 6 , 34 , 200 ) , rgb( 6 , 34 , 200 )
ShadowText( Panel.SizeX / 2 , Panel.BorderY , "Preset:" + str$( PresetType ) , 1 )
rem Do the Cells parameters
rem Cell Amount background middle
PTempX3 = ( ( Panel.SizeX + Panel.BorderX ) - ( Panel.Columns.Fifth + Panel.BorderX ) ) / 2 + Panel.Columns.Fifth + Panel.BorderX
For Cntr = 0 to 8
PTempY1 = Cntr * Panel.RowSize + Panel.RowSize + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
ink rgb( 255 , 255 , 0 ) , Clr_White
rem The Cell count
ShadowText( 3 + Panel.BorderX , PTempY1 + 4 , str$( Cntr ) , 0 )
rem Cell Amount background
box PTempX3 , PTempY1 , Panel.Columns.Fifth + Panel.BorderX , PTempY2 - 2 , 0 , 0 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 )
box PTempX3 , PTempY1 , Panel.SizeX + Panel.BorderX , PTempY2 - 2 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 ) , 0 , 0
rem Calc and draw the Cell Growth amounts
rem Temp = ( CellAmounts( Cntr ) / 100.0 ) * ( Panel.SizeX * 0.3 ) + ( Panel.SizeX * 0.5 )
` Temp = ( CellAmounts( Cntr ) / 100.0 ) * Panel.Columns.Third + Panel.Columns.Half
RTemp1 = ( Panel.SizeX - Panel.BorderX - Panel.Columns.Fifth ) / 200.0 `Get the size/ratio of the Value area
RTemp1 = CellAmounts( Cntr ) * RTemp1 + PTempX3 `Get the pixel position
if CellAmounts( Cntr ) < 0
box PTempX3 , PTempY1 + 2 , RTemp1 , PTempY2 - 4 , rgb( 96 , 12 , 12 ) , rgb( 96 , 12 , 12 ) , rgb( 255 , 14 , 14 ) , rgb( 255 , 14 , 14 )
else
box PTempX3 , PTempY1 + 2 , RTemp1 , PTempY2 - 4 , rgb( 12, 96 , 12 ) , rgb( 12, 96 , 12 ) , rgb( 14, 255 , 14 ) , rgb( 14, 255 , 14 )
endif
ShadowText( PTempX3 , PTempY1 + 2 , str$( CellAmounts( Cntr ) ) , 1 )
remstart
rem Does cell make life?
box Panel.SizeX - Panel.Columns.Fifth + Panel.Columns.Spacer + Panel.BorderX , PTempY1 + 3 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 - 5
If CellBirth( Cntr ) = 1
ink rgb( 0 , 255 , 64 ) , Clr_White
else
ink rgb( 32 , 64 , 255 ) , Clr_White
endif
rem box Panel.SizeX * 0.83 + Panel.BorderX + 2 , PTempY1 + 5 , Panel.SizeX * 0.97 + Panel.BorderX - 2 , PTempY2 - 7
box Panel.SizeX - Panel.Columns.Fifth + Panel.Columns.Spacer + Panel.BorderX + 2 , PTempY1 + 5 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX - 2 , PTempY2 - 7
remend
Next Cntr
PTempY3 = 10
remstart
rem Position for next item
rem PTempY1 = Panel.RowSize * 9 + Panel.RowSize / 2 + Panel.RowSize + Panel.BorderY
PTempY1 = Panel.RowSize * PTempY3 + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
rem Is "New Life On Old" turned On or Off
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 , 0 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 ) , 0
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 , 0 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 ) , 0
If NewLifeOnOld = 1
ink rgb( 0 , 255 , 64 ) , Clr_White
else
ink rgb( 32 , 64 , 64 ) , Clr_White
endif
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 + 3 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 - 3
rem Tell 'em what it is
ShadowText( Panel.Columns.Half , PTempY1 + 3 , "New on old" , 1 )
remend
rem Position for next item
PTempY3 = PTempY3 + 1
PTempY1 = Panel.RowSize * PTempY3 + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
rem Neighbours background
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 , Panel.SizeX - Panel.Columns.Fifth + Panel.BorderX , PTempY2 , 0 , 0 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 )
rem Calc the NeighboursAmount
RTemp1 = NeighboursAmount / ( CellLimit + 0.0 )
RTemp2 = Panel.SizeX * 0.77
Temp = RTemp1 * RTemp2 + Panel.Columns.Spacer
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 + 2 , Temp + Panel.BorderX , PTempY2 - 4 , rgb( 64 , 12 , 12 ) , rgb( 64 , 12 , 12 ) , rgb( 255 , 64 , 64 ) , rgb( 255 , 64 , 64 )
rem Is "NeighboursEffect" turned On or Off
box Panel.SizeX - Panel.Columns.Fifth + Panel.Columns.Spacer + Panel.BorderX , PTempY1 + 3 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 - 5
If NeighboursEffect = 1
ink rgb( 0 , 255 , 64 ) , Clr_White
else
ink rgb( 32 , 64 , 255 ) , Clr_White
endif
box Panel.SizeX - Panel.Columns.Fifth + Panel.Columns.Spacer + Panel.BorderX + 2 , PTempY1 + 5 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX - 2 , PTempY2 - 7
rem Tell 'em what it is
ShadowText( Panel.Columns.Half + 1 + Panel.BorderX , PTempY1 + 3 , "N:" + str$( NeighboursAmount ) , 1 )
rem Position for next item
PTempY3 = PTempY3 + 1
PTempY1 = Panel.RowSize * PTempY3 + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
rem Tell 'em what it is
ShadowText( Panel.Columns.Half + Panel.BorderX , PTempY1 + 3 , "Deviation" , 1 )
ShadowText( Panel.Columns.Half + Panel.BorderX + 1 , PTempY1 + 3 , "Deviation" , 1 )
rem Position for next item
PTempY3 = PTempY3 + 1
PTempY1 = Panel.RowSize * PTempY3 + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
rem Deviation background
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 , Panel.Columns.Half - Panel.Columns.Spacer + Panel.BorderX , PTempY2 , 0 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 ) , 0
box Panel.Columns.Half + Panel.Columns.Spacer + Panel.BorderX , PTempY1 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 , 0 , rgb( 96 , 96 , 96 ) , rgb( 96 , 96 , 96 ) , 0
If AllowGlobalDeviation = 1
ink rgb( 0 , 255 , 64 ) , Clr_White
else
ink rgb( 32 , 64 , 255 ) , Clr_White
endif
box Panel.Columns.Spacer + Panel.BorderX , PTempY1 + 3 , Panel.Columns.Half - Panel.Columns.Spacer + Panel.BorderX , PTempY2 - 5
rem Tell 'em what it is
ShadowText( Panel.Columns.Quarter + Panel.BorderX , PTempY1 + 3 , "Global" , 1 )
If AllowCellDeviation = 1
ink rgb( 0 , 255 , 64 ) , Clr_White
else
ink rgb( 32 , 64 , 255 ) , Clr_White
endif
box Panel.Columns.Half + Panel.Columns.Spacer + Panel.BorderX , PTempY1 + 3 , Panel.SizeX - Panel.Columns.Spacer + Panel.BorderX , PTempY2 - 5
rem Tell 'em what it is
ShadowText( Panel.Columns.Half + Panel.Columns.Quarter + Panel.BorderX , PTempY1 + 3 , "Cell" , 1 )
rem Position for next item
PTempY3 = PTempY3 + 1
PTempY1 = Panel.RowSize * PTempY3 + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
ShadowText( Panel.Columns.Spacer , PTempY1 + 3 , "Instructions" , 0 )
PTempY3 = PTempY3 + 1
PTempY1 = Panel.RowSize * PTempY3 + Panel.BorderY
PTempY2 = PTempY1 + Panel.RowSize
set cursor Panel.Columns.Spacer , PTempY1 + 3
print "Left Mouse"
print " Splurgh Cells"
print "Right Mouse"
print " Clear Cells"
print "Arrows"
print " Rotate camera"
print "Shift+Arrow"
print " Move Cells"
print "Ctrl+UpDown Arrow"
print " Move look point"
print "Space+UpDown Arrow"
print " Zoom In/Out"
remstart
SplurghIntensity = CellLimit * 2
SplurghOffset = -CellLimit
SplurghCount = 100
remend
get image 1 , 0 , 0 , Panel.BorderX * 2 + Panel.SizeX , Panel.BorderY * 2 + Panel.SizeY , 1
sprite 1 , Panel.PosX , Panel.PosY , 1
set current bitmap 0
return
rem KeySt = SCANCODE()
rem text 0 , 400 , str$( KeySt )
_CheckMouse:
Rem Check if Not in Panel
MX = mouseX()
MY = mouseY()
MClk = mouseclick()
if MX < Panel.BorderX * 2 + Panel.PosX + Panel.SizeX
rem Inside the Panel
gosub _InPanelInput
else
rem Outside the Panel
gosub _OutOfPanelInput
endif
return
_InPanelInput:
set sprite alpha 1 , 255
If MClk = 1 and MX > Panel.PosX
rem Adjust the Mouse position to the panel
MX = MX - Panel.PosX - Panel.BorderX
rem - Panel.BorderX
MY = MY - Panel.PosY - Panel.BorderY
rem - Panel.BorderY
rem Get the Row
PTempY1 = MY / Panel.RowSize
rem Check for the Cells
If PTempY1 >= 1 And PTempY1 <= 9
rem CellAmounts( PTempY1 - 1 ) = ( MX * CellLimit ) / ( Panel.SizeX * 0.6 ) - ( Panel.SizeX * 0.2 )
remstart
the CellBirth toggle
If MX > Panel.SizeX - Panel.Columns.Fifth
rem - Panel.Columns.Spacer
CellBirth( PTempY1 - 1 ) = Mod( CellBirth( PTempY1 - 1 ) + 1 , 2 )
Else
remend
rem CellAmounts( PTempY1 - 1 ) = ( ( MX - ( Panel.SizeX * 0.2 ) ) * 200 ) / ( Panel.SizeX * 0.6 ) - 100
rem Miss the cell number
If MX > Panel.Columns.Fifth - Panel.Columns.Spacer
`just to bring it back into valid ranges
If MX < Panel.Columns.Fifth Then MX = Panel.Columns.Fifth
if MX > Panel.SizeX - Panel.BorderX then MX = Panel.SizeX - Panel.BorderX
rem PTempX3 = ( ( Panel.SizeX + Panel.BorderX ) - ( Panel.Columns.Fifth + Panel.BorderX ) ) / 2 + Panel.Columns.Fifth + Panel.BorderX
rem RTemp1 = MX - Panel.Columns.Fifth - Panel.Columns.Spacer
RTemp2 = ( Panel.SizeX - Panel.BorderX - Panel.Columns.Fifth ) / 200.0
` RTemp2 = RTemp2 / 200.0 `Size/Ratio of value area
RTemp1 = ( MX - Panel.Columns.Fifth ) / RTemp2 - 100.0 `Adjust to the value area
` RTemp1 = RTemp1 * 2.0
rem * 0.77
` RTemp1 = ( RTemp1 / RTemp2 ) * RTemp2
rem RTemp1 = RTemp1 * 3
CellAmounts( PTempY1 - 1 ) = RTemp1 `MX - Panel.Columns.Fifth
EndIf
rem EndIf
Else
rem The other panel devices
Select PTempY1
Case 0
PresetType = mod( PresetType , MaxPresets ) + 1
goto _ReStartLife
EndCase
Case 10
rem New on Top
NewLifeOnOld = Mod( NewLifeOnOld + 1 , 2 )
EndCase
Case 11
rem Neighbours
if MX > Panel.SizeX * 0.83
NeighboursEffect = Mod( NeighboursEffect + 1 , 2 )
else
NeighboursAmount = ( MX * CellLimit ) / ( Panel.SizeX * 0.6 ) - ( Panel.SizeX * 0.2 )
endif
remstart The Deviation heading
case 12
endcase
remend
EndCase
Case 13
if MX > Panel.SizeX / 2
AllowCellDeviation = Mod( AllowCellDeviation + 1 , 2 )
else
AllowGlobalDeviation = Mod( AllowGlobalDeviation + 1 , 2 )
endif
EndCase
Case 14
EndCase
EndSelect
endif
Gosub _MakePanel
endif
return
_OutOfPanelInput:
set sprite alpha 1 , 128
if SCANCODE() = 0
if ( MClk And 2 )
gosub _ClearGrid
endif
if ( MClk And 1 )
gosub _Splurgh
endif
else
rem Scroll within the Grid
if ShiftKey() = 1
if UpKey() = 1
DisplayXOffset = DisplayXOffset + 1
if DisplayXOffset + DisplaySize > GridSize
DisplayXOffset = GridSize - DisplaySize
endif
endif
if DownKey() = 1
DisplayXOffset = DisplayXOffset - 1
if DisplayXOffset < 1
DisplayXOffset = 0
endif
endif
if LeftKey() = 1
DisplayYOffset = DisplayYOffset - 1
if DisplayYOffset < 1
DisplayYOffset = 0
endif
endif
if RightKey() = 1
DisplayYOffset = DisplayYOffset + 1
if DisplayYOffset + DisplaySize > GridSize
DisplayYOffset = GridSize - DisplaySize
endif
endif
else
rem Move the Camera Look at point up or down
if ControlKey() = 1
YesNo = 0
if UpKey() = 1
CamDetail.LookPoint = CamDetail.LookPoint + SphSize
YesNo = 1
endif
if DownKey() = 1
CamDetail.LookPoint = CamDetail.LookPoint - SphSize
YesNo = 1
endif
if YesNo = 1
gosub _PositionCamera
endif
else
rem Set the Field-Of-View
if SpaceKey() = 1
YesNo = 0
if UpKey() = 1
YesNo = 1
CamDetail.FOV = CamDetail.FOV - 2
endif
if DownKey() = 1
YesNo = 1
CamDetail.FOV = CamDetail.FOV + 2
endif
if YesNo = 1
CamDetail.FOV = WrapValue( CamDetail.FOV * 2 ) / 2
set camera fov CamDetail.FOV
endif
else
rem Move the Camera around
YesNo = 0
if UpKey() = 1
CamDetail.Angle1 = WrapValue( CamDetail.Angle1 - 2 )
YesNo = 1
endif
if DownKey() = 1
CamDetail.Angle1 = WrapValue( CamDetail.Angle1 + 2 )
YesNo = 1
endif
if LeftKey() = 1
CamDetail.Angle2 = WrapValue( CamDetail.Angle2 - 2 )
YesNo = 1
endif
if RightKey() = 1
CamDetail.Angle2 = WrapValue( CamDetail.Angle2 + 2 )
YesNo = 1
endif
if YesNo = 1
gosub _PositionCamera
endif
endif
endif
endif
endif
return
_Splurgh:
For SplgCntr1 = 1 To SplurghCount
rem The size of the Splurgh
SplgTemp1 = Rnd( GridSize / 10 ) + 1
rem How many in the Splurgh
SplgTemp2 = Rnd( SplgTemp1 ) + 1
rem Where is the Splurgh
SplgX1 = Rnd( GridSize - SplgTemp1 - 4 ) + 2
SplgY1 = Rnd( GridSize - SplgTemp1 - 4 ) + 2
rem Do it
For SplgCntr2 = 1 to SplgTemp2
SplgX2 = Rnd( SplgTemp1 ) + SplgX1
SplgY2 = Rnd( SplgTemp1 ) + SplgY1
rem Temp = LifeArray(CurrentArray, SplgX2 , SplgY2 ) + Rnd( SplurghIntensity ) + SplurghOffset
Temp = Rnd( SplurghIntensity ) + SplurghOffset
If Temp >= CellLimit
Temp = CellLimit
EndIf
If Temp < 0
Temp = 0
EndIf
LifeArray(CurrentArray, SplgX2 , SplgY2 ) = Temp
Next SplgCntr2
Next SplgCntr1
Return
_SetUpCellAmounts:
For Cntr = 0 to 8
CellAmounts( Cntr ) = CellAmountsOrig( Cntr )
Next Cntr
return
_PresetCells:
select PresetType
case 0
GridSize = 150
DisplaySize = 40
SphSize = 20
CellLimit = 1000
CellHalfLimit = CellLimit / 2
NeighboursEffect = 0
NeighboursAmount = CellLimit
NewLifeOnOld = 0
AllowGlobalDeviation = 0
AllowCellDeviation = 0
SplurghIntensity = CellHalfLimit
SplurghOffset = CellLimit / 4
SplurghCount = 5
CellAmountsOrig( 0 ) = -CellHalfLimit
CellAmountsOrig( 1 ) = -5
CellAmountsOrig( 2 ) = 5
CellAmountsOrig( 3 ) = 5
CellAmountsOrig( 4 ) = 45
CellAmountsOrig( 5 ) = 30
CellAmountsOrig( 6 ) = -30
CellAmountsOrig( 7 ) = -50
CellAmountsOrig( 8 ) = -80
CellBirth( 0 ) = 0
CellBirth( 1 ) = 0
CellBirth( 2 ) = 1
CellBirth( 3 ) = 0
CellBirth( 4 ) = 1
CellBirth( 5 ) = 0
CellBirth( 6 ) = 0
CellBirth( 7 ) = 0
CellBirth( 8 ) = 0
CellDeviation( 0 ) = 0
CellDeviation( 1 ) = 145
CellDeviation( 2 ) = 145
CellDeviation( 3 ) = 145
CellDeviation( 4 ) = 145
CellDeviation( 5 ) = 145
CellDeviation( 6 ) = 145
CellDeviation( 7 ) = 145
CellDeviation( 8 ) = 145
endcase
case 1
GridSize = 150
DisplaySize = 50
SphSize = 20
CellLimit = 1000
CellHalfLimit = CellLimit / 2
NeighboursEffect = 0
NeighboursAmount = CellLimit
NewLifeOnOld = 0
AllowGlobalDeviation = 0
AllowCellDeviation = 1
SplurghIntensity = CellHalfLimit
SplurghOffset = CellLimit / 4
SplurghCount = 5
CellAmountsOrig( 0 ) = -100
CellAmountsOrig( 1 ) = -40
CellAmountsOrig( 2 ) = 25
CellAmountsOrig( 3 ) = 5
CellAmountsOrig( 4 ) = 45
CellAmountsOrig( 5 ) = 30
CellAmountsOrig( 6 ) = -5
CellAmountsOrig( 7 ) = -40
CellAmountsOrig( 8 ) = -100
CellBirth( 0 ) = 0
CellBirth( 1 ) = 0
CellBirth( 2 ) = 1
CellBirth( 3 ) = 0
CellBirth( 4 ) = 1
CellBirth( 5 ) = 0
CellBirth( 6 ) = 0
CellBirth( 7 ) = 0
CellBirth( 8 ) = 0
CellDeviation( 0 ) = 0
CellDeviation( 1 ) = 45
CellDeviation( 2 ) = 45
CellDeviation( 3 ) = 45
CellDeviation( 4 ) = 45
CellDeviation( 5 ) = 45
CellDeviation( 6 ) = 45
CellDeviation( 7 ) = 45
CellDeviation( 8 ) = 45
endcase
case 2
GridSize = 150
DisplaySize = 50
SphSize = 20
CellLimit = 1000
CellHalfLimit = CellLimit / 2
NeighboursEffect = 1
NeighboursAmount = CellLimit
NewLifeOnOld = 1
AllowGlobalDeviation = 0
AllowCellDeviation = 1
SplurghIntensity = CellHalfLimit
SplurghOffset = CellLimit / 4
SplurghCount = 10
CellAmountsOrig( 0 ) = -100
CellAmountsOrig( 1 ) = -78
CellAmountsOrig( 2 ) = -49
CellAmountsOrig( 3 ) = 29
CellAmountsOrig( 4 ) = 19
CellAmountsOrig( 5 ) = -10
CellAmountsOrig( 6 ) = -7
CellAmountsOrig( 7 ) = -49
CellAmountsOrig( 8 ) = -91
CellBirth( 0 ) = 0
CellBirth( 1 ) = 0
CellBirth( 2 ) = 0
CellBirth( 3 ) = 1
CellBirth( 4 ) = 1
CellBirth( 5 ) = 0
CellBirth( 6 ) = 0
CellBirth( 7 ) = 0
CellBirth( 8 ) = 0
CellDeviation( 0 ) = 0
CellDeviation( 1 ) = 9
CellDeviation( 2 ) = 9
CellDeviation( 3 ) = 9
CellDeviation( 4 ) = 9
CellDeviation( 5 ) = 9
CellDeviation( 6 ) = 9
CellDeviation( 7 ) = 9
CellDeviation( 8 ) = 9
endcase
case 3
GridSize = 150
DisplaySize = 50
SphSize = 20
CellLimit = 1000
CellHalfLimit = CellLimit / 2
NeighboursEffect = 0
NeighboursAmount = CellLimit
NewLifeOnOld = 1
AllowGlobalDeviation = 0
AllowCellDeviation = 1
SplurghIntensity = CellHalfLimit
SplurghOffset = CellLimit / 4
SplurghCount = 10
CellAmountsOrig( 0 ) = -40
CellAmountsOrig( 1 ) = -30
CellAmountsOrig( 2 ) = -25
CellAmountsOrig( 3 ) = -10
CellAmountsOrig( 4 ) = 45
CellAmountsOrig( 5 ) = 60
CellAmountsOrig( 6 ) = 30
CellAmountsOrig( 7 ) = -40
CellAmountsOrig( 8 ) = -100
CellBirth( 0 ) = 0
CellBirth( 1 ) = 0
CellBirth( 2 ) = 0
CellBirth( 3 ) = 0
CellBirth( 4 ) = 0
CellBirth( 5 ) = 1
CellBirth( 6 ) = 0
CellBirth( 7 ) = 0
CellBirth( 8 ) = 0
CellDeviation( 0 ) = 0
CellDeviation( 1 ) = 3
CellDeviation( 2 ) = 3
CellDeviation( 3 ) = 3
CellDeviation( 4 ) = 3
CellDeviation( 5 ) = 3
CellDeviation( 6 ) = 3
CellDeviation( 7 ) = 3
CellDeviation( 8 ) = 3
endcase
case 4
GridSize = 150
DisplaySize = 40
SphSize = 30
CellLimit = 1000
CellHalfLimit = CellLimit / 2
NeighboursEffect = 1
NeighboursAmount = CellLimit
NewLifeOnOld = 1
AllowGlobalDeviation = 0
AllowCellDeviation = 1
SplurghIntensity = CellLimit * 2
SplurghOffset = -CellLimit
SplurghCount = 10
CellAmountsOrig( 0 ) = -100
CellAmountsOrig( 1 ) = -75
CellAmountsOrig( 2 ) = -25
CellAmountsOrig( 3 ) = 1
CellAmountsOrig( 4 ) = 45
CellAmountsOrig( 5 ) = 30
CellAmountsOrig( 6 ) = -5
CellAmountsOrig( 7 ) = -40
CellAmountsOrig( 8 ) = -100
CellBirth( 0 ) = 0
CellBirth( 1 ) = 0
CellBirth( 2 ) = 0
CellBirth( 3 ) = 1
CellBirth( 4 ) = 1
CellBirth( 5 ) = 0
CellBirth( 6 ) = 0
CellBirth( 7 ) = 0
CellBirth( 8 ) = 0
CellDeviation( 0 ) = 0
CellDeviation( 1 ) = 1
CellDeviation( 2 ) = 3
CellDeviation( 3 ) = 3
CellDeviation( 4 ) = 1
CellDeviation( 5 ) = 2
CellDeviation( 6 ) = 3
CellDeviation( 7 ) = 2
CellDeviation( 8 ) = 1
endcase
case 5
GridSize = 150
DisplaySize = 70
SphSize = 9
CellLimit = 500
CellHalfLimit = CellLimit / 2
NeighboursEffect = 1
NeighboursAmount = CellLimit / 2
NewLifeOnOld = 1
AllowGlobalDeviation = 0
AllowCellDeviation = 1
SplurghIntensity = CellLimit * 2
SplurghOffset = -CellLimit
SplurghCount = 10
CellAmountsOrig( 0 ) = -100
CellAmountsOrig( 1 ) = -75
CellAmountsOrig( 2 ) = -45
CellAmountsOrig( 3 ) = 21
CellAmountsOrig( 4 ) = 75
CellAmountsOrig( 5 ) = 10
CellAmountsOrig( 6 ) = -75
CellAmountsOrig( 7 ) = -90
CellAmountsOrig( 8 ) = -100
CellBirth( 0 ) = 0
CellBirth( 1 ) = 0
CellBirth( 2 ) = 0
CellBirth( 3 ) = 1
CellBirth( 4 ) = 1
CellBirth( 5 ) = 0
CellBirth( 6 ) = 0
CellBirth( 7 ) = 0
CellBirth( 8 ) = 0
CellDeviation( 0 ) = 0
CellDeviation( 1 ) = 50
CellDeviation( 2 ) = 50
CellDeviation( 3 ) = 50
CellDeviation( 4 ) = 50
CellDeviation( 5 ) = 50
CellDeviation( 6 ) = 50
CellDeviation( 7 ) = 50
CellDeviation( 8 ) = 50
endcase
endselect
DisplayXOffset = GridSize / 2
DisplayYOffset = GridSize / 2
if DisplayXOffset + DisplaySize > GridSize
DisplayXOffset = GridSize - DisplaySize
endif
if DisplayYOffset + DisplaySize > GridSize
DisplayYOffset = GridSize - DisplaySize
endif
return
_MakeGrid:
Rem Make the Grid
Rem Make a Wire frame Box around the Cells
Rem Size of the 3D Grid
Temp1 = DisplaySize * SphSize
For CntrX = 10 to 21
Make Object Box CntrX , Temp1 , SphSize / 4 , SphSize / 4
Next CntrX
Temp1 = DisplaySize * SphSize / 2
Rem Face
Position Object 10 , 0 , -Temp1 , -Temp1
Position Object 11 , Temp1 , 0 , -Temp1
ZRotate Object 11 , 90
Position Object 12 , 0 , Temp1 , -Temp1
Position Object 13 , -Temp1 , 0 , -Temp1
ZRotate Object 13 , 270
Rem Back
Position Object 14 , 0 , -Temp1 , Temp1
Position Object 15 , Temp1 , 0 , Temp1
ZRotate Object 15 , 90
Position Object 16 , 0 , Temp1 , Temp1
Position Object 17 , -Temp1 , 0 , Temp1
ZRotate Object 17 , 270
Rem Connectors
YRotate Object 18 , 90
YRotate Object 19 , 90
YRotate Object 20 , 90
YRotate Object 21 , 90
Position Object 18 , Temp1 , Temp1 , 0
Position Object 19 , Temp1 , -Temp1 , 0
Position Object 20 , -Temp1 , Temp1 , 0
Position Object 21 , -Temp1 , -Temp1 , 0
Rem Get the Cells "look"
load image "Pictures/Cell.bmp" , 9
Rem Make a primative
MAKE OBJECT SPHERE 1 , SphSize
rem MAKE OBJECT CUBE 1 , SphSize
Texture Object 1 , 9
SET OBJECT SPECULAR POWER 1 , 50
SET OBJECT SPECULAR 1 , rgb( 255 , 128 , 96 )
Set Object Light 1 , 1
For CntrX = 0 To DisplaySize
For CntrY = 0 To DisplaySize
rem MAKE OBJECT SPHERE CellObjectOffset + CntrX * DisplaySize + CntrY , SphSize
Temp = ( DisplaySize * SphSize ) / 2
Temp1 = CellObjectOffset + CntrX * DisplaySize + CntrY
INSTANCE OBJECT Temp1 , 1
Position Object Temp1 , CntrX * SphSize - Temp , 0 , CntrY * SphSize - Temp
rem Scale OBJECT Temp1 , 1 , 1 , 1
Next CntrY
Next CntrX
hide object 1
Return
_ClearGrid:
rem Clear the Life Grid
NumberOfCycles = 0
For CntrX = 0 To GridSize
For CntrY = 0 To GridSize
LifeArray(0, CntrX , CntrY ) = 0
LifeArray(1, CntrX , CntrY ) = 0
Next CntrY
Next CntrX
gosub _ShowLife
Return
_RemoveGrid:
Rem Remove the 3D box
For CntrX = 10 to 21
Delete Object CntrX
Next CntrX
Rem Delete the Main Parent Object which will in turn delete all the other
Delete Object 1
Return
_SetUpCamera:
rem position camera 0 , ( DisplaySize * SphSize ) , 0
CamDetail.Angle1 = 10
CamDetail.Angle2 = WrapValue( 45 )
CamDetail.Dist = ( DisplaySize * SphSize ) * 1.4
CamDetail.FOV = 60
gosub _PositionCamera
rem position camera ( DisplaySize * SphSize ) / 2 , ( DisplaySize * SphSize ) , ( DisplaySize * SphSize ) / 2
rem point camera CamDetail.Dist , 0 , CamDetail.Dist
rem point camera 0 , 0 , 0
set camera fov CamDetail.FOV
Set Camera Range 1 , 5000
sync
Return
_PositionCamera:
CamDetail.PosX = CamDetail.Dist * sin( CamDetail.Angle1 ) * cos( CamDetail.Angle2 )
CamDetail.PosZ = CamDetail.Dist * sin( CamDetail.Angle1 ) * sin( CamDetail.Angle2 )
CamDetail.PosY = CamDetail.Dist * cos( CamDetail.Angle1 )
position camera CamDetail.PosX , CamDetail.PosY , CamDetail.PosZ
point camera 0 , CamDetail.LookPoint , 0
rem text 0 , 500 , str$( CamDetail.LookPoint )
Return
_ReStartLife:
gosub _RemoveGrid
gosub _StartLife
gosub _PositionCamera
return
_StartLife:
OtherArray = 0
CurrentArray = 1
gosub _PresetCells
gosub _SetUpCellAmounts
gosub _MakePanel
gosub _MakeGrid
OtherArray = 1
CurrentArray = 0
return
Function WaitMouse
repeat
ink 0 , 0
box 0 , screen height() - 40 , 70 , screen height() ,0,0,0,0
ink Clr_White , 0
text 0 , screen height() - 40 , str$( timer() )
sync
until MouseClick() > 0
EndFunction
Rem -------------------------------------------------------------------------------------------------
Function ShadowText( XPos As Integer , YPos As Integer , Msg As String , CenterIt As Boolean )
if CenterIt = 1
ink Clr_Black , Clr_White
center text XPos + 1 , YPos + 1 , Msg
center text XPos + 2 , YPos + 2 , Msg
ink Clr_White , rgb( 1 , 1 , 1 )
center text XPos , YPos , Msg
else
ink Clr_Black , Clr_White
text XPos + 1 , YPos + 1 , Msg
text XPos + 2 , YPos + 2 , Msg
ink Clr_White , rgb( 1 , 1 , 1 )
text XPos , YPos , Msg
endif
EndFunction
Rem -------------------------------------------------------------------------------------------------
Function MsgBox( Msg As String , XPos As Integer , YPos As Integer , WaitForInput As Boolean )
ReturnString As String
ReturnString = ""
Center Text XPos , YPos , Msg
sync
If WaitForInput = 1
Input ReturnString
EndIf
EndFunction ReturnString
Rem -------------------------------------------------------------------------------------------------
Function MsgC( Msg As String )
Center Text Screen Width() / 2 , 20 , Msg
sync
EndFunction
Rem -------------------------------------------------------------------------------------------------
Function Sgn( NumValue as Float )
ValueSign as integer
if NumValue = 0
ValueSign = 0
else
if NumValue < 0
ValueSign = -1
else
ValueSign = 1
endif
endif
EndFunction ValueSign
Rem -------------------------------------------------------------------------------------------------
FUNCTION Mod( Value As Integer , Modulo As Integer )
ReturnValue As Integer
ReturnValue = Value - ( ( Value / Modulo ) * Modulo )
ENDFUNCTION ReturnValue
Rem -------------------------------------------------------------------------------------------------
Function CheckCell( CheckArray As Integer , CellX As Integer , CellY As Integer )
ReturnValue As Integer
rem CheckCellRV As Integer
rem 0=No Change, >0 = Lives better, <0 = Lives worse
ReturnValue = 0
CellCntr = 0
CellValue = 0
rem Check N
If LifeArray(CheckArray, CellX, CellY - 1) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX , CellY - 1 )
EndIf
rem Check NW
If LifeArray(CheckArray, CellX - 1, CellY - 1) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX - 1 , CellY - 1 )
EndIf
rem Check NE
If LifeArray(CheckArray, CellX + 1, CellY - 1) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX + 1 , CellY - 1 )
EndIf
rem Check E
If LifeArray(CheckArray, CellX + 1, CellY) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX + 1 , CellY )
EndIf
rem Check W
If LifeArray(CheckArray, CellX - 1, CellY) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX - 1 , CellY )
EndIf
rem Check S
If LifeArray(CheckArray, CellX, CellY + 1) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX , CellY + 1 )
EndIf
rem Check SW
If LifeArray(CheckArray, CellX - 1, CellY + 1) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX - 1 , CellY + 1 )
EndIf
rem Check SE
If LifeArray(CheckArray, CellX + 1, CellY + 1) > 0
CellCntr = CellCntr + 1
CellValue = CellValue + LifeArray( CheckArray , CellX + 1 , CellY + 1 )
EndIf
ReturnValue = CellAmounts( CellCntr )
CreateLife = CellBirth( CellCntr )
remstart
If LifeArray( CheckArray, CellX , CellY ) > 0
ThereIsLife = 1
EndIf
remend
remstart
If NeighboursEffect = 1
if AllowCellDeviation = 1
ReturnValue = ( CellAmounts( CellCntr ) + Rnd( CellDeviation( CellCntr ) * 2 ) - CellDeviation( CellCntr ) ) + CellValue / NeighboursAmount
else
ReturnValue = CellAmounts( CellCntr ) + CellValue / NeighboursAmount
endif
Else
remend
remstart
if AllowCellDeviation = 1
ReturnValue = ( CellAmounts( CellCntr ) + Rnd( CellDeviation( CellCntr ) * 2 ) - CellDeviation( CellCntr ) )
else
ReturnValue = CellAmounts( CellCntr )
endif
rem EndIf
remend
ENDFUNCTION ReturnValue