Skip to content

Commit

Permalink
Rotation fitness improvements
Browse files Browse the repository at this point in the history
less computation by Sam Ferwerda's suggestion
  • Loading branch information
portaloffreedom committed Jun 4, 2020
1 parent 080b0b3 commit a317c45
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions pyrevolve/evolution/fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def rotation(robot_manager: RobotManager, _robot: RevolveBot, factor_orien_ds: f
# TODO move to measurements?
orientations: float = 0.0
delta_orientations: float = 0.0
dS: float = 0.0

assert len(robot_manager._orientations) == len(robot_manager._positions)

Expand All @@ -114,8 +113,6 @@ def rotation(robot_manager: RobotManager, _robot: RevolveBot, factor_orien_ds: f
rot_i_1 = robot_manager._orientations[i - 1]
rot_i = robot_manager._orientations[i]

dS += _distance_flat_plane(pos_i_1, pos_i)

angle_i: float = rot_i[2] # roll / pitch / yaw
angle_i_1: float = rot_i_1[2] # roll / pitch / yaw
pi_2: float = math.pi / 2.0
Expand All @@ -128,6 +125,5 @@ def rotation(robot_manager: RobotManager, _robot: RevolveBot, factor_orien_ds: f
delta_orientations = angle_i - angle_i_1
orientations += delta_orientations

print(f'orientations: {orientations} dS: {dS}')
fitness_value: float = orientations - factor_orien_ds * dS # dS in (0, 1.5) in 30s
fitness_value: float = orientations - factor_orien_ds * robot_manager._dist
return fitness_value

0 comments on commit a317c45

Please sign in to comment.