//User01: stuynaught Team: Stuy-Naught Project: move2.718
void ZRUser01(float *myState, float *otherState, float time)
{
float P[3] = {0.25, 0.25, 0};
 
if (getPercentFuelRemaining() < 10) {
myState[0] = P[0];
myState[1] = P[1];
myState[2] = P[2];
}
if (state == 0) {
}
else
if (state == 1) {
    P[1] = -0.25;
}
else
if (state == 2) {
    P[0] = -0.25;
    P[1] = -0.25;
}
else
if (state == 3) {
    P[0] = -0.25;
}
 
ZRSetPositionTarget(P);
if ( sqrt((myState[0] - P[0])*(myState[0] - P[0]) +
     (myState[1] - P[1])*(myState[1] - P[1]) +
     (myState[2] - P[2])*(myState[2] - P[2]))  < 0.05 ) {
      
     state = state+1;
      
}
 
if (state == 4) {
state = 0;
}
 
 
}
예제 #2
0
void HistDump(float * myState, float * otherState, int time) {
	float pos[3] = {0,0,0};
	int k;

	for (k=0; k<3; k++) {
		pos[k] = myState[k];
	}

	for (k=0; k<12; k++) {
		history[35*time+k] = myState[k];
		history[35*time+12+k] = otherState[k];
	}
	history[35*time+24] = iHavePanel();
	history[35*time+25] = otherHasPanel();
	history[35*time+26] = isPanelFound();
	history[35*time+27] = isPanelInSync();
	history[35*time+28] = isStationInSync();
	history[35*time+29] = getCurrentScore();
	history[35*time+30] = getOtherCurrentScore();
	history[35*time+31] = getPercentChargeRemaining();
	history[35*time+32] = getPercentFuelRemaining();
	history[35*time+33] = otherRepelling();
	history[35*time+34] = outsideBoundary(pos);
}
예제 #3
0
//User01: blakeelias Team: Stuy-Naught Project: Kill-Retreat
void ZRUser01(float *myState, float *otherState, float time)
{
#define position procvar
#define attitude (procvar+3)
#define panel_location (procvar+6)
   
memcpy(vOtherPrev, vOther, sizeof(float)*3); //original value copied to previous value
   
memcpy(vOther, otherState+3, sizeof(float)*3); // this is set to the current value
 
// Wait for them to run out of fuel (constant velocity)
if ((Vfunc(6, vOther, vOtherPrev, NULL, 0)) <= 0.01)
    counter++;
else
    counter = 0;
   
DEBUG(("time: %3.0f, SPH%d: state %i\n", time, getPanelSide() == 1 ? 1 : 2, state));
 
if (state == 1) { //Zapping
    // Get between the opponent and the sun
    memcpy(position, otherState, sizeof(float)*3);
    mathVecNormalize(position, 3);
    Vfunc(4, position, NULL, position, 0.1);
  
    CoastToTarget(myState, position, 0.04);
      
    // Face the opponent
    Vfunc(9, myState, otherState, attitude, 0);
    ZRSetAttitudeTarget(attitude);
      
    // Zap once we see them
    if (fabs (Vfunc(8, myState+6, attitude, NULL, 0)) < 6.0) {
        ZRRepel();
        }
     
           
    //DEBUG(("Counter = %i \n", counter));
 
 
    if(iHavePanel()) {
        if (counter >= 15 || getPercentFuelRemaining() < 10)
            state = 6;
    }
    else {
        if (counter >= 15 || time > 100)
            state = 2;
        else if (getPercentFuelRemaining() < 20)
            state = 3;
    }
}
   
if (state == 2) { //Moving to panel circle, they're dead
    if (isPanelFound())
        state = 5;
    else {
        attitude[0] = 0;
        attitude[1] = 1*getPanelSide();
        attitude[2] = 0;
    
        position[0] = .7*getPanelSide();
        position[1] = 0;
        position[2] = 0;
    
        CoastToTarget(myState, position, 0.04);
        ZRSetAttitudeTarget(attitude);
            
        if (Vfunc(6, myState, position, NULL, 0) < 0.03)
            state = 4;
    }
}
  
if (state == 3) { // Retreating to panel, they are alive
    if (isPanelFound())
        state = 5;
    else {
        position[0] = .7*getPanelSide();
        position[1] = 0;
        position[2] = 0;
        CoastToTarget(myState, position, 0.04);
    }
  
    if (Vfunc(6, position, myState, NULL, 0) < 0.03)
        state = 4;
}
  
if (state == 4) { //Finding panel
    RotateTarget(myState, position);
        if (isPanelFound())
            state = 5;
        if (iHavePanel())
            state = 6;
    }
           
if (state == 5) { //Get the panel
        getPanelState(position);
        attitude[0] = 0.7*getPanelSide();
        attitude[1] = attitude[2] = 0;
        Vfunc(9, attitude, position, attitude, 0);
        ZRSetAttitudeTarget(attitude);
        CoastToTarget(myState, position, 0.04);
        if (iHavePanel())
            state++;
        }
   
if (state == 6) { //Stop
    if (counter < 15)
        state = 1;
    position[0] = position[1] = position[2] = 0;
    ZRSetVelocityTarget(position);
        }
}