File size: 924 Bytes
09a6f7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**
 * @classdesc Abstract class for swimmer morphologies.
 */
class SwimmerAbstractBody extends AbstractBody{
    /**
     * @constructor
     * @param scale {number} - Scale of the environment
     * @param motors_torque {number}
     * @param density {number} - Density of the agent's body.
     * @param nb_steps_outside_water {number}
     */
    constructor(scale, motors_torque, density, nb_steps_outside_water) {
        super(scale, motors_torque);
        this.body_type = BodyTypesEnum.SWIMMER;
        this.nb_steps_can_survive_outside_water = nb_steps_outside_water;

        // set the embodiment's density to the same value as water so that it will be in a zero-gravity setup
        this.DENSITY = density - 0.01; // Make it a little lighter such that it slowly goes up when no action is done
    }

    destroy(world) {
        super.destroy(world);
        this.fins = [];
        this.tail = null;
    }
}