@@ -28,7 +28,7 @@ pos[0] = pos[1] = -1;
2828
2929const boardTracer = new Array2DTracer ( 'Board' ) . set ( board ) ;
3030const posTracer = new Array1DTracer ( 'Knight Position' ) . set ( pos ) ;
31- const logTracer = new LogTracer ( 'Console' ) . wait ( ) ;
31+ const logTracer = new LogTracer ( 'Console' ) . delay ( ) ;
3232
3333function knightTour ( x , y , moveNum ) {
3434 if ( moveNum === N * N ) {
@@ -39,10 +39,10 @@ function knightTour(x, y, moveNum) {
3939 const nextX = x + X [ i ] ;
4040 const nextY = y + Y [ i ] ;
4141
42- posTracer . notify ( 0 , nextX ) . wait ( ) ;
43- posTracer . notify ( 1 , nextY ) . wait ( ) ;
44- posTracer . denotify ( 0 ) ;
45- posTracer . denotify ( 1 ) ;
42+ posTracer . patch ( 0 , nextX ) . delay ( ) ;
43+ posTracer . patch ( 1 , nextY ) . delay ( ) ;
44+ posTracer . depatch ( 0 ) ;
45+ posTracer . depatch ( 1 ) ;
4646 /*
4747 Check if knight is still in the board
4848 Check that knight does not visit an already visited square
@@ -51,8 +51,8 @@ function knightTour(x, y, moveNum) {
5151 board [ nextX ] [ nextY ] = moveNum ;
5252
5353 logTracer . print ( `Move to ${ nextX } ,${ nextY } ` ) ;
54- boardTracer . notify ( nextX , nextY , moveNum ) . wait ( ) ;
55- boardTracer . denotify ( nextX , nextY ) ;
54+ boardTracer . patch ( nextX , nextY , moveNum ) . delay ( ) ;
55+ boardTracer . depatch ( nextX , nextY ) ;
5656 boardTracer . select ( nextX , nextY ) ;
5757
5858 const nextMoveNum = moveNum + 1 ;
@@ -61,8 +61,8 @@ function knightTour(x, y, moveNum) {
6161 }
6262 logTracer . print ( `No place to move from ${ nextX } ,${ nextY } : Backtrack` ) ;
6363 board [ nextX ] [ nextY ] = - 1 ; // backtrack
64- boardTracer . notify ( nextX , nextY , - 1 ) . wait ( ) ;
65- boardTracer . denotify ( nextX , nextY ) ;
64+ boardTracer . patch ( nextX , nextY , - 1 ) . delay ( ) ;
65+ boardTracer . depatch ( nextX , nextY ) ;
6666 boardTracer . deselect ( nextX , nextY ) ;
6767 } else {
6868 logTracer . print ( `${ nextX } ,${ nextY } is not a valid move` ) ;
@@ -75,13 +75,13 @@ board[0][0] = 0; // start from this position
7575pos [ 0 ] = 0 ;
7676pos [ 0 ] = 0 ;
7777
78- boardTracer . notify ( 0 , 0 , 0 ) . wait ( ) ;
79- posTracer . notify ( 0 , 0 ) . wait ( ) ;
80- posTracer . notify ( 1 , 0 ) . wait ( ) ;
81- boardTracer . denotify ( 0 , 0 ) ;
82- boardTracer . denotify ( 0 , 0 ) ;
83- posTracer . denotify ( 0 ) ;
84- posTracer . denotify ( 1 ) ;
78+ boardTracer . patch ( 0 , 0 , 0 ) . delay ( ) ;
79+ posTracer . patch ( 0 , 0 ) . delay ( ) ;
80+ posTracer . patch ( 1 , 0 ) . delay ( ) ;
81+ boardTracer . depatch ( 0 , 0 ) ;
82+ boardTracer . depatch ( 0 , 0 ) ;
83+ posTracer . depatch ( 0 ) ;
84+ posTracer . depatch ( 1 ) ;
8585
8686if ( knightTour ( 0 , 0 , 1 ) === false ) {
8787 logTracer . print ( 'Solution does not exist' ) ;
0 commit comments