Adds mutation

This commit is contained in:
Mark Hoekveen
2019-10-28 13:47:26 +01:00
parent cc2a677005
commit 57a712f140
2 changed files with 13 additions and 10 deletions
+3
View File
@@ -1,5 +1,6 @@
extends Node extends Node
export (PackedScene) var Creature export (PackedScene) var Creature
export (float) var mutation_rate = 0.05
var selected = [] var selected = []
var rng = RandomNumberGenerator.new() var rng = RandomNumberGenerator.new()
@@ -32,6 +33,8 @@ func combine_a_bitch():
new_dna.append(selected[0].dna[i]) new_dna.append(selected[0].dna[i])
else: else:
new_dna.append(selected[1].dna[i]) new_dna.append(selected[1].dna[i])
if rng.randf() <= mutation_rate:
new_dna.append(!new_dna.pop_back())
var new_child = spawn_a_bitch() var new_child = spawn_a_bitch()
new_child.dna = new_dna new_child.dna = new_dna
deselect_all() deselect_all()
+10 -10
View File
@@ -30,7 +30,7 @@ background_sky = SubResource( 5 )
[sub_resource type="World" id=7] [sub_resource type="World" id=7]
environment = SubResource( 6 ) environment = SubResource( 6 )
[sub_resource type="ProceduralSky" id=10] [sub_resource type="ProceduralSky" id=8]
sky_top_color = Color( 0, 0, 0, 1 ) sky_top_color = Color( 0, 0, 0, 1 )
sky_horizon_color = Color( 0, 0, 0, 1 ) sky_horizon_color = Color( 0, 0, 0, 1 )
ground_bottom_color = Color( 0, 0, 0, 1 ) ground_bottom_color = Color( 0, 0, 0, 1 )
@@ -38,14 +38,14 @@ ground_horizon_color = Color( 0, 0, 0, 1 )
sun_latitude = 137.19 sun_latitude = 137.19
sun_energy = 14.21 sun_energy = 14.21
[sub_resource type="Environment" id=11] [sub_resource type="Environment" id=9]
background_mode = 2 background_mode = 2
background_sky = SubResource( 10 ) background_sky = SubResource( 8 )
[sub_resource type="World" id=12] [sub_resource type="World" id=10]
environment = SubResource( 11 ) environment = SubResource( 9 )
[sub_resource type="ProceduralSky" id=8] [sub_resource type="ProceduralSky" id=11]
sky_top_color = Color( 0, 0, 0, 1 ) sky_top_color = Color( 0, 0, 0, 1 )
sky_horizon_color = Color( 0, 0, 0, 1 ) sky_horizon_color = Color( 0, 0, 0, 1 )
sky_curve = 1.44 sky_curve = 1.44
@@ -57,9 +57,9 @@ sun_color = Color( 0.835294, 0.462745, 0.462745, 1 )
sun_latitude = 11.29 sun_latitude = 11.29
sun_energy = 20.16 sun_energy = 20.16
[sub_resource type="Environment" id=9] [sub_resource type="Environment" id=12]
background_mode = 2 background_mode = 2
background_sky = SubResource( 8 ) background_sky = SubResource( 11 )
background_color = Color( 0.803922, 0.54902, 0.333333, 0.196078 ) background_color = Color( 0.803922, 0.54902, 0.333333, 0.196078 )
tonemap_mode = 2 tonemap_mode = 2
auto_exposure_speed = 3.15 auto_exposure_speed = 3.15
@@ -161,7 +161,7 @@ rect_scale = Vector2( 0.5, 0.5 )
[node name="Viewport" type="Viewport" parent="GUI/Preview1"] [node name="Viewport" type="Viewport" parent="GUI/Preview1"]
size = Vector2( 640, 480 ) size = Vector2( 640, 480 )
world = SubResource( 12 ) world = SubResource( 10 )
handle_input_locally = false handle_input_locally = false
render_target_update_mode = 3 render_target_update_mode = 3
gui_disable_input = true gui_disable_input = true
@@ -181,7 +181,7 @@ script = ExtResource( 3 )
Creature = ExtResource( 2 ) Creature = ExtResource( 2 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 9 ) environment = SubResource( 12 )
[connection signal="pressed" from="GUI/Spawn" to="CreatureLab" method="spawn_a_bitch"] [connection signal="pressed" from="GUI/Spawn" to="CreatureLab" method="spawn_a_bitch"]
[connection signal="pressed" from="GUI/Kill" to="CreatureLab" method="kill_a_bitch"] [connection signal="pressed" from="GUI/Kill" to="CreatureLab" method="kill_a_bitch"]
[connection signal="pressed" from="GUI/Button" to="CreatureLab" method="combine_a_bitch"] [connection signal="pressed" from="GUI/Button" to="CreatureLab" method="combine_a_bitch"]