| 1 | #include <stdio.h>
|
|---|
| 2 | #include "treeverse.h"
|
|---|
| 3 |
|
|---|
| 4 | int str2int(char *str) {
|
|---|
| 5 | int res = 0 ;
|
|---|
| 6 | while(*str) {
|
|---|
| 7 | res = (res * 10) + (*str) - '0' ;
|
|---|
| 8 | str++ ;
|
|---|
| 9 | }
|
|---|
| 10 | return(res) ;
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | int main(int argc, char *argv[]) {
|
|---|
| 14 | int action,step ;
|
|---|
| 15 | int nstp = 10 ;
|
|---|
| 16 | int nsnp = 3 ;
|
|---|
| 17 | if (argc>1) nstp=str2int(argv[1]) ;
|
|---|
| 18 | if (argc>2) nsnp=str2int(argv[2]) ;
|
|---|
| 19 | printf("REVERSING %i STEPS WITH %i SNAPSHOTS:\n",nstp,nsnp) ;
|
|---|
| 20 | trv_init(nstp, nsnp, 1) ;
|
|---|
| 21 | while (trv_next_action(&action, &step)) {
|
|---|
| 22 | switch (action) {
|
|---|
| 23 | case PUSHSNAP :
|
|---|
| 24 | printf("[%i] PUSH SNAPSHOT %i\n",action,step) ;
|
|---|
| 25 | break ;
|
|---|
| 26 | case LOOKSNAP :
|
|---|
| 27 | printf("[%i] LOOK SNAPSHOT %i\n",action,step) ;
|
|---|
| 28 | break ;
|
|---|
| 29 | case POPSNAP :
|
|---|
| 30 | printf("[%i] POP SNAPSHOT %i\n",action,step) ;
|
|---|
| 31 | break ;
|
|---|
| 32 | case ADVANCE :
|
|---|
| 33 | printf("[%i] ADVANCE ONE STEP %i\n",action,step) ;
|
|---|
| 34 | break ;
|
|---|
| 35 | case FIRSTTURN :
|
|---|
| 36 | printf("[%i] FIRST TURN %i\n",action,step) ;
|
|---|
| 37 | break ;
|
|---|
| 38 | case TURN :
|
|---|
| 39 | printf("[%i] TURN %i\n",action,step) ;
|
|---|
| 40 | break ;
|
|---|
| 41 | default :
|
|---|
| 42 | printf("[%i] ?? %i\n",action,step) ;
|
|---|
| 43 | break ;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | /* if (step==8 && action==4) { */
|
|---|
| 47 | /* printf(" =============> step 8: TRV_RESIZE() !!!\n") ; */
|
|---|
| 48 | /* trv_resize() ; */
|
|---|
| 49 | /* } */
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|