No more feuilles de base si mutation avec feuilles
This commit is contained in:
@@ -77,7 +77,7 @@ func shuffle_weighted(array: Array, weights: Array[int]):
|
||||
weights[i] = originalWeights[indices[i]]
|
||||
|
||||
func get_mutation_weight(level: int) -> int:
|
||||
return 3 * level
|
||||
return 2 * level
|
||||
|
||||
func build_seed_texture(random_seed: int) -> Texture:
|
||||
rng.seed = random_seed
|
||||
@@ -126,16 +126,19 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
var weight_per_origin_type: Array[int] = origin_weights_base.values().duplicate()
|
||||
|
||||
var parts_to_place: Dictionary[OriginType, Array] # BRANCH_ORIGIN : Array[PlantPart], MUTATION_ORIGIN : Array[Array[PlantPart]], BASE_LEAF_ORIGIN : Array[PlantPart]
|
||||
parts_to_place[OriginType.BRANCH_ORIGIN] = branches
|
||||
parts_to_place[OriginType.BRANCH_ORIGIN] = branches.duplicate()
|
||||
parts_to_place[OriginType.MUTATION_ORIGIN] = []
|
||||
parts_to_place[OriginType.BASE_LEAF_ORIGIN] = base_leaves
|
||||
parts_to_place[OriginType.BASE_LEAF_ORIGIN] = base_leaves.duplicate()
|
||||
var mutation_weights: Array[int] = []
|
||||
for mutation in plant_data.mutations:
|
||||
if mutation.id in parts_mutation_associations:
|
||||
parts_to_place[OriginType.MUTATION_ORIGIN].append(parts_mutation_associations[mutation.id].parts)
|
||||
var mutation_parts := parts_mutation_associations[mutation.id].parts
|
||||
parts_to_place[OriginType.MUTATION_ORIGIN].append(mutation_parts)
|
||||
var mutation_weight := get_mutation_weight(mutation.level)
|
||||
mutation_weights.append(mutation_weight)
|
||||
weight_per_origin_type[OriginType.MUTATION_ORIGIN] += mutation_weight
|
||||
if len(parts_to_place[OriginType.BASE_LEAF_ORIGIN]) > 0 and mutation_parts[0].type == PlantPart.PartType.LEAF_PART:
|
||||
parts_to_place[OriginType.BASE_LEAF_ORIGIN].clear()
|
||||
|
||||
var flipped: bool = rng.randi() % 2 == 0
|
||||
|
||||
@@ -197,8 +200,8 @@ func get_part(all_parts: Dictionary[OriginType, Array], weight_per_origin_type:
|
||||
var ind := find_random_matching_attach_ind(attach, all_parts[origin])
|
||||
if ind >= 0:
|
||||
weight_per_origin_type[origin] -= origin_weight_loss
|
||||
weight_per_origin_type[((origin + 1) % 3) as OriginType] += origin_weight_gain
|
||||
weight_per_origin_type[((origin + 2) % 3) as OriginType] += origin_weight_gain
|
||||
for i in range(len(weight_per_origin_type) - 1):
|
||||
weight_per_origin_type[((origin + i + 1) % 3)] += origin_weight_gain
|
||||
return all_parts[origin][ind]
|
||||
else: # find a mutation part to place
|
||||
if weight_copy[originIndInd] < 0:
|
||||
@@ -213,8 +216,8 @@ func get_part(all_parts: Dictionary[OriginType, Array], weight_per_origin_type:
|
||||
mutation_weights[i] += mutation_weight_gain
|
||||
mutation_weights[mutation_parts_ind] -= mutation_weight_gain + mutation_weight_loss
|
||||
weight_per_origin_type[origin] -= origin_weight_loss
|
||||
weight_per_origin_type[(origin + 1) % 3] += origin_weight_gain
|
||||
weight_per_origin_type[(origin + 2) % 3] += origin_weight_gain
|
||||
for i in range(len(weight_per_origin_type) - 1):
|
||||
weight_per_origin_type[((origin + i + 1) % 3)] += origin_weight_gain
|
||||
return parts_per_mutations[mutation_parts_ind][ind]
|
||||
return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user