11using System . Collections ;
22using System . Collections . Generic ;
3+ using Unity . VisualScripting ;
34using UnityEngine ;
45
56public class PathPheromoneLife : ILife
67{
78 private DrawGrid drawGrid ;
8- private int xBound = 15 ;
9- private int yBound = 15 ;
9+ private int xBound = 35 ;
10+ private int yBound = 35 ;
1011 private System . Random random = new ( ) ;
1112
1213 public PathPheromoneLife ( DrawGrid grid )
@@ -26,7 +27,7 @@ public HashSet<Cell> Step(HashSet<Cell> currentCells)
2627 if ( cell . state == CellState . alive )
2728 {
2829 aliveCount ++ ;
29- Vector3Int nextPosition = new Vector3Int ( 0 , 0 , 0 ) ;
30+ Vector3Int nextPosition = cell . position ;
3031 List < Vector3Int > nextPositions = new List < Vector3Int > ( ) ; // best options list
3132 int nextPositionPriority = 0 ;
3233 List < Vector3Int > availablePositions = GetAvailablePositions ( cell . position , takenPositions ) ;
@@ -63,12 +64,12 @@ public HashSet<Cell> Step(HashSet<Cell> currentCells)
6364 nextPosition = nextPositions [ randomIndex ] ;
6465 }
6566
66- // Random chance of wandering to dead/empty space instead
67- if ( ! takenPositions . Contains ( emptyPosition ) && UnityEngine . Random . value > drawGrid . wanderChance )
68- nextPosition = emptyPosition ;
69-
70- if ( nextPosition == new Vector3Int ( 0 , 0 , 0 ) )
71- Debug . Log ( "nextPosition never changed" ) ;
67+ // Random chance of birth (uses wandering chance) to dead/empty space
68+ if ( ! takenPositions . Contains ( emptyPosition ) && UnityEngine . Random . value > .99 )
69+ {
70+ newCells . Add ( new Cell ( emptyPosition , CellState . alive ) ) ;
71+ takenPositions . Add ( emptyPosition ) ; // Ensure position isn't taken twice
72+ }
7273
7374 // Move to next position
7475 newCells . Add ( new Cell ( nextPosition , CellState . alive ) ) ;
@@ -124,15 +125,15 @@ private int GetPriority(CellState state)
124125
125126 if ( state == CellState . alive )
126127 priority = 6 ;
127- else if ( state == CellState . stage2 )
128- priority = 5 ;
129128 else if ( state == CellState . stage3 )
130- priority = 4 ;
129+ priority = 5 ;
131130 else if ( state == CellState . stage4 )
132- priority = 3 ;
131+ priority = 4 ;
133132 else if ( state == CellState . stage5 )
134- priority = 2 ;
133+ priority = 3 ;
135134 else if ( state == CellState . dead )
135+ priority = 2 ;
136+ else if ( state == CellState . stage2 )
136137 priority = 1 ;
137138 else
138139 priority = 0 ;
0 commit comments