added timer for maxed calculation time.
This commit is contained in:
11
lceb.c
11
lceb.c
@@ -20,6 +20,7 @@
|
||||
|
||||
static char *cmd;
|
||||
static int treetype=TREE_CATALAN;
|
||||
static int maxmillisecs=0;
|
||||
extern int displaytimer, displayintermediate, displaytype, firstonly;
|
||||
int displaysummary=1;
|
||||
|
||||
@@ -42,7 +43,7 @@ void help()
|
||||
{
|
||||
usage();
|
||||
fprintf(stderr, "Countdown game solver.\n");
|
||||
fprintf(stderr, " -1: Stops immediately when one solution is found\n");
|
||||
fprintf(stderr, " -1: Show only one solution (immediate stop when exact solution found\n");
|
||||
fprintf(stderr, " -c: Show solutions timer\n");
|
||||
fprintf(stderr, " -d TYPE: Solutions display type. TYPE can be:\n");
|
||||
fprintf(stderr, " r: RPN (default)\n");
|
||||
@@ -54,6 +55,7 @@ void help()
|
||||
fprintf(stderr, " -i: Show intermediate solutions\n");
|
||||
fprintf(stderr, " -s: Do not show summary (time, nodes evaluated)\n");
|
||||
fprintf(stderr, " -t: Use less trees (Wedderburn–Etherington instead of Catalan)\n");
|
||||
fprintf(stderr, " -T TIMER: Will stop after TIMER 1/10th seconds\n");
|
||||
fprintf(stderr, " -h: This help\n");
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ int main(ac, av)
|
||||
TREE *tree;
|
||||
char intarray[1024];
|
||||
char *comb;
|
||||
char *options="1thcisd:";
|
||||
char *options="1thcisd:T:";
|
||||
int option;
|
||||
# ifdef DEBUG_MAINLOOP
|
||||
int eval;
|
||||
@@ -124,6 +126,9 @@ int main(ac, av)
|
||||
case 's':
|
||||
displaysummary=0;
|
||||
break;
|
||||
case 'T':
|
||||
maxmillisecs=atoi(optarg)*100;
|
||||
break;
|
||||
case 't':
|
||||
treetype=TREE_WEDDERBURN;
|
||||
break;
|
||||
@@ -143,6 +148,8 @@ int main(ac, av)
|
||||
}
|
||||
setlocale(LC_ALL, ""); /* to use "%'d" in printf */
|
||||
start_timer();
|
||||
if (maxmillisecs)
|
||||
set_alarm(maxmillisecs);
|
||||
target=atoi(av[optind]);
|
||||
stacksize=ac-optind-1;
|
||||
nops=stacksize-1;
|
||||
|
Reference in New Issue
Block a user