Beispiel #1
0
int main (int argc, char** argv){
	static int addr1;
	int addr2;
	int addr3;
	char* yos="ree";
	int * addr4 = (int*)(malloc(50));
	printf("%p\n",&addr1);
	printf("%p\n",&addr2);
	printf("%p\n",&addr3);
	printf("%p\n",foo);
	printf("%p\n",&addr5);
	point_at(&addr5);
	printf("%p\n",&addr6);
	printf("%p\n",yos);
	printf("%p\n",addr4);

    int iarray[3];
    char carray[3];

    printf("iarray0: %p\n", &iarray);
    printf("iarray1: %p\n", &iarray[1]);
    printf("iarray2: %p\n", &iarray[2]);
    printf("carray0: %p\n", &carray);
    printf("carray1: %p\n", &carray[1]);
    printf("carray2: %p\n", &carray[2]);
    
    printf("iarray+1: %p\n", &iarray+1);
    printf("iarray+2: %p\n", &iarray+2);
    printf("carray+1: %p\n", &carray+1);
    printf("carray+2: %p\n", &carray+2);

    counter();
    counter();
    counter();
    counter();
    counter();

    {
        int x;
        printf("%p\n", &x);
    }

    {
        int y;
        printf("%p\n", &y);
    }
	return 0;
}
/**
 * The problem with this is that it doesn't really know if it's already performed turnaround,
 * and has no hysteresis, so it ends up wobbling its ass a lot, decelerating much more slowly
 * than it should be able to, and overshooting the target.
 *
 * Also for reasons I can't figure out, it only accelerates for about the first third of the trajectory,
 * instead of until halfway as it should.
 */
void SimpleShipMovementController::step(RocketShip& ship, point2 target) {
    // Angular tolerance within which directions are considered equivalent.
    const plane_angle direction_slop = ship.side_thruster_acceleration() * pow<2>(0.25*seconds);

    ship.stop_turning();
    ship.thrust_off();

    vec2<length> r = target - ship.position();
    unit_vec2 rhat(r);
    vec2<velocity> dr = ship.velocity();
    acceleration dv = ship.main_thruster_acceleration();

    // Not sure WTF these expressions mean physically, but it's the result of hours of screwing around and seems to produce nice results.
    unit_vec2 thrust_direction_towards(rhat*fudge_direction_ratio_ - dr.rejection(r)*((1-fudge_direction_ratio_)*second/meter));
    unit_vec2 thrust_direction_away(-rhat*fudge_direction_ratio_ - dr.rejection(r)*((1-fudge_direction_ratio_)*second/meter));


    time_interval time_to_target = r.magnitude() / dr.scalar_projection(r);
    time_interval time_to_stop = dr.scalar_projection(r) / dv;

    //plane_angle turnaround_delta_a = angle_difference(thrust_direction_away.angle(), ship.heading() + M_PI*radians);
    //time_interval maximum_turnaround_time = .75*seconds; // FIXME: pull this number from somewhere other than my ass
    //time_to_stop -= maximum_turnaround_time*(fabs(turnaround_delta_a) / (M_PI*radians)); // is this really linear wrt delta_a?
    /*
    if(fabs(turnaround_delta_a) > direction_slop) {
        time_to_stop -= maximum_turnaround_time*(fabs(turnaround_delta_a) / (M_PI*radians));
    }
    */

    unit_vec2 thrust_direction(0,0);
    if(time_to_target < 0*seconds || time_to_stop < time_to_target) {
        // Before turnaround - thrust towards the target.
        thrust_direction = thrust_direction_towards;
    } else {
        // After turnaround - thrust away from the target.
        thrust_direction = thrust_direction_away;
    }
    point_at(ship, thrust_direction);
    // Thrust if heading within tolerance
    if(fabs(angle_difference(thrust_direction.angle(), ship.heading())) < direction_slop) {
        ship.thrust_on();
    }
    // Finally,
    ship.update_forces();
}