int CBwfind::valuefirst(int tb[][8] ) { int flag,minus,corner=0,v,ComMobil,ManMobil,DiffMobil,Num,squre; int danger; flag=ComChoice; ComMobil=Mobility(tb,ComChoice); ManMobil=Mobility(tb,ManChoice); //DiffMobil=ComMobil*ComMobil-ManMobil*ManMobil; //a DiffMobil=ComMobil-ManMobil; //b Num=Total(tb); if(flag==1){ minus=white(tb)-black(tb); if(minus>=0) squre=minus*minus; else squre=-minus*minus; danger=black(tb); } if(flag==-1){ minus=black(tb)-white(tb); if(minus>=0) squre=minus*minus; else squre=-minus*minus; danger=white(tb); } if(Num<25){ v=minus+2*DiffMobil; } else{ v=minus+3*DiffMobil; } if(danger==0) v=-10000; return v; }
uint64 PERFD (typePOS* POSITION, int n) { int i; uint64 TOTAL = 0, TIME; typeMoveList LM[256], *lm; DrawBoard (POSITION); TIME = GetClock(); Mobility (POSITION); if (IN_CHECK) lm = EvasionMoves (POSITION, LM, 0xffffffffffffffff); else { lm = CaptureMoves (POSITION, LM, POSITION->OccupiedBW); lm = OrdinaryMoves (POSITION, lm); } for (i = 0; i < lm - LM; i++) { Make (POSITION, LM[i].move); Mobility (POSITION); if (!ILLEGAL) { printf ("%s ",Notate (LM[i].move, STRING1[POSITION->cpu])); PERFT (POSITION, n - 1); TOTAL += CNT[n - 1]; } Undo (POSITION, LM[i].move); } printf ("TOTAL %lld moves %ld time: %lld us\n", TOTAL, lm - LM, GetClock() - TIME); return TOTAL; }
void DispBoard2(const BOARD *Board, const int Forbidden[]) { int Time, Rank, File, Square; static const char *Colour[] = { "Black", "?!?!?", "White" }; Time = 0; if (Board == Game->Board) { Time = (int) ElapsedTime[0]; if (Time < 0) Time = 0; } printf("\n A B C D E F G H %02d:%02d:%02d\n",Time/3600,(Time%3600)/60,Time%60); for (Rank = 0, Square = A1; Rank < 8; Rank++, Square++) { printf("%d ",Rank+1); for (File = 0; File < 8; File++, Square++) { board.Square[Rank][File].Colour = Board->Square[Square]; if (Forbidden != NULL && Forbidden[Square]) { printf("= "); strcpy(board.Square[Rank][File].String,"#"); } else if (IsLegalMove(Board,Square)) { printf(". "); strcpy(board.Square[Rank][File].String,"*"); } else { printf("%c ","*-O"[Board->Square[Square]+1]); strcpy(board.Square[Rank][File].String,""); } } printf("%d",Rank+1); switch (Rank) { case 1 : printf(" %2d Disks * %2d Moves",DiskNb(Board,BLACK),Mobility(Board,BLACK)); break; case 3 : printf(" %2d Empties",EmptyNb(Board)); break; case 4 : if (IsFinished(Board)) { printf(" Game ended"); } else { printf(" %s's Turn",Colour[Board->Colour+1]); } break; case 6 : printf(" %2d Disks O %2d Moves",DiskNb(Board,WHITE),Mobility(Board,WHITE)); break; } printf("\n"); } if (Board == Game->Board) { Time = (int) ElapsedTime[1]; if (Time < 0) Time = 0; } printf(" A B C D E F G H %02d:%02d:%02d\n\n",Time/3600,(Time%3600)/60,Time%60); board.Colour = Board->Colour; DispXBoard(); }
//*****************************************************************************// void isotropic_solverloop() { int i,j,z; double p,dp_dt,dmu_dt, kai; double dc_dx, dc_dy, V_gradC = 0.0; double mob; for (i = 1; i < Mx-1; i++) { for (j = 1; j < My-1; j++){ z = i*My + j; p = phi_old[z]; dp_dt = (G*E*lap_phi[z] - (G/E)*18.0*(p)*(1.0-p)*(1.0-2.0*p) + (mu_old[z] - Mu)*(K-1)*(mu_old[z])*6*p*(1-p))/(tau*E); phi_new[z] = p + deltat*(dp_dt); dc_dx = (conc[z+1]-conc[z-1])*0.5*inv_deltax; dc_dy = (conc[z+My]-conc[z-My])*0.5*inv_deltax; // V_gradC = u[z]*dc_dx + v[z]*dc_dy; mob = Mobility(z); // dmu_dt = Mob*lap_mu[z] - V_gradC - (K-1)*mu_old[z]*6*p*(1-p)*dp_dt; dmu_dt = mob - V_gradC - (K-1)*mu_old[z]*6*p*(1-p)*dp_dt; kai = 1+(K-1)*p*p*(3-2*p); mu_new[z] = mu_old[z] + deltat*dmu_dt/kai; } } }
void CBulkDlg::OnDiffLength() { UpdateData(TRUE); if (!m_NeedUpdate) return; double Tref = 300; double Vt = VT300; double D = Vt*Mobility(m_BkgndDoping,Tref); m_LLItau = (1e6*pow(1e-4*m_DiffLength,2)/D); UpdateData(FALSE); OnLLItau(); }
void PERFT (typePOS* POSITION, int d) { int i; Mobility (POSITION); for (i = 0; i < 64; i++) CNT[i] = 0; perft (POSITION, d, 1); for (i = d; i >= 2; i--) printf ("%lld/", CNT[i]); printf ("%lld\n", CNT[1]); }
static void MainLineIterate(typePos *Position) { int va, v2, cp; uint32 m; (Position->Dyn + 1)->move = MoveNone; Mobility(Position); if (!RobboTotalBaseScore(Position, &va)) { if (VerboseRobboBases) { Send("info string Failure in MainLine\n"); #ifdef Log if (WriteLog) { log_file = fopen(log_filename, "a"); fprintf(log_file, "info string Failure in MainLine\n"); close_log(); } #endif } (Position->Dyn + 1)->move = MoveNone; Position->StackHeight = 0; return; } if (!RobboMove(Position, &m, &v2, &cp)) { (Position->Dyn + 1)->move = MoveNone; Position->StackHeight = 0; return; } if (va == dDraw) { Position->StackHeight = 0; Make(Position, m); Position->StackHeight = 1; Undo(Position, m); return; } m &= 0x7fff; Position->StackHeight = 0; Make(Position, m); Position->StackHeight = 1; MainLineIterate(Position); Undo(Position, m); Position->StackHeight = 1; }
BOOL CBulkDlg::OnInitDialog() { if (m_Type==N_TYPE) m_TypeStr = "n-type"; else m_TypeStr = "p-type"; double Tref = 300; double Vt = VT300; double taun = CPhysics::tau(1e-6*m_TauN,m_BkgndDoping,m_Nref,m_Nalpha,Tref,m_Talpha); double taup = CPhysics::tau(1e-6*m_TauP,m_BkgndDoping,m_Nref,m_Nalpha,Tref,m_Talpha); m_LLItau = (1e6 * CMath::round(Tau(taun,taup,Tref),4)); // s to us m_DiffLength = // cm to um (1e4 * CMath::round(sqrt(Mobility(m_BkgndDoping,Tref)*Vt*Tau(taun,taup,Tref)),4)); m_NeedUpdate = FALSE; CDialog::OnInitDialog(); return TRUE; }
void CBulkDlg::OnKillfocus() { UpdateData(TRUE); if (!m_NeedUpdate) return; double Tref = 300; double Vt = VT300; double taun = CPhysics::tau(1e-6*m_TauN,m_BkgndDoping,m_Nref,m_Nalpha,Tref,m_Talpha); double taup = CPhysics::tau(1e-6*m_TauP,m_BkgndDoping,m_Nref,m_Nalpha,Tref,m_Talpha); m_LLItau = (1e6 * CMath::round(Tau(taun,taup,Tref),4)); // s to us m_DiffLength = // cm to um (1e4 * CMath::round(sqrt(Mobility(m_BkgndDoping,Tref)*Vt*Tau(taun,taup,Tref)),4)); m_NeedUpdate = FALSE; UpdateData(FALSE); }
void PadComp::Read (istream& in) { Connector::Read(in); Coord l, b, r, t; int mobility; in >> l >> b >> r >> t >> mobility; PadGraphic* pad = new PadGraphic(l, b, r, t); _mobility = Mobility(mobility); pad->FillBg(ReadBgFilled(in)); PSColor* fg = ReadColor(in); PSColor* bg = ReadColor(in); pad->SetColors(fg, bg); pad->SetBrush(ReadBrush(in)); Transformer* xf = ReadTransformer(in); pad->SetTransformer(xf); Unref(xf); SetGraphic(pad); }
void PinComp::Read (istream& in) { Connector::Read(in); Coord x0, y0; int mobility; in >> x0 >> y0 >> mobility; PinGraphic* pin = new PinGraphic(x0, y0); _mobility = Mobility(mobility); pin->FillBg(ReadBgFilled(in)); PSColor* fg = ReadColor(in); PSColor* bg = ReadColor(in); pin->SetColors(fg, bg); pin->SetBrush(ReadBrush(in)); Transformer* t = ReadTransformer(in); pin->SetTransformer(t); Unref(t); SetGraphic(pin); }
static void perft (typePOS* POSITION, int d, int h) { typeMoveList LM[256], *lm; int i; if (IN_CHECK) lm = EvasionMoves (POSITION, LM, 0xffffffffffffffff); else { lm = CaptureMoves (POSITION, LM, POSITION->OccupiedBW); lm = OrdinaryMoves (POSITION, lm); } for (i = 0; i < lm - LM; i++) { Make (POSITION, LM[i].move); Mobility (POSITION); if (!ILLEGAL) { CNT[h]++; if (d > 1) perft (POSITION, d - 1, h + 1); } Undo (POSITION, LM[i].move); } }
bool RobboMove(typePos *Position, uint32 *am, int *v, int *cap) { int va, v2, av = 0xff, zv = 0x00, cp; typeMoveList move_list[256]; typeMoveList *q; uint32 m; if (Position->Dyn->oo) return false; if (!RobboTotalBaseScore(Position, &va) || va == dLoss) return false; Mobility(Position); if (IsCheck) EvasionMoves(Position, move_list, 0xffffffffffffffff); else { q = CaptureMoves(Position, move_list, 0xffffffffffffffff); OrdinaryMoves(Position, q); } for (q = move_list; q->move; q++) { m = q->move & 0x7fff; Position->StackHeight = 0; Make(Position, m); Position->StackHeight = 1; Mobility(Position); if (IsIllegal) { Undo(Position, m); Position->StackHeight = 1; continue; } if (!RobboTotalBaseScore(Position, &v2)) { Undo(Position, m); Position->StackHeight = 1; return false; } if (DiskLoss(va)) { uint32 m3; int v3; if (!RobboMove(Position, &m3, &v3, &cp)) { Undo(Position, m); Position->StackHeight = 1; return false; } if (v3 > zv && ((!Position->Dyn->cp && !(m & FlagMask) && ((!cp && (!(m3 & FlagMask))))) || va <= dLoss + 1)) { *am = m; *v = zv = v3; *cap = Position->Dyn->cp; } } Undo(Position, m); Position->StackHeight = 1; if (DiskDraw(va) && DiskDraw(v2)) { *am = m; *v = dDraw; *cap = false; return true; } if (DiskWin(va) && DiskLoss(v2)) { if (Position->sq[To(m)] || (m & FlagMask)) { *am = m; *v = v2; *cap = true; return true; } if (v2 < av) { *am = m; *v = av = v2; *cap = false; } } } return true; }