Example #1
0
int main(void)
{
  int opt=0, level=0, keep=ONEMORE, prevent=10;
  while(keep==ONEMORE && (prevent--))
  { 
    printf("welcome to sudoku. there is a {1,2,3} Level. which one? ");
    scanf("%d",&opt);
    clear();
    switch(opt)
    { 
      case 1:
        level=easy;
        break;
      case 2:
        level=normal;
        break;
      case 3:
        level=difficult;
        break;
      default :
        printf("there is no such level.\n");
        return;
        break;
    }
    if(makemap()!=0)
    {
      printf("failed to make map\n");
      return 0;
    }
    else 
    {
      if(applylevel(level)==0)
      {
        keep=run();
      }
      else
      {
        printf("level apply error\n program exit\n");
        return 0;
      }
    }
  }
}
Example #2
0
/*--------------------------------------------------------------*
 *	Main program						*
 *--------------------------------------------------------------*/
int main(void)
{
  char line[256];
  char letters[256];
  char name[40];
  FILE *file;
  int i;

  printf("Boggle square size is %d lines of %d characters\n", YMAX, XMAX);
  strcpy(letters, "");
  for (i=0; i<YMAX; i++) {
    printf("Enter line %d :", i+1);
    gets(line);
    if (strlen(line) != XMAX) {
      fprintf(stderr, "Wrong length of line\n");
      exit(1);
    }
    strcat(letters, line);
  }
  makemap(letters);
  
    file = fopen("apet", "r");
    if (file == NULL) {
      fprintf(stderr, "Could not open %s\n", name);
      exit(1);
    }
    for (; fgets(line, 256, file); ) {
      if (boggle(line, NONE, 0) != EXIT) {
      	printf("-- %s", line);
      }
    }
    fclose(file);

/*    
  for (i=0; i<MAXTEST; i++) {
    if (boggle(test[i], NONE, 0) == EXIT) {
      printf("-- %s\n", test[i]);
    }
  }
*/
  return 0;
} 
Example #3
0
void *
__go_construct_map (const struct __go_map_type *type,
		    uintptr_t count, uintptr_t entry_size,
		    uintptr_t val_offset, const void *ventries)
{
  void *ret;
  const unsigned char *entries;
  uintptr_t i;

  ret = makemap(type, (int64_t) count, NULL, NULL);

  entries = (const unsigned char *) ventries;
  for (i = 0; i < count; ++i)
    {
      mapassign1 (type, ret, entries, entries + val_offset);
      entries += entry_size;
    }

  return ret;
}
Example #4
0
/*DRAFT IF IN A CITY*/
void draft(void) {
  short armynum, x, y, i;
  long men = 0, mercs;
  short army = (-1), isgod = FALSE, newtype = 0;
  long i_cost, e_cost;
  char ch;

  clear_bottom(0);
  if (country == 0) {
    isgod = TRUE;
    country = sct[XREAL][YREAL].owner;
    curntn = &ntn[country];
  } else if (sct[XREAL][YREAL].owner != country) {
    errormsg("You do not own");
    return;
  }
  if ((sct[XREAL][YREAL].designation != DTOWN) &&
      (sct[XREAL][YREAL].designation != DCAPITOL) &&
      (sct[XREAL][YREAL].designation != DCITY)) {
    errormsg("must raise in towns/cities/capitols");
    if (isgod == TRUE)
      reset_god();
    return;
  }
  if (curntn->tgold <= 0) {
    errormsg("You are broke");
    if (isgod == TRUE)
      reset_god();
    return;
  }
  if (ISCITY(sct[XREAL][YREAL].designation) &&
      (sct[XREAL][YREAL].people * (3 * CITYLIMIT + (curntn->tsctrs / 2)) <
       curntn->tciv)) {
    mvprintw(LINES - 1, 0, "Need %d people in sector: hit any key",
             curntn->tciv / (3 * CITYLIMIT + (curntn->tsctrs / 2)));
    refresh();
    getch();
    if (isgod == TRUE)
      reset_god();
    return;
  }
  /* ask what type of unit */
  y = LINES - 2;
  mvaddstr(y, 0, "options: 1) spy 2) scout");
  clrtoeol();
  x = 25;
  for (i = 0; i <= NOUNITTYPES; i++) {
    if (unitvalid(i) == TRUE) {
      mvprintw(y, x + 2, "%s", *(shunittype + i));
      mvprintw(y, x, "(%c)", *(shunittype + i)[0]);
      x += strlen(*(shunittype + i)) + 3;
      if (x > COLS - 10) {
        x = 0;
        y++;
      }
    }
  }
  move(y, x);
  clrtoeol();
  if ((magic(country, WARRIOR) == TRUE) || (magic(country, WARLORD) == TRUE) ||
      (magic(country, CAPTAIN) == TRUE))
    mvaddstr(LINES - 3, 0,
             "(Warrior = 1/2 enlist cost) what type of unit do you want:");
  else
    mvaddstr(LINES - 3, 0, "what type of unit do you want to raise:");

  clrtoeol();
  refresh();
  ch = getch();
  for (newtype = 0; newtype <= NOUNITTYPES; newtype++)
    if (ch == *(shunittype + newtype)[0])
      break;

  if ((newtype == NOUNITTYPES + 1) || (unitvalid(newtype) == FALSE)) {
    if (ch == '1')
      newtype = A_SPY;
    else if (ch == '2')
      newtype = A_SCOUT;
    else {
      errormsg("Invalid type");
      if (isgod == TRUE)
        reset_god();
      return;
    }
  }
  clear_bottom(0);

  /* marines and sailors may only be drafted in harbors */
  if (newtype == A_MARINES || newtype == A_SAILOR) {
    i = FALSE;
    for (x = XREAL - 1; x <= XREAL + 1; x++)
      for (y = YREAL - 1; y <= YREAL + 1; y++)
        if (sct[x][y].altitude == WATER)
          i = TRUE;

    /* not a harbor */
    if (i == FALSE) {
      if (newtype == A_MARINES)
        errormsg("Huh?  What would marines do without the water?");
      else
        errormsg("You gotta be kinding!?  Sailors on land?");
      if (isgod == TRUE)
        reset_god();
      return;
    }
  }
  /* raise an untrained army */
  i = FALSE;
  if (newtype == A_SPY || newtype == A_SCOUT) {
    men = 1;
  } else {
    mvprintw(LINES - 3, 0, "how many %s do you wish to raise:",
             unittype[newtype]);
    clrtoeol();
    refresh();
    men = get_number();
    if (men <= 0) {
      if (isgod == TRUE)
        reset_god();
      return;
    }
  }

  /* i_people*256 is initial people -> can  draft up to following */
  /* draftable = max_draft - already drafted */
  /* = imen/4 - ( imen - people)   */
  /* = -3/4 * imen + people)  	 */
  /* 192 comes from 3*256/4 			 */
  if ((newtype != A_MERCENARY &&
       (men > sct[XREAL][YREAL].people - (sct[XREAL][YREAL].i_people * 192))) ||
      (sct[XREAL][YREAL].i_people < 0)) {
    if (sct[XREAL][YREAL].i_people < 0)
      errormsg("error: sector wasn't city at beginning of turn");
    else
      errormsg("error: raising too many soldiers");
    if (isgod == TRUE)
      reset_god();
    return;
  }
  /* check that you dont have too many mercenaries */
  mercs = 0;
  if (newtype == A_MERCENARY) {
    int totalsolds = 0;

    for (armynum = 0; armynum < MAXARM; armynum++) {
      if (P_ATYPE < MINLEADER) {
        if (P_ATYPE == A_MERCENARY)
          mercs += P_ASOLD;
        totalsolds += P_ASOLD;
      }
    }
    if (men + mercs > (totalsolds + men) / 2) {
      errormsg("you would then have more than 50%% mercenaries");
      if (isgod == TRUE)
        reset_god();
      return;
    }
    if (mercgot + men > MERCMEN / NTOTAL) {
      errormsg("there are not that many mercanaries available");
      if (isgod == TRUE)
        reset_god();
      return;
    }
  }
  e_cost = (long) * (u_encost + newtype) * men;
  i_cost = (long) * (u_enmetal + newtype) * men;

  /* magiced get 1/2 enlistment costs */
  if ((magic(country, WARRIOR) == TRUE) || (magic(country, WARLORD) == TRUE) ||
      (magic(country, CAPTAIN) == TRUE))
    e_cost /= 2;

  if ((magic(country, SAPPER) == TRUE) &&
      ((newtype == A_SIEGE) || (newtype == A_CATAPULT))) {
    e_cost /= 2;
    i_cost /= 2;
  }
  /* check to see if enough gold */
  if (e_cost > curntn->tgold) {
    errormsg("You don't have enough talons");
    if (isgod == TRUE)
      reset_god();
    return;
  } else if (i_cost > curntn->metals) {
    mvprintw(LINES - 1, 0, "You don't have %ld metal", i_cost);
    mvaddstr(LINES - 1, COLS - 20, "PRESS ANY KEY");
    clrtoeol();
    refresh();
    getch();
    if (isgod == TRUE)
      reset_god();
    return;
  } else {
    move(LINES - 2, 0);
    clrtoeol();
  }

  /* count is order of that army in sector */
  /* armynum is number of that army */
  if ((armynum = getselunit()) >= 0) {
    if (armynum >= MAXARM || newtype == A_SPY || newtype == A_SCOUT) {
      army = -1;
    } else {
      /* if different types, must raise new army */
      if ((newtype == P_ATYPE) && (P_ASTAT != ONBOARD)) {
        mvaddstr(LINES - 1, 0, "Do you wish to raise a new army:");
        clrtoeol();
        refresh();
        if (getch() != 'y')
          army = armynum;
        else
          army = -1;
      } else
        army = (-1);
    }
  }
  if (army == (-1)) {
    mvprintw(LINES - 2, 0,
             "(%s, gold talons=%ld, metal=%ld) raising a new army",
             *(unittype + newtype), e_cost, i_cost);
    clrtoeol();
    refresh();
    sleep(1);

    armynum = 0;
    while ((army == (-1)) && (armynum < MAXARM)) {
      if (P_ASOLD <= 0) {
        army = armynum;
        P_ASOLD = 0;
        if (newtype == A_MILITIA)
          P_ASTAT = MILITIA; /* new militia units=MILITIA */
        else
          P_ASTAT = DEFEND; /* set new armies to DEFEND */
        AADJSTAT;
        AADJMEN;
      }
      armynum++;
    }
    if (army == (-1)) {
      errormsg("NO FREE ARMIES");
      if (isgod == TRUE)
        reset_god();
      return;
    }
    armynum = army;
  } else {
    mvprintw(LINES - 2, 0,
             "(%s, gold talons=%ld, metal=%ld) adding to existing army",
             *(unittype + newtype), e_cost, i_cost);
    clrtoeol();
    refresh();
    sleep(2);
  }

  if (newtype == A_SPY) {
    while (TRUE) {
      clear_bottom(0);
      mvaddstr(LINES - 3, 0, "Spy Against What Nation: ");
      refresh();
      if ((i = get_country()) == (-1)) {
        if (isgod == TRUE)
          reset_god();
        return;
      }
      if (i == country) {
        errormsg("What?  You don't even trust yourself?");
        i = NTOTAL;
      }
      if (!(isntn(ntn[i].active))) {
        errormsg("You can't spy against them");
        i = NTOTAL;
      }
      if (i < NTOTAL && isactive(i))
        break;
    }
    if (curntn->dstatus[i] != UNMET) {
      P_AYLOC = ntn[i].capy;
      P_AXLOC = ntn[i].capx;
      mvprintw(LINES - 2, 0, "The Spy Starts in %s's Capitol (%d,%d)",
               ntn[i].name, rel_x((int) P_AXLOC), rel_y((int) P_AYLOC));
      clrtoeol();
    } else {
      clear_bottom(0);
      mvprintw(LINES - 4, 0, "You do not yet know where %s is", ntn[i].name);
      mvaddstr(LINES - 3, 0, "Have the Spy start from this sector? [y or n]");
      refresh();
      if (getch() != 'y') {
        if (isgod == TRUE)
          reset_god();
        return;
      }
      P_AYLOC = YREAL;
      P_AXLOC = XREAL;
      mvprintw(LINES - 2, 0, "Intelligence indicates that %s lies to the %s",
               ntn[i].name,
               *(directions + compass((int) P_AXLOC, (int) P_AYLOC,
                                      (int) ntn[i].capx, (int) ntn[i].capy)));
      clrtoeol();
    }
    errormsg("");
    redraw = PART;
  } else {
    P_AYLOC = YREAL;
    P_AXLOC = XREAL;
  }
  if (newtype == A_SPY || newtype == A_SCOUT) {
    P_ASTAT = SCOUT;
    AADJSTAT;
  }
  P_ATYPE = newtype;
  if (P_ATYPE != A_MERCENARY) {
    sct[XREAL][YREAL].people -= men;
    SADJCIV;
  } else {
    mercgot += men;
    AADJMERC;
  }
  AADJLOC;
  P_AMOVE = 0;
  AADJMOV;
  P_ASOLD += men;
  AADJMEN;
  if (P_ASTAT >= NUMSTATUS) {
    P_ASTAT = ATTACK;
    AADJSTAT;
  }
  curntn->metals -= i_cost;
  curntn->tgold -= e_cost;
  makemap(); /* if display 'y' is set, this will show new
				 * army */
  if (isgod == TRUE)
    reset_god();
}
Example #5
0
void GpbAtrial::Initialize() {
    type = "Human Atrial (Grandi 2011)";
    Cm = 1.0; //uF/cm2
    ACap = 1.10E-4; //capacitive area, cm2
    dVdt=dVdtmax=0.0;
    t=0.0;
    dt = dtmin = 0.005;
    dtmed = 0.005;
    dtmax = 0.005;
    dvcut = 1.0;
    vOld=vNew=-80.9763;

    apTime = 0.0;
//    flag = 0;
//    num = 0;

    Vcell = 3.3E-5;//uL
    Vsr = 0.035*Vcell;
    Vjunc = (5.39E-4)*Vcell;
    Vsl = 0.02*Vcell;
    Vmyo = 0.65*Vcell;
//###### Concentrations #########
    naI = 9.136; //mM
    naO = 140.0; //mM
    kI = 120.0; //mM
    kO = 5.4; //mM
    caI =0.00008597401; //mM
    caO = 1.8; //mM
    caSr = 0.01; //mM
    cajI = 0.0001737475; //mM
    caslI = 0.0001031812; //mM
    najI = 9.136; //mM
    naslI = 9.136; //mM
    clO = 150.0;//mM
    clI = 15.0; //mM
    mgI = 1.0; //mM
//##### Fractional Currents ########
    Fjunc = 0.11;
    Fsl = 1-Fjunc;
    F_juncCaL = 0.9;
    F_slCaL = 1-F_juncCaL;
//##### Buffers ########
//Sodium Buffers
    Nabj = 3.539892;
    Nabsl = 0.7720854; //mM
//Calcium Buffers
    TnCl = 0.008773191;//mM
    TnChc = 0.1078283; //mM
    TnChm = 0.01524002;
    CaM = 0.0002911916; //mM
    Myoc = 0.001298754; //mM
    Myom = 0.1381982;
    SRB = 0.002143165; //mM
//junctional and SL Ca buffers
    SLLj = 0.009566355;
    SLLsl = 0.1110363;
    SLHj = 0.007347888;
    SLHsl = 0.07297378;
//SR Ca buffer
    Csqnb = 1.242988;
//##### Gating Variables #####
    Gate.m = 0.001405627;
    Gate.h = .9867005;
    Gate.j = .991562;
    Gate.xkr = .008641386;
    Gate.xks = .005412034;
    Gate.xf = 0.004051574;
    Gate.yf = .9945511;
    Gate.xkur = 0.0;
    Gate.ykur = 1.0;
    Gate.d = 0.000007175662;
    Gate.f = 1.00;
    Gate.f_cabj = .02421991;
    Gate.f_cabsl = .01452605;

//####### RyR channel fractions
    Ryrr = 0.8884332;
    Ryro = 8.156628E-7;
    Ryri = 1.024274E-7;
    RI = 1.0-Ryrr-Ryro-Ryri;

    iTos = iTof = iTo = 0.0;
    iKsjunc = iKssl=iKs=iKr=iKur=iKpjunc = iKpsl = iKp = iK1 = 0.0;
    iNajunc = iNasl = iNabjunc = iNabsl = iNab = iNa = 0.0;
    iCajunc = iCasl = iCa = 0.0;
    iCaL = iCab = ipCa = 0.0;
    iCak = iCanajunc = iCanasl = iCana = 0.0;
    iNaKjunc = iNaKsl = iNak = 0.0;
    iNcxjunc = iNcxsl = iNaca = 0.0;
    iClcajunc = iClcasl = iClca = iClbk = 0.0;
    ipCajunc = ipCasl = ipCa = 0.0;
    iCabjunc = iCabsl = iCab = 0.0;

    Icajuncfactor=1;
    Icaslfactor=1;
    Icakfactor=1;
    Icanajuncfactor=1;
    Icanaslfactor=1;
    Icabslfactor=1;
    Icabjuncfactor=1;
    Ipcaslfactor=1;
    Ipcajuncfactor=1;
    Itofactor=1;
    Iksslfactor=1;
    Iksjuncfactor=1;
    Ikrfactor=1;
    Ik1factor=1;
    Ikurfactor=1;
    Ipkslfactor=1;
    Ipkjuncfactor=1;
    Inacaslfactor=1;
    Inacajuncfactor=1;
    Inakslfactor=1;
    Inakjuncfactor=1;
    Inabslfactor=1;
    Inabjuncfactor=1;
    Inaslfactor=1;
    Inajuncfactor=1;
    Jsrcarelfactor =1;
    Jsrleakfactor=1;
    Jsercafactor=1;
    Iclcaslfactor=1;
    Iclcajuncfactor=1;
    Iclbkfactor=1;



    makemap();

}