-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimulator.v
1458 lines (1286 loc) · 32.2 KB
/
simulator.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
author: Robin T. Gruenke
* date: 13.12.2021
* licencse: GNU General Public License v3.0
*/
module main
import gg
import gx
import rand
import rand.util as rutil
import time
import os
const (
win_width = 800
win_height = 800
lower_color_space = 0x3f
upper_color_space = 0xcf
max_temp = 32
repro_age = 40
repro_cost = 15
sharing_success_chance = 1
init_creature_count = 1000
)
struct App {
mut:
gg &gg.Context
grid [][]GridTile
creature_count int
ticks i64 = time.ticks()
accumulator i64
tick_count i64
update_time int = 100
paused bool
debug bool
show_grid bool
debug_grid [][]DebugGridTile = [][]DebugGridTile{}
seed []u32
mode Mode
}
enum UpdateThreshold {
slower
faster
even_slower
even_faster
}
fn (mut app App) refresh_update_threshold(t UpdateThreshold) {
match t {
.slower { app.update_time += 10 }
.faster { app.update_time -= 10 }
.even_slower { app.update_time += 100 }
.even_faster { app.update_time -= 100 }
}
if app.update_time < 0 {
app.update_time = 0
}
}
fn (mut app App) reset() {
app.grid = [][]GridTile{}
app.ticks = time.ticks()
app.accumulator = 0
app.debug_grid = [][]DebugGridTile{}
app.tick_count = 0
init(mut app)
}
struct Pause {}
struct Jump {
to_tick i64
}
struct Play {}
struct WaitForInput {
next_mode Mode
}
type Mode = Jump | Pause | Play | WaitForInput
struct Coordinate {
x f32
y f32
}
struct DebugGridTile {
Coordinate
color gx.Color
}
struct GridTile {
Coordinate
mut:
occupation Occupation
}
struct SomethingElse {}
type Inhabitant = Creature | SomethingElse
struct Occupied {
mut:
inhabitant Inhabitant
}
struct Empty {}
struct BedRock {}
type Occupation = BedRock | Empty | Occupied
struct Creature {
mut:
genome Genome
age byte
color gx.Color
life Life
reproduced bool
temp byte
received_temp byte
generation int
debug bool
}
fn (c &Creature) is_debug() bool {
return c.debug
}
fn (mut c Creature) use_movement_energy() {
mut nt := c.temp - 1
if c.genome.immune_system.has(.defender) {
nt -= 5
}
if c.genome.immune_system.all(.defender | .strong_defender) {
nt -= 15
}
if c.genome.social.has(.predator) {
nt -= 5
}
if nt == 0 || c.temp < nt {
nt = 0
c.life = .dead
}
c.temp = nt
if c.received_temp > 0 {
if c.received_temp <= 10 {
c.received_temp -= 1
}
if c.received_temp >= 25 {
c.received_temp -= 5
}
}
}
fn (mut c Creature) loose_neighbour_temp() {
c.received_temp = 0
}
fn (mut c Creature) exchange_temp() {
if c.temp < 30 {
c.temp += 2
}
if c.received_temp > 180 {
c.received_temp += 0
} else if c.received_temp > 120 {
c.received_temp += 1
} else if c.received_temp > 25 {
c.received_temp += 10
} else {
c.received_temp += 50
}
}
fn (mut c Creature) flag_as_debug() {
dg := debug_genome()
c.genome = dg
c.color = color_space(dg)
c.life = .alive
c.temp = 255
c.debug = true
}
fn (mut c Creature) ages(a byte) {
na := c.age + a
if na == 255 || na < c.age {
c.age = 255
} else {
c.age = na
}
}
fn (mut c Creature) add_temp(t byte) {
nt := c.temp + t
if nt >= max_temp {
c.temp = max_temp
} else {
c.temp = nt
}
}
fn (mut c Creature) remove_temp(t byte) {
nt := c.temp - t
if nt <= 0 || nt > c.temp {
c.temp = 0
c.life = .dead
} else {
c.temp = nt
}
}
enum Life {
alive
dead
}
struct Genome {
mut:
movement MovementGene
direction_sensor DirectionSensorGene
metabolism MetabolismGene
social SocialGene
ageing AgeingGene
immune_system ImmuneSystemGene
mutation_rate MutationRateGene
}
[flag]
enum MutationRateGene {
slower
slow
normal
fast
faster
insane
}
[flag]
enum ImmuneSystemGene {
normal
defender
strong_defender
}
[flag]
enum AgeingGene {
faster
fast
normal
slow
slower
}
[flag]
enum MovementGene {
able
unable
}
[flag]
enum MetabolismGene {
slow
normal
fast
}
[flag]
enum DirectionSensorGene {
north
east
south
west
center
}
fn (dsg DirectionSensorGene) sum() byte {
// print(byte(dsg))
// print('|')
return byte(dsg)
}
[flag]
enum SocialGene {
normal
sharing
predator
}
enum Direction {
north
east
south
west
}
fn main() {
mut app := &App{
gg: 0
mode: Play{}
}
app.gg = gg.new_context(
bg_color: gx.white
width: win_width
height: win_height
borderless_window: true
resizable: false
create_window: true
window_title: 'Rectangles'
frame_fn: frame
user_data: app
init_fn: init
keydown_fn: on_keydown
click_fn: on_click
)
app.gg.run()
}
[live]
fn init(mut app App) {
if app.seed.len == 2 {
println('seeding fixed: $app.seed')
rand.seed(app.seed)
}
mut creatures := init_creatures(init_creature_count)
creatures[100].flag_as_debug()
grid := init_grid(mut creatures)
app.grid = grid
}
fn init_creatures(count int) []Creature {
mut creatures := []Creature{len: count, cap: count}
for mut c in creatures {
c = init_creature(genome: rand_genome())
}
return creatures
}
[params]
struct CreatureConfig {
genome Genome = rand_genome()
}
fn init_creature(cfg CreatureConfig) Creature {
color := color_space(cfg.genome)
life := match rand.int_in_range(0, 64) {
0 { Life.dead }
else { Life.alive }
}
temp := if life == .dead { 0 } else { 32 }
c := Creature{
genome: cfg.genome
color: color
life: life
temp: byte(temp)
}
return c
}
fn init_grid(mut creatures []Creature) [][]GridTile {
mut grid := [][]GridTile{len: 80, cap: 80, init: []GridTile{len: 80, cap: 80}}
for i, mut row in grid {
for j, mut tile in row {
tile = GridTile{
x: j * 10
y: i * 10
occupation: Empty{}
}
if creatures.len > 0 && rand.int_in_range(0, 4) == 1 {
c := creatures.pop()
tile.occupation = Occupied{
inhabitant: c
}
}
}
}
return grid
}
fn frame(mut app App) {
match app.mode {
Pause {}
WaitForInput {
inp := os.input('Input tick to jump to (current: $app.tick_count):')
mode := app.mode as WaitForInput
match mode.next_mode {
Pause {
app.mode = mode.next_mode
}
WaitForInput {
app.mode = mode.next_mode
}
Jump {
to_tick := inp.i64()
println('Jumping to tick: $to_tick ... this might take some time ...')
app.mode = Jump{
to_tick: to_tick
}
}
Play {
app.mode = mode.next_mode
}
}
}
Jump {
mode := app.mode as Jump
if mode.to_tick == app.tick_count {
println('Jumped to tick $mode.to_tick, press space to continue ...')
app.mode = Pause{}
app.gg.begin()
app.draw()
app.gg.end()
} else {
run_tick(mut app)
}
}
Play {
run_tick(mut app)
app.gg.begin()
app.draw()
app.gg.end()
}
}
}
fn run_tick(mut app App) {
now := time.ticks()
if app.accumulator >= app.update_time {
for i, mut row in app.grid {
for j, mut tile in row {
creature_moves(mut app, mut row, mut tile, i, j)
creature_reproduces(mut app, mut row, mut tile, i, j)
creature_hunts(mut app, mut row, mut tile, i, j)
creature_exchanges_temp(mut app, mut row, mut tile, i, j)
// creatures eat, gain energy and temp
creature_dies_of_age(mut tile)
// creatures die of starvation
// creatures die of heat death
// creatures die of cold death
// creatures die of disease
creature_ages(mut tile)
if app.tick_count % 50 == 0 {
creature_decays(mut tile)
}
}
}
app.accumulator = 0
app.tick_count += 1
}
app.accumulator += now - app.ticks
app.ticks = now
}
[live]
fn (app &App) draw() {
for row in app.grid {
for tile in row {
if app.show_grid {
draw_grid(app, tile)
}
match tile.occupation {
Empty {}
BedRock {}
Occupied {
inhabitant := tile.occupation.inhabitant
match inhabitant {
Creature {
if app.debug {
// if inhabitant.is_debug() {
// draw_debug_movement_tracing(app, tile, color_space(inhabitant.genome))
// draw_debug_mark_creature(app, tile)
// }
if inhabitant.genome.movement.has(.able) {
draw_debug_mark_creature(app, tile, gx.rgba(0x60,
0xa0, 0x80, 0xff))
}
}
draw_creature(app, tile, inhabitant)
}
SomethingElse {}
}
}
}
}
}
}
fn draw_creature(app &App, tile &GridTile, c Creature) {
color := c.color
size := match_creature_draw_size(c)
match c.life {
.alive {
app.gg.draw_circle_with_segments(tile.x + 5, tile.y + 5, size, 30, color)
}
.dead {
app.gg.draw_circle_line(tile.x + 5, tile.y + 5, 3, 15, color)
}
}
}
fn match_creature_draw_size(c Creature) f32 {
size := match true {
c.age < 5 {1.5}
c.age < 20 {2.0}
else {2.5}
}
return f32(size)
}
fn draw_debug_mark_creature(app &App, tile GridTile, color gx.Color) {
app.gg.draw_circle_line(tile.x + 5, tile.y + 5, 5, 15, color)
}
fn draw_debug_movement_tracing(app &App, tile GridTile, color gx.Color) {
for tile_pair in app.debug_grid {
app.gg.draw_line(tile_pair[0].x + 5, tile_pair[0].y + 5, tile_pair[1].x + 5,
tile_pair[1].y + 5, color)
}
}
fn draw_grid(app &App, tile GridTile) {
app.gg.draw_empty_rect(tile.x, tile.y, 10, 10, gx.rgba(0, 0, 0, 10))
}
fn on_click(x f32, y f32, btn gg.MouseButton, mut app App) {
match app.mode {
Pause {
if btn == .left {
ix := int(x)
iy := int(y)
for row in app.grid {
for tile in row {
if ix >= tile.x && ix <= tile.x + 10 && iy >= tile.y && iy <= tile.y + 10 {
match tile.occupation {
Occupied {
match tile.occupation.inhabitant {
Creature {
dump(tile.occupation.inhabitant)
}
SomethingElse {}
}
}
Empty {}
BedRock {}
}
}
}
}
}
}
else {}
}
}
fn on_keydown(code gg.KeyCode, mod gg.Modifier, mut app App) {
match app.mode {
Play {
match code {
.space {
app.mode = Pause{}
}
.d {
app.debug = !app.debug
}
.r {
app.reset()
}
.g {
app.show_grid = !app.show_grid
}
.t {
if mod == .shift {
app.mode = WaitForInput{
next_mode: Jump{}
}
} else {
println('Current tick: $app.tick_count')
}
}
.right {
if mod == .shift {
app.refresh_update_threshold(.faster)
} else {
app.refresh_update_threshold(.even_faster)
}
}
.left {
if mod == .shift {
app.refresh_update_threshold(.slower)
} else {
app.refresh_update_threshold(.even_slower)
}
}
else {}
}
}
Pause {
match code {
.space { app.mode = Play{} }
else {}
}
}
Jump {}
WaitForInput {}
}
}
fn creature_ages(mut tile GridTile) {
match tile.occupation {
Occupied {
occupation := tile.occupation as Occupied
inhabitant := occupation.inhabitant
match inhabitant {
Creature {
mut c := inhabitant as Creature
if c.life == .dead {
return
}
match c.genome.ageing {
.faster {
c.ages(0xa)
}
.fast {
c.ages(0x8)
}
.normal {
c.ages(0x5)
}
.slow {
c.ages(0x2)
}
.slower {
c.ages(0x1)
}
}
tile.occupation = Occupied{c}
}
SomethingElse {}
}
}
else {}
}
}
fn creature_decays(mut tile GridTile) {
match tile.occupation {
Occupied {
occupation := tile.occupation as Occupied
inhabitant := occupation.inhabitant
match inhabitant {
Creature {
c := inhabitant as Creature
if c.life == .dead {
tile.occupation = Empty{}
}
}
else {}
}
}
else {}
}
}
fn creature_dies_of_age(mut tile GridTile) {
match tile.occupation {
Occupied {
occupation := tile.occupation as Occupied
inhabitant := occupation.inhabitant
match inhabitant {
Creature {
mut c := inhabitant as Creature
if c.life == .dead {
return
}
if c.age > 100 && c.age < 200 {
match rand.int_in_range(0, 1000) {
0 {
c.life = .dead
tile.occupation = Occupied{c}
}
else {}
}
} else if c.age > 200 && c.age < 255 {
match rand.int_in_range(0, 140) {
0 {
c.life = .dead
tile.occupation = Occupied{c}
}
else {}
}
} else if c.age == 255 {
match rand.int_in_range(0, 10) {
0 {
c.life = .dead
tile.occupation = Occupied{c}
}
else {}
}
} else {
}
}
SomethingElse {}
}
}
else {}
}
}
fn creature_exchanges_temp(mut app App, mut row []GridTile, mut tile GridTile, i int, j int) {
match tile.occupation {
Occupied {
occupation := tile.occupation as Occupied
inhabitant := occupation.inhabitant
match inhabitant {
Creature {
mut c := inhabitant as Creature
mut neighbour_count := 0
sharing_xor_predator := (SocialGene.sharing | SocialGene.predator) & c.genome.social
if !c.genome.social.has(sharing_xor_predator) {
return
}
for dir in [Direction.north, Direction.east, Direction.south, Direction.west] {
row_index, tile_index := match_direction(dir, i, j)
n_row := app.grid[row_index] or { continue }
n_tile := n_row[tile_index] or { continue }
match n_tile.occupation {
Occupied {
o := n_tile.occupation as Occupied
n_inhabitant := o.inhabitant
match n_inhabitant {
Creature {
n_creature := n_inhabitant as Creature
n_is_alive := n_creature.life == .alive
n_has_dispostion := n_creature.genome.social.has(sharing_xor_predator)
n_has_similar_genome := has_similiar_genome(c.genome, n_creature.genome, 3)
sharing_success := random_chance(sharing_success_chance)
if n_is_alive && n_has_dispostion && n_has_similar_genome && sharing_success {
neighbour_count += 1
c.exchange_temp()
tile.occupation = Occupied{c}
}
}
else {}
}
}
else {}
}
}
if neighbour_count == 0 {
c.loose_neighbour_temp()
tile.occupation = Occupied{c}
}
}
SomethingElse {}
}
}
Empty {}
BedRock {}
}
}
fn creature_hunts(mut app App, mut row []GridTile, mut tile GridTile, i int, j int) {
match tile.occupation {
Empty {}
BedRock {}
Occupied {
occupation := tile.occupation as Occupied
mut inhabitant := occupation.inhabitant
match inhabitant {
Creature {
mut c := occupation.inhabitant as Creature
if !c.genome.social.has(.predator) {
return
}
if c.life == .dead || c.genome.movement == .unable {
return
}
mut chance_of_hunting := match c.genome.metabolism {
.slow { rand.int_in_range(4, 64) }
.normal { rand.int_in_range(4, 32) }
.fast { rand.int_in_range(4, 8) }
}
chance_of_hunting = if c.temp < 20 {
chance_of_hunting / 2
} else if c.temp < 15 {
2
} else {
chance_of_hunting
}
match rand.int_in_range(0, chance_of_hunting) {
0 {
if c.genome.direction_sensor.has(.north) {
hunt_direction(mut app, mut tile, mut c, Direction.north,
i, j)
}
}
1 {
if c.genome.direction_sensor.has(.east) {
hunt_direction(mut app, mut tile, mut c, Direction.east,
i, j)
}
}
2 {
if c.genome.direction_sensor.has(.south) {
hunt_direction(mut app, mut tile, mut c, Direction.south,
i, j)
}
}
3 {
if c.genome.direction_sensor.has(.west) {
hunt_direction(mut app, mut tile, mut c, Direction.west,
i, j)
}
}
else {}
}
}
SomethingElse {}
}
}
}
}
fn hunt_direction(mut app App, mut tile GridTile, mut inhabitant Creature, dir Direction, i int, j int) {
row_index, tile_index := match_direction(dir, i, j)
mut neighbour_row := app.grid[row_index] or { return }
mut neighbour_tile := neighbour_row[tile_index] or { return }
match neighbour_tile.occupation {
Empty {}
BedRock {}
Occupied {
o := neighbour_tile.occupation as Occupied
mut n_creature := o.inhabitant as Creature
if has_similiar_genome(inhabitant.genome, n_creature.genome, rand.int_in_range(1,4)) && inhabitant.temp > 10 {
return
}
if n_creature.life == .dead {
inhabitant.add_temp(2)
} else if n_creature.genome.immune_system.has(.defender) {
inhabitant.remove_temp(byte(rand.int_in_range(1, 5)))
n_creature.remove_temp(byte(rand.int_in_range(1, 5)))
if n_creature.genome.immune_system.has(.strong_defender) {
inhabitant.remove_temp(byte(rand.int_in_range(1, 5)))
n_creature.remove_temp(byte(rand.int_in_range(1, 3)))
}
} else {
inhabitant.add_temp(n_creature.temp)
n_creature.life = .dead
}
if n_creature.life == .dead {
inhabitant.add_temp(n_creature.temp + 2)
inhabitant.use_movement_energy()
neighbour_tile.occupation = Occupied{inhabitant}
app.grid[row_index][tile_index] = neighbour_tile
tile.occupation = Empty{}
}
}
}
}
fn creature_moves(mut app App, mut row []GridTile, mut tile GridTile, i int, j int) {
match tile.occupation {
Empty {}
BedRock {}
Occupied {
occupation := tile.occupation as Occupied
mut inhabitant := occupation.inhabitant
match inhabitant {
Creature {
mut c := occupation.inhabitant as Creature
if c.life == .dead || c.genome.movement == .unable {
return
}
if c.genome.social.has(.predator) && c.temp > 20 && c.age < repro_age {
return
}
mut chance_of_moving := match c.genome.metabolism {
.slow { rand.int_in_range(4, 64) }
.normal { rand.int_in_range(4, 32) }
.fast { rand.int_in_range(4, 8) }
}
if c.genome.immune_system.has(.defender) {
chance_of_moving = chance_of_moving * 5
}
if c.genome.social.has(.sharing) {
if c.received_temp > 0 {
chance_of_moving = chance_of_moving * c.received_temp
}
}
match rand.int_in_range(0, chance_of_moving) {
0 {
if c.genome.direction_sensor.has(.north) {
move_direction(mut app, mut tile, mut c, Direction.north,
i, j)
}
}
1 {
if c.genome.direction_sensor.has(.east) {
move_direction(mut app, mut tile, mut c, Direction.east,
i, j)
}
}
2 {
if c.genome.direction_sensor.has(.south) {
move_direction(mut app, mut tile, mut c, Direction.south,
i, j)
}
}
3 {
if c.genome.direction_sensor.has(.west) {
move_direction(mut app, mut tile, mut c, Direction.west,
i, j)
}
}
else {}
}
}
SomethingElse {}
}
}
}
}
fn move_direction(mut app App, mut tile GridTile, mut c Creature, dir Direction, i int, j int) {
row_index, tile_index := match_direction(dir, i, j)
mut neighbour_row := app.grid[row_index] or { []GridTile{} }
mut neighbour_tile := neighbour_row[tile_index] or { create_bedrock() }
match neighbour_tile.occupation {
Empty {
c.use_movement_energy()
neighbour_tile.occupation = Occupied{c}
tile.occupation = Empty{}
app.grid[row_index][tile_index] = neighbour_tile
if app.debug && c.is_debug() {
debug_movement(mut app, tile, neighbour_tile)
}
}
BedRock {}
Occupied {}
}
}
fn creature_reproduces(mut app App, mut row []GridTile, mut tile GridTile, i int, j int) {
match tile.occupation {
Occupied {
occupation := tile.occupation as Occupied
inhabitant := occupation.inhabitant