Beispiel #1
0
/* Get a keystroke from the user (or from a macro) and perform the
 * indicated command. A non-zero return value indicates a request to
 * change the current puzzle, the actual value being a delta.
 */
static int doturn(void)
{
    switch (input()) {
      case ARROW_N: if (!movecursor(NORTH))		ding();	break;
      case ARROW_E: if (!movecursor(EAST))		ding();	break;
      case ARROW_S: if (!movecursor(SOUTH))		ding();	break;
      case ARROW_W: if (!movecursor(WEST))		ding();	break;
      case 'k':     if (!shiftfromcurrblock(NORTH))	ding();	break;
      case 'l':     if (!shiftfromcurrblock(EAST))	ding();	break;
      case 'j':     if (!shiftfromcurrblock(SOUTH))	ding();	break;
      case 'h':     if (!shiftfromcurrblock(WEST))	ding();	break;
      case 'K':     if (!newmove(NORTH))		ding();	break;
      case 'L':     if (!newmove(EAST))			ding();	break;
      case 'J':     if (!newmove(SOUTH)) 		ding();	break;
      case 'H':     if (!newmove(WEST))			ding();	break;
      case 'x':     if (!undomove())			ding();	break;
      case 'z':     if (!redomove())			ding();	break;
      case 'X':     if (!undostep())			ding();	break;
      case 'Z':     if (!redostep())			ding();	break;
      case 'R':     initgamestate();				break;
      case 's':     savestate();				break;
      case 'r':     if (!restorestate())		ding();	break;
      case 'S':     if (!partialsave())			ding();	break;
      case 'g':	    drawgoalscreen();				break;
      case '?':     drawhelpscreen();				break;
      case '\f':						break;
      case 'P':     return -1;
      case 'N':     return +1;
      case 'q':     exit(0);
      case 'Q':     exit(0);
    }

    return 0;
}
Beispiel #2
0
local void oldrun(void) {
  restorestate(getparam("restore"));		// read in old state file
  if (getparamstat("eps") & ARGPARAM)		// was eps given new value?
    eps = getdparam("eps");			// use command line value
  if (getparamstat("nstatic") & ARGPARAM)	// likewise for others...
    nstatic = getiparam("nstatic");
#if !defined(QUICKSCAN)
  if (getparamstat("theta") & ARGPARAM)
    theta = getdparam("theta");
#endif
  if (getparamstat("usequad") & ARGPARAM)
    usequad = getbparam("usequad");
  if (getparamstat("options") & ARGPARAM)
    options = getparam("options");
  if (getparamstat("outputs") & ARGPARAM)
    outputs = getparam("outputs");
  if (getparamstat("tstop") & ARGPARAM)
    tstop = getdparam("tstop");
  if (getparamstat("dtout") & ARGPARAM)
    dtout = getdparam("dtout");
  if (scanopt(options, "new-tout"))		// if output time reset
    tout = tnow + dtout;			// then offset from now
}
Beispiel #3
0
startrun()
{
    string restfile, contfile;
    bool scanopt();
    proc get_potential();
    infile = getparam("in");			/* set I/O file names       */
    outfile = getparam("out");
    restfile = getparam("restart");
    contfile = getparam("continue");
    savefile = getparam("save");
    options = getparam("options");		/* set control options      */
    debug = getbparam("hdebug");
    if (debug)
	dprintf(0,"hdebug is turned on");
    nrigid = getiparam("nrigid");
    if (*contfile)	         		/* resume interrupted run   */
	restorestate(contfile);
    else if (*restfile) {	        	 /* resume w/ new parameters */
	restorestate(restfile);
	/* NOTE: someday, I will have a way to tell which, if any, of these *
	 * parameters are actually input from the command line, and only    *
	 * change them.  ANY NON-DEFAULT ARGS MUST BE SPECIFIED AT RESTART. */
	eps = getdparam("eps");			/*   get modified params    */
	tol = getdparam("tol");
	options = getparam("options");		/*   restorestate overwrite */
	fcells = getdparam("fcells");
	tstop = getdparam("tstop");
	freqout = getdparam("freqout");
	minor_freqout = getdparam("minor_freqout");
	if (scanopt(options, "new_tout")) {	/*   reset output times?    */
	    tout = tnow + 1 / freqout;		/*     offset from present  */
	    minor_tout = tnow + 1 / minor_freqout;
	}
    } else {					/* start new calculation    */
	if (*infile)	                 	/*   was data file given?   */
	    inputdata(infile);			/*     read inital data     */
	else {					/*   make initial conds?    */
	    nbody = getiparam("nbody");		/*     get nbody parameter  */
	    if (nbody < 1)			/*     is value absurd?     */
		error("startrun: absurd nbody\n");
	    init_xrandom(getparam("seed"));	/*     set random generator */
	    testdata(getbparam("cencon"));	/*     make test model      */
	}
	freq = getdparam("freq");		/*   get various parameters */
	eps = getdparam("eps");
	tol = getdparam("tol");
	fcells = getdparam("fcells");
	tstop = getdparam("tstop");
	freqout = getdparam("freqout");
	minor_freqout = getdparam("minor_freqout");
	nstep = 0;				/*   start counting steps   */
	minor_tout = tout = tnow;		/*   schedule first output  */
	SETVS(rmin, -2.0);			/*   init box scaling       */
	rsize = -2.0 * rmin[0];
    }
    contfile = getparam("potname");
    if (*contfile) {
        extpot = get_potential(contfile, 
                    getparam("potpars"),getparam("potfile"));
    }
}