int main() { float a,b; long mn,ma,mb,ua,ub,ta,tb,l,mx; long pa,pb; scanf("%f%f",&a,&b); ta=long(a*100+0.1); tb=long(b*100+0.1); scanf("%d",&mn); for (ma=0;ma<=mn;ma++) if ((ma+ma+1)*100>=ta) break; ma=minn(ma,mn); for (mb=0;mb<=mn;mb++) if ((mb+mb+1)*100>=tb) break; mb=minn(mb,mn); mx=-1; for (ua=0;ua<=ma;ua++) { ub=minn(mn-ua,mb); l=ua*ta+ub*tb-100*ua*ua-100*ub*ub; if (l>mx) { mx=l; pa=ua; pb=ub; } } printf("%d.",mx/100); mx=mx%100; if (mx<10) printf("%d",0); printf("%d\n",mx); printf("%d %d\n",pa,pb); return 0; }
int main() { float a,b,l,mx; long mn,ma,mb,ua,ub; long pa,pb; scanf("%f%f",&a,&b); scanf("%d",&mn); for (ma=0;ma<=mn;ma++) if ((ma+ma+1)>=a) break; ma=minn(ma,mn); for (mb=0;mb<=mn;mb++) if ((mb+mb+1)>=b) break; mb=minn(mb,mn); mx=-1; for (ub=0;ub<=mb;ub++) { ua=minn(mn-ub,ma); l=ua*a+ub*b-ua*ua-ub*ub; if (l>mx) { mx=l; pa=ua; pb=ub; } } printf("%.2f\n%d %d\n",mx,pa,pb); return 0; }
int compute_time_step(double d[MAXSIZE][MAXSIZE],double new_d[MAXSIZE][MAXSIZE], double theta_hat[MAXSIZE][MAXSIZE],double new_theta[MAXSIZE][MAXSIZE], double *new_deltat) { double deltat_courant = d[2][2]; double deltat_conduct = fabs((theta_hat[2][2]-new_theta[2][2])/theta_hat[2][2]); /* double deltat_conduct = get_deltat_conduct(theta_hat,new_theta,2,2); */ double deltat_minimum; int i,j; for (i=2;i<problem_size;i++) for (j=2;j<problem_size;j++){ if (deltat_courant > d[i][j] ) deltat_courant = d[i][j]; } for (i=2;i<problem_size;i++) for (j=2;j<problem_size;j++){ double temp = fabs((theta_hat[i][j]-new_theta[i][j])/theta_hat[i][j]); /*get_deltat_conduct(theta_hat,new_theta,i,j);*/ if (deltat_conduct < temp) deltat_conduct = temp; } deltat_minimum = minn(deltat_courant, deltat_conduct); *new_deltat = minn(deltat_maximum,deltat_minimum); };
int check(int p,int q,int pp,int qq,int step) { int i,l,r,x; int direc=pp>p?1:-1; //printf("%d %d %d\n",l,r,x); for(i=1;i<=step;i++) { l=maxx(1,maxx(q-i,qq-(dist-i))); //printf("%d %d %d %d\n",i,l,r,x); r=minn(n,minn(q+i,qq+(dist-i))); x=p+direc*i; //printf("%d %d %d %d\n",i,l,r,x); if(((x==p3-i||x==p3+i)&&havecross(l,r,q3-i,q3+i)) ||(aabs(p3,x)<i&&(inbox(q3-i,l,r)||inbox(q3+i,l,r)))) return i; } return INF; }
void did() { dist=aabs(p1,p2); //printf("%d\n",dist); //printf("%d %d\n",check(p1,q1,p2,q2,dist/2-1),check(p2,q2,p1,q1,dist/2-1)); ans=minn(check(p1,q1,p2,q2,dist/2-1),check(p2,q2,p1,q1,dist/2-1)); //printf("%d\n",ans); if(ans!=INF) { ok=1; } }
void gxPutImage (GXHEADER *hp, int mode, int x, int y, int op2) { int row, col, from_idx, to_idx; int clip_x, clip_y; SDL_Rect r; assert(op2 == 0); assert(hp); assert(mode == gxSET || mode == gxXOR); assert(0 <= x && x < MAX_X); assert(0 <= y && y < MAX_Y); clip_y = minn(hp->h + y, MAX_Y) - y; clip_x = minn(hp->w + x, MAX_X) - x; switch (mode) { case gxSET: for (row = 0; row < clip_y; row++) { from_idx = row * hp->w; to_idx = (y + row) * MAX_X + x; memcpy(&screen[to_idx], &hp->vptr[from_idx], clip_x); } break; case gxXOR: for (row = 0; row < clip_y; row++) { from_idx = row * hp->w; to_idx = (y + row) * MAX_X + x; for (col = 0; col < clip_x; col++) { screen[to_idx+col] ^= hp->vptr[from_idx+col]; } } break; } r.x = x; r.y = y; r.w = clip_x; r.h = clip_y; av_need_update(&r); screen_dirty = 1; }
void gxVirtualDisplay (GXHEADER *hp, int from_x, int from_y, int to_x0, int to_y0, int to_x1, int to_y1, int always_zero) { int row, from_idx, to_idx; int width, height; int clip_x, clip_y; SDL_Rect r; assert(hp); assert(always_zero == 0); assert(0 <= from_x && from_x < hp->w); assert(0 <= from_y && from_y < hp->h); assert(to_x0 <= to_x1); assert(to_y0 <= to_y1); assert(0 <= to_x0 && to_x0 < MAX_X); assert(0 <= to_x1 && to_x1 < MAX_X); assert(0 <= to_y0 && to_y0 < MAX_Y); assert(0 <= to_y1 && to_y1 < MAX_Y); width = to_x1 - to_x0 + 1; height = to_y1 - to_y0 + 1; clip_y = minn(height + to_y0, MAX_Y) - to_y0; clip_x = minn(width + to_x0, MAX_X) - to_x0; for (row = 0; row < clip_y; row++) { from_idx = (from_y + row) * hp->w + from_x; to_idx = (to_y0 + row) * MAX_X + to_x0; memcpy(&screen[to_idx], &hp->vptr[from_idx], clip_x); } r.x = to_x0; r.y = to_y0; r.w = clip_x; r.h = clip_y; av_need_update(&r); screen_dirty = 1; }
void CalcPresRev(void) { int16_t *ip; int val, max, min, i, j; char plr; if (Data->Year == 57 && Data->Season == 0) { return; } // Move PresRev down One for (j = 0; j < NUM_PLAYERS; j++) for (i = 4; i > 0; i--) { Data->P[j].PresRev[i] = Data->P[j].PresRev[i - 1]; } Data->P[0].Prestige = Data->P[1].Prestige = 0; // Clear Prest when finished for (plr = 0; plr < NUM_PLAYERS; plr++) { ip = &Data->P[plr].PresRev[0]; max = maxx(Data->P[plr].tempPrestige[0], Data->P[plr].tempPrestige[1]); min = minn(Data->P[plr].tempPrestige[0], Data->P[plr].tempPrestige[1]); val = ((max >= 0 && min >= 0) || (max <= 0 && min <= 0)) ? max + min : max / 2 + min; *ip = (val < 0 && (*ip < 4)) ? *ip + 1 : ((val > 1 && val <= 10) ? *ip - 1 : ((val >= 11 && val <= 20) ? ((*ip < 4) ? *ip - 1 : *ip - 2) : ((val >= 21) ? ((*ip < 4) ? *ip - 1 : *ip - 3) : ((val >= -9 && val <= 0) ? *ip + 1 : ((val <= -10) ? ((plr == 0) ? *ip + Data->Def.Lev1 + 1 : *ip + Data->Def.Lev2 + 1) : *ip))))); *ip = (*ip > 16) ? 16 : ((*ip < 1) ? 1 : *ip); Data->P[plr].tempPrestige[0] = 0; Data->P[plr].tempPrestige[1] = 0; Data->P[plr].PresRev[0] += (Data->P[plr].PresRev[0] > Data->P[abs(plr - 1)].PresRev[0]) ? 1 : 0; } }
int ek() { queue<int>q; int f=0,j,u,i; for(;;) { memset(a,0,sizeof(a)); a[s]=INF; q.push(s); while(!q.empty()) { u=q.front(); q.pop(); for(i=1;i<=n;i++) { if(!a[i] && (cap[u][i] > flow[u][i]) ) { p[i]=u; q.push(i); a[i]=minn(a[u],cap[u][i]-flow[u][i]); } } } if(0 == a[t]) { return f; } j=t; while(s != j) { flow[p[j]][j] += a[t]; flow[j][p[j]] -= a[t]; j=p[j]; } f += a[t]; } }
void AIFuture(char plr, char mis, char pad, char *prog) { int i, j; char prime, back, max, men; char fake_prog[2]; if (prog == NULL) { memset(fake_prog, 0, sizeof fake_prog); prog = fake_prog; } GetMisType(mis); for (i = 0; i < (Mis.Jt + 1); i++) { Data->P[plr].Future[pad + i].MissionCode = mis; Data->P[plr].Future[pad + i].part = i; // duration if (Data->P[plr].DurLevel <= 5 && Data->P[plr].Future[pad + i].Duration == 0) { if (Mis.Dur == 1) Data->P[plr].Future[pad + i].Duration = maxx(Mis.Days, minn(Data->P[plr].DurLevel + 1, 6)); else { Data->P[plr].Future[pad + i].Duration = Mis.Days; } } if (Data->P[plr].Mission[0].Duration == Data->P[plr].Future[pad + i].Duration || Data->P[plr].Mission[1].Duration == Data->P[plr].Future[pad + i].Duration) { ++Data->P[plr].Future[pad + i].Duration; } if (pad == 1 && Data->P[plr].Future[0].Duration == Data->P[plr].Future[pad + i].Duration) { ++Data->P[plr].Future[pad + i].Duration; } if (Data->P[plr].Future[pad + i].Duration >= 6) { Data->P[plr].Future[pad + i].Duration = 6; } // one man capsule duration klugge if (Data->P[plr].Future[pad + i].Prog == 1) { if (Data->P[plr].DurLevel == 0) { Data->P[plr].Future[pad + i].Duration = 1; } else { Data->P[plr].Future[pad + i].Duration = 2; } }; // limit duration 'C' one man capsule // lunar mission klugge if (Mis.Lun == 1 || Data->P[plr].Future[pad + i].MissionCode == 55 || Data->P[plr].Future[pad + i].MissionCode == 56 || Data->P[plr].Future[pad + i].MissionCode == 53) { Data->P[plr].Future[pad + i].Duration = 4; } // unmanned duration klugge if (Mis.Days == 0) { Data->P[plr].Future[pad + i].Duration = 0; } Data->P[plr].Future[pad + i].Joint = Mis.Jt; Data->P[plr].Future[pad + i].Month = 0; if (mis == 1) { prog[i] = 0; } Data->P[plr].Future[pad + i].Prog = prog[0]; if (prog[i] > 0 && Mis.Days > 0) { for (j = 1; j < 6; j++) { DumpAstro(plr, j); } TransAstro(plr, prog[i]); //indexed OK if (Data->P[plr].Future[pad + i].PCrew != 0) { prime = Data->P[plr].Future[pad + i].PCrew - 1; } else { prime = -1; } if (Data->P[plr].Future[pad + i].BCrew != 0) { back = Data->P[plr].Future[pad + i].BCrew - 1; } else { back = -1; } max = prog[i]; if (prog[i] > 3) { max = prog[i] - 1; } Data->P[plr].Future[pad + i].Men = max; men = Data->P[plr].Future[pad + i].Men; if (prime != -1) for (j = 0; j < men; j++) { Data->P[plr].Pool[Data->P[plr].Crew[prog[i]][prime][j] - 1].Prime = 0; } if (back != -1) for (j = 0; j < men; j++) { Data->P[plr].Pool[Data->P[plr].Crew[prog[i]][back][j] - 1].Prime = 0; } Data->P[plr].Future[pad + i].PCrew = 0; Data->P[plr].Future[pad + i].BCrew = 0; pc[i] = -1; bc[i] = -1; for (j = 0; j < 8; j++) if (pc[i] == -1 && Data->P[plr].Crew[prog[i]][j][0] != 0 && Data->P[plr].Pool[Data->P[plr].Crew[prog[i]][j][0] - 1].Prime == 0) { pc[i] = j; } if (pc[i] == -1) { // astronaut/duration klugge if (Mis.Days > 0) { Data->P[plr].Future[pad + i].Men = max; } // no astronauts available have to go unmanned Data->P[plr].Future[pad + i].Men = 0; Data->P[plr].Future[pad + i].PCrew = 0; Data->P[plr].Future[pad + i].BCrew = 0; return; } Data->P[plr].Future[pad + i].PCrew = pc[i] + 1; bc[i] = -1; for (j = 0; j < 8; j++) if (bc[i] == -1 && j != pc[i] && Data->P[plr].Crew[prog[i]][j][0] != 0 && Data->P[plr].Pool[Data->P[plr].Crew[prog[i]][j][0] - 1].Prime == 0) { bc[i] = j; } Data->P[plr].Future[pad + i].BCrew = bc[i] + 1; for (j = 0; j < men; j++) { Data->P[plr].Pool[Data->P[plr].Crew[prog[i]][pc[i]][j] - 1].Prime = 4; } for (j = 0; j < men; j++) { Data->P[plr].Pool[Data->P[plr].Crew[prog[i]][bc[i]][j] - 1].Prime = 2; } } else { Data->P[plr].Future[pad + i].Men = 0; Data->P[plr].Future[pad + i].PCrew = 0; Data->P[plr].Future[pad + i].BCrew = 0; } } // joint mission 55 and 56 men klugge if (mis == 55 || mis == 56) { Data->P[plr].Future[pad + 1].Men = Data->P[plr].Future[pad].Men; Data->P[plr].Future[pad + 1].PCrew = Data->P[plr].Future[pad].PCrew; Data->P[plr].Future[pad + 1].BCrew = Data->P[plr].Future[pad].BCrew; Data->P[plr].Future[pad + 1].Prog = Data->P[plr].Future[pad].Prog; Data->P[plr].Future[pad].Men = 0; Data->P[plr].Future[pad].PCrew = 0; Data->P[plr].Future[pad].BCrew = 0; Data->P[plr].Future[pad].Prog = 0; Data->P[plr].Future[pad + 1].Duration = Data->P[plr].Future[pad].Duration; Data->P[plr].Future[pad].Duration = 0; } return; }
void dy_checkdefaults (consys_struct *sys, lpopts_struct *opts, lptols_struct *tols) /* This routine looks over various option and tolerance settings with an eye toward setting or adjusting values based on the size of the constraint system or other options that might be set by the user. The default values here are, by and large, grossly larger than required. The more outrageous ones are motivated by the Netlib examples. Parameters: sys: a constraint system opts: an options structure; may be modified on return Returns: undefined */ { int scalefactor ; if (opts->check < 0) opts->check = opts->factor/2 ; if (opts->check <= 0) opts->check = 1 ; if (opts->scan < 0) { opts->scan = maxx(dyopts_lb.scan,sys->archvcnt/2) ; opts->scan = minn(opts->scan,dyopts_ub.scan) ; } if (opts->iterlim < 0) { opts->iterlim = minn(5*(sys->concnt+sys->varcnt),100000) ; opts->iterlim = maxx(opts->iterlim,10000) ; } if (opts->idlelim < 0) { opts->idlelim = minn(2*(sys->concnt+sys->varcnt),50000) ; opts->idlelim = maxx(opts->idlelim,1000) ; } if (opts->degenpivlim < 0) { opts->degenpivlim = minn(1000,sys->concnt/2) ; opts->degenpivlim = maxx(100,opts->degenpivlim) ; } /* If the user has specified a dual pivot strategy, observe it. If not, start with strategy 1 (max dual objective improvement). */ if (opts->dpsel.strat >= 0) { opts->dpsel.flex = FALSE ; } else { opts->dpsel.strat = 1 ; opts->dpsel.flex = TRUE ; } if (opts->fullsys == TRUE) { opts->active.vars = 1.0 ; opts->active.cons = 1.0 ; } /* Loosen the base primal and dual accuracy check values for larger systems, and put a little more distance between the zero tolerances and feasibility tolerances. */ scalefactor = ((int) (.5 + log10((double) sys->varcnt))) - 2 ; if (scalefactor > 0) { tols->pchk *= pow(10.0,(double) scalefactor) ; tols->pfeas_scale *= pow(10.0,(double) scalefactor) ; } scalefactor = ((int) (.5 + log10((double) sys->concnt))) - 2 ; if (scalefactor > 0) { tols->dchk *= pow(10.0,(double) scalefactor) ; tols->dfeas_scale *= pow(10.0,(double) scalefactor) ; } /* XX_DEBUG_XX There's no good way to control this print statement, given the timing and purpose of this call. But it's occasionally handy for debugging. dyio_outfmt(dy_logchn,TRUE,"\nPTOLS: pzero = %g, pscale = %g, pchk = %g", tols->zero,tols->pfeas_scale,tols->pchk) ; dyio_outfmt(dy_logchn,TRUE,"\nDTOLS: dzero = %g, dscale = %g, dchk = %g", tols->cost,tols->dfeas_scale,tols->dchk) ; */ return ; }
int AllotPrest(char plr, char mis) { int i, total, other, negs, mcode, mike, P_Goal, N_Goal, S_Goal, ival, cval; extern struct mStr Mis; char PVal[28]; hero = 0; tMo = Data->P[plr].Mission[mis].Month; tYr = Data->Year; tIDX = bIDX = 0; memset(PVal, 0x00, sizeof PVal); // SETUP INFO mcode = Data->P[plr].Mission[mis].MissionCode; GetMisType(mcode); other = MaxFail(); total = negs = 0; for (i = 0; i < STEPnum; i++) { if (Mev[i].PComp == 5 && Mev[i].StepInfo == 0) { Mev[i].PComp = 0; Mev[i].Prest = -100; } if ((MANNED[0] + MANNED[1]) > 0) { if (other >= 3000) { Mev[i].PComp = 4; } else if (Mev[i].Prest >= -28 && Mev[i].StepInfo > 2999) { Mev[i].PComp = 4; } } } // FEMALE 'NAUTS PVal[25] = (MA[0][0].A != NULL && MA[0][0].A->Sex) || (MA[0][1].A != NULL && MA[0][1].A->Sex) || (MA[0][2].A != NULL && MA[0][2].A->Sex) || (MA[0][3].A != NULL && MA[0][3].A->Sex) || (MA[1][0].A != NULL && MA[1][0].A->Sex) || (MA[1][1].A != NULL && MA[1][1].A->Sex) || (MA[1][2].A != NULL && MA[1][2].A->Sex) || (MA[1][3].A != NULL && MA[1][3].A->Sex); for (i = 0; i < STEPnum; i++) { ival = abs(Mev[i].Prest); cval = Mev[i].PComp; // ival of 100 seems to mean "don't record this in PVal[]" // Regardless of intention, it's out of bounds, so don't access or overwrite it if (ival != 100) { if (Mev[i].StepInfo == 0 && PVal[ival] == 0) { cval = 4; } if (PVal[ival] != 4) { PVal[ival] = cval; } } } // EVA FIX FOR ALTERNATE STEPS LATER IN MISSION if (Mis.EVA == 1 && (PVal[26] == 0 || PVal[26] == 5)) { PVal[26] = 4; } else if (Mis.EVA == 0 && PVal[26] == 5) { PVal[26] = 0; } // DOCKING FIX FOR ALTERNATE STEPS LATER IN SESSION if (Mis.Doc == 1 && (PVal[24] == 0 || PVal[24] == 5)) { PVal[27] = 4; } else if (Mis.EVA == 0 && PVal[24] == 5) { PVal[24] = 0; } // CLEAR TOTAL VALUE total = 0; negs = 0; // PHOTO RECON if (PVal[19] > 0 && PVal[19] < 4) { Data->P[plr].Misc[5].Safety += 5; // manned stuff gets 5 } Data->P[plr].Misc[5].Safety = minn(Data->P[plr].Misc[5].Safety, 99); if (death == 1) { for (i = 0; i < 28; i++) if (PVal[i] > 0 && PVal[i] < 4) { PVal[i] = 4; } } // GOAL FILTER: MANNED P_Goal = PosGoal(PVal); N_Goal = NegGoal(PVal); S_Goal = SupGoal(PVal); if (P_Goal == LLAND) { // make sure EVA was done if (!(PVal[26] >= 1 && PVal[26] <= 3)) { P_Goal = LORBIT; PVal[LLAND] = 0; } } if ((P_Goal == -1 && S_Goal == -1) && (PVal[25] > 0)) { PVal[25] = 4; } if (Check_Dock(500) == 2) { // Success Data->P[plr].Misc[4].Safety += 10; Data->P[plr].Misc[4].Safety = minn(Data->P[plr].Misc[4].Safety, Data->P[plr].Misc[4].MaxSafety); } else if (Check_Dock(500) == 1) { Data->P[plr].Misc[4].Safety += 5; Data->P[plr].Misc[4].Safety = minn(Data->P[plr].Misc[4].Safety, Data->P[plr].Misc[4].MaxSafety); } if (STSp(27) || STSn(27)) { PVal[27] = 0; // Clear All Firsts/Negative Goals } if (STSp(18) || STSn(18)) { PVal[18] = 0; } if (STSp(19) || STSn(19)) { PVal[19] = 0; } if (STSp(20) || STSn(20)) { PVal[20] = 0; } if (STSp(22) || STSn(22)) { PVal[22] = 0; } // DURATION FIRSTS Data->P[plr].Mission[mis].Duration = maxx(Data->P[plr].Mission[mis].Duration, 1); if (!Mis.Dur) { switch (P_Goal) { case MANSPACE: mike = 7; Data->P[plr].Mission[mis].Duration = 1; break; case EORBIT: mike = (Mis.Index <= 6) ? (Data->P[plr].Mission[mis].Duration = 1, 7) : (Data->P[plr].Mission[mis].Duration = 2, 12); break; case LPASS: mike = 11; Data->P[plr].Mission[mis].Duration = 3; break; case LORBIT: mike = 10; Data->P[plr].Mission[mis].Duration = 4; break; case LLAND: mike = 10; Data->P[plr].Mission[mis].Duration = 4; break; default: mike = 0; break; } } else { mike = 14 - Data->P[plr].Mission[mis].Duration; } if (mike >= 8 && mike <= 12) if (P_Goal >= 18 || S_Goal >= 18) { PVal[mike] = 1; } //total+=(char) Set_Goal(plr,mike,0); // GOAL POSTIVE if (P_Goal != -1) { total = Set_Goal(plr, P_Goal, 0); if (P_Goal != 27) { total += Set_Goal(plr, 27, 0); PVal[27] = 0; } //if (!(Data->Prestige[27].Place==plr || Data->Prestige[27].mPlace==plr)) // total+=Set_Goal(plr,27,0); } // GOAL NEGATIVE if (N_Goal != -1) { negs += PrestNeg(plr, N_Goal); PVal[N_Goal] = 0; } if (mcode == 32 || mcode == 36) { PVal[23] = Check_Lab(); } // TOTAL ALL MISSION FIRSTS for (i = 0; i < 28; i++) if (PVal[i] == 1 || (PVal[i] == 2 && other < 3000)) { total += (char) Set_Goal(plr, i, 0); } //else if (PVal[i]==4) negs+=Set_Goal(plr,i,0); // CAPSULE FIRSTS need to check for failure on capsule if ((P_Goal != -1 || S_Goal != -1) && other < 3000 && MANNED[0] > 0 && Data->P[plr].Mission[mis].Hard[Mission_Capsule] != -1) { // Hardware on first part total += Set_Goal(plr, 12 + Data->P[plr].Mission[mis].Prog, 0); } if ((P_Goal != -1 || S_Goal != -1) && other < 3000 && MANNED[1] > 0 && Data->P[plr].Mission[mis + 1].Hard[Mission_Capsule] != -1 && Data->P[plr].Mission[mis + 1].part == 1) { total += Set_Goal(plr, 12 + Data->P[plr].Mission[mis + 1].Prog, 0); } #define DNE(a,b) (Data->Prestige[b].Place==(a) || Data->Prestige[b].mPlace==(a)) if (DNE(plr, DUR_F)) { Data->P[plr].DurLevel = 6; } else if (DNE(plr, DUR_E)) { Data->P[plr].DurLevel = 5; } else if (DNE(plr, DUR_D)) { Data->P[plr].DurLevel = 4; } else if (DNE(plr, DUR_C)) { Data->P[plr].DurLevel = 3; } else if (DNE(plr, DUR_B)) { Data->P[plr].DurLevel = 2; } else if (DNE(plr, MANSPACE)) { Data->P[plr].DurLevel = 1; } // TOTAL ALL MISSION SUBSEQUENTS if (total == 0) { // SET SUBSEQUENT Goal if (S_Goal != -1 && other < 3000) { total = Set_Goal(plr, S_Goal, 0); } for (i = 0; i < 28; i++) if (PVal[i] == 1 || (PVal[i] == 2 && other < 3000)) { total += (char) Set_Goal(plr, i, 0); } else if (PVal[i] == 3) { Set_Goal(plr, i, 0); } } // LM POINTS Set_LM(plr, STEPnum); if (mcode >= 48 && mcode <= 52 && other < 3000) { Set_LM(plr, STEPnum); } // ADD IN NEGATIVES AND RETURN MIN of -10 total = ((total + negs) < -10) ? -10 : total + negs; if (!death && total == -10) { total = -7; } return total; }
int U_AllotPrest(char plr, char mis) { int i = 0, total, other, negs, mcode, lun; extern struct mStr Mis; char PVal[28]; memset(PVal, 0x00, sizeof PVal); // CLEAR TOTAL VALUE total = 0, negs = 0, lun = 0; tMo = Data->P[plr].Mission[mis].Month; tYr = Data->Year; tIDX = bIDX = 0; // SETUP INFO mcode = Data->P[plr].Mission[mis].MissionCode; GetMisType(mcode); lun = Check_Photo(); other = MaxFail(); if ((mcode >= 7 && mcode <= 13) || mcode == 1) { // Unmanned Probes switch (mcode) { case 1: i = 0; break; // O.S. case 7: i = 1; break; // L.F.B. case 8: i = 7; break; // L.P.L. case 9: i = 3; break; case 10: i = 4; break; case 11: i = 2; break; case 12: i = 5; break; case 13: i = 6; break; } if (other == 1) { if (mcode == 10 || mcode == 12 || mcode == 13) { return 0; } total = Set_Goal(plr, i, 0); } else { negs = PrestNeg(plr, i); } if (mcode == 7 || mcode == 8) { if (lun == 1) { // UNMANNED PHOTO RECON Data->P[plr].Misc[5].Safety += 5; Data->P[plr].Misc[5].Safety = minn(Data->P[plr].Misc[5].Safety, 99); } // if } // if if (mcode == 8 && MaxFail() == 1) { // extra 10 for landing on Moon if (lun == 1) { // UNMANNED PHOTO RECON Data->P[plr].Misc[5].Safety += 10; Data->P[plr].Misc[5].Safety = minn(Data->P[plr].Misc[5].Safety, 99); } // if } // if } // if if (Check_Dock(2) == 2) { Data->P[plr].Misc[4].Safety += 10; Data->P[plr].Misc[4].Safety = minn(Data->P[plr].Misc[4].Safety, Data->P[plr].Misc[4].MaxSafety); } else if (Check_Dock(2) == 1) { Data->P[plr].Misc[4].Safety += 5; Data->P[plr].Misc[4].Safety = minn(Data->P[plr].Misc[4].Safety, Data->P[plr].Misc[4].MaxSafety); } return total + negs; }
dyret_enum dy_addtopivrej (int j, dyret_enum why, double abarij, double maxabarij) /* This routine adds x<j> to the rejected pivot list by adding an entry to pivrejlst and adding the NOPIVOT qualifier to x<j>'s status. If necessary, it expands the size of the list. Parameter: j: the variable x<j> why: the reason it's going on the pivot reject list; one of dyrSINGULAR or dyrMADPIV abarij: (why == dyrMADPIV) the pivot element maxabarij: (why == dyrMADPIV) the maximum pivot element in the pivot column (primal) or row (dual). Returns: dyrOK if the entry is added without error, dyrFATAL if we can't get more space, or if a paranoid check fails. */ { int n,ndx,newsze ; double ratio ; const char *rtnnme = "dy_addtopivrej" ; # ifndef DYLP_NDEBUG int saveprint ; saveprint = dy_opts->print.pivoting ; dy_opts->print.pivoting = 0 ; # endif /* We don't actually need the pivot ratio until further down, but it's handy to do it here where we can easily suppress the internal print, then restore the print level. */ ratio = dy_chkpiv(abarij,maxabarij) ; n = dy_sys->varcnt ; # ifndef DYLP_NDEBUG dy_opts->print.pivoting = saveprint ; # endif # ifdef DYLP_PARANOIA if (j < 1 || j > n) { errmsg(102,rtnnme,dy_sys->nme,"variable",j,1,n) ; return (dyrFATAL) ; } if (!(why == dyrSINGULAR || why == dyrMADPIV)) { errmsg(1,rtnnme,__LINE__) ; return (dyrFATAL) ; } # endif # ifndef DYLP_NDEBUG /* The default case in this switch is needed to suppress GCC warnings --- it doesn't grok the paranoid check. */ if (dy_opts->print.pivreject >= 2) { dyio_outfmt(dy_logchn,dy_gtxecho, "\n marking %s (%d) ineligible for pivoting ", consys_nme(dy_sys,'v',j,TRUE,NULL),j) ; switch (why) { case dyrSINGULAR: { dyio_outfmt(dy_logchn,dy_gtxecho,"(%s).",dy_prtdyret(why)) ; break ; } case dyrMADPIV: { dyio_outfmt(dy_logchn,dy_gtxecho,"(%s = %g).",dy_prtdyret(why),ratio) ; break ; } default: { errmsg(1,rtnnme,__LINE__) ; return (dyrFATAL) ; } } } # endif /* Flag the culprit --- the extent of externally visible activity. Then make the entry in the pivot reject list. Check for adequate list length and expand if necessary. */ setflg(dy_status[j],vstatNOPIVOT) ; ndx = pivrej_ctl.cnt++ ; if (ndx >= pivrej_ctl.sze) { newsze = minn(2*pivrej_ctl.sze,n+1) ; # ifndef DYLP_NDEBUG if (dy_opts->print.pivreject >= 3) { dyio_outfmt(dy_logchn,dy_gtxecho, "\n%s: expanding pivot reject list from %d to %d entries.", rtnnme,pivrej_ctl.sze,newsze) ; } # endif pivrejlst = (pivrej_struct *) REALLOC(pivrejlst,newsze*sizeof(pivrej_struct)) ; if (pivrejlst == NULL) { errmsg(337,rtnnme,dy_sys->nme,pivrej_ctl.sze,newsze) ; return (dyrFATAL) ; } pivrej_ctl.sze = newsze ; } pivrejlst[ndx].ndx = j ; pivrejlst[ndx].iter = dy_lp->basis.pivs ; pivrejlst[ndx].why = why ; switch (why) { case dyrSINGULAR: { pivrej_ctl.sing++ ; break ; } case dyrMADPIV: { pivrej_ctl.mad++ ; ratio = dy_chkpiv(abarij,maxabarij) ; pivrejlst[ndx].ratio = ratio*dy_tols->pivot ; break ; } default: { errmsg(1,rtnnme,__LINE__) ; return (dyrFATAL) ; } } # ifdef DYLP_STATISTICS if (dy_stats != NULL) { switch (why) { case dyrSINGULAR: { dy_stats->pivrej.sing++ ; break ; } case dyrMADPIV: { dy_stats->pivrej.mad++ ; break ; } default: { errmsg(1,rtnnme,__LINE__) ; return (dyrFATAL) ; } } if (pivrej_ctl.cnt > dy_stats->pivrej.max) { dy_stats->pivrej.max = pivrej_ctl.cnt ; } } # endif return (dyrOK) ; }