Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peter Norvig's use of asterisks in PAIP arrays

In Peter Norvig's PAIP, section 18.12, pg. 643 (unfortunately not part of the Google Books preview), he includes 2D arrays like:

(/ (aref '#2A((.1  .4 .7)
              (.05 .3  *)
              (.01  *  *))
         (count-edge-neighbors ...)
         (count-edge-neighbors ...)))

What do the asterisks (*) represent? I assumed some shorthand for symmetry, but later there's a lot of repetition like:

'#2A((;stab  semi     un
      (   *     0 -2000)                ; X
      ( 700     *     *)                ; corner
      (1200   200   -25)                ; C
      (1000   200    75)                ; A
      (1000   200    50)                ; B
      (1000   200    50)                ; B
      (1000   200    75)                ; A
      (1200   200   -25)                ; C
      ( 700     *     *)                ; corner
      (   *     0 -2000)                ; X
      )) 

So I'm at a loss.

like image 233
Tianxiang Xiong Avatar asked Jan 04 '23 06:01

Tianxiang Xiong


1 Answers

The chapter implements sophisticated game play for the game of Othello.

Norvig uses some 2d arrays to get fixed values depending on two dimensional input.

The * is an arbitrary placeholder for not applicable or unused value

For unused values in the 2d array, he uses markers, here a symbol *. Note that the choice is arbitrary, he could have used any data object, since that value will never be accessed and thus will not be used in an arithmetic formula.

Take for example the second array, which is a table of weights. A corner piece has the weights of the second row in that array. A corner piece is always stable. If it is stable (which it always is, since it cannot be captured), then the value is 700. Since a corner piece can't be semi-stable (second value. Means: neither stable nor unstable) or unstable (immediate danger of being captured, third value), these values will never be used and can be set to an arbitrary value: Norvig used *. A corner simply has no values for those weights and thus * marks that here. In the computation, these marks will never be used and are only here for the human reader and to put something into these array slots, since we can't leave them out in a printed representation of a 2d array.

like image 190
Rainer Joswig Avatar answered Jan 14 '23 00:01

Rainer Joswig