LCOV - code coverage report
Current view: top level - src - sqmove.h (source / functions) Hit Total Coverage
Test: test_coverage.info Lines: 2 2 100.0 %
Date: 2017-06-21 14:32:49 Functions: 0 0 -

          Line data    Source code
       1             : //////////////////////////////////////////////////////////////////////
       2             : //
       3             : //  FILE:       sqmove.h
       4             : //              Square movement lookup table
       5             : //
       6             : //  Part of:    Scid (Shane's Chess Information Database)
       7             : //  Version:    3.4
       8             : //
       9             : //  Notice:     Copyright (c) 1999-2002  Shane Hudson.  All rights reserved.
      10             : //
      11             : //  Author:     Shane Hudson (sgh@users.sourceforge.net)
      12             : //
      13             : //////////////////////////////////////////////////////////////////////
      14             : 
      15             : #ifndef SCID_SQMOVE_H
      16             : #define SCID_SQMOVE_H
      17             : 
      18             : //~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      19             : // sqMove
      20             : //   Array indexed by square value and direction, giving the square
      21             : //   obtained by moving from the square in that direction.
      22             :   const squareT
      23             : sqMove[66][11] = {
      24             :                 /* UP DOWN    LEFT UL  DL    RIGHT UR  DR */
      25             :    { /* A1 */  NS, A2, NS, NS, NS, NS, NS, NS, B1, B2, NS   },
      26             :    { /* B1 */  NS, B2, NS, NS, A1, A2, NS, NS, C1, C2, NS   },
      27             :    { /* C1 */  NS, C2, NS, NS, B1, B2, NS, NS, D1, D2, NS   },
      28             :    { /* D1 */  NS, D2, NS, NS, C1, C2, NS, NS, E1, E2, NS   },
      29             :    { /* E1 */  NS, E2, NS, NS, D1, D2, NS, NS, F1, F2, NS   },
      30             :    { /* F1 */  NS, F2, NS, NS, E1, E2, NS, NS, G1, G2, NS   },
      31             :    { /* G1 */  NS, G2, NS, NS, F1, F2, NS, NS, H1, H2, NS   },
      32             :    { /* H1 */  NS, H2, NS, NS, G1, G2, NS, NS, NS, NS, NS   },
      33             :    { /* A2 */  NS, A3, A1, NS, NS, NS, NS, NS, B2, B3, B1   },
      34             :    { /* B2 */  NS, B3, B1, NS, A2, A3, A1, NS, C2, C3, C1   },
      35             :    { /* C2 */  NS, C3, C1, NS, B2, B3, B1, NS, D2, D3, D1   },
      36             :    { /* D2 */  NS, D3, D1, NS, C2, C3, C1, NS, E2, E3, E1   },
      37             :    { /* E2 */  NS, E3, E1, NS, D2, D3, D1, NS, F2, F3, F1   },
      38             :    { /* F2 */  NS, F3, F1, NS, E2, E3, E1, NS, G2, G3, G1   },
      39             :    { /* G2 */  NS, G3, G1, NS, F2, F3, F1, NS, H2, H3, H1   },
      40             :    { /* H2 */  NS, H3, H1, NS, G2, G3, G1, NS, NS, NS, NS   },
      41             :    { /* A3 */  NS, A4, A2, NS, NS, NS, NS, NS, B3, B4, B2   },
      42             :    { /* B3 */  NS, B4, B2, NS, A3, A4, A2, NS, C3, C4, C2   },
      43             :    { /* C3 */  NS, C4, C2, NS, B3, B4, B2, NS, D3, D4, D2   },
      44             :    { /* D3 */  NS, D4, D2, NS, C3, C4, C2, NS, E3, E4, E2   },
      45             :    { /* E3 */  NS, E4, E2, NS, D3, D4, D2, NS, F3, F4, F2   },
      46             :    { /* F3 */  NS, F4, F2, NS, E3, E4, E2, NS, G3, G4, G2   },
      47             :    { /* G3 */  NS, G4, G2, NS, F3, F4, F2, NS, H3, H4, H2   },
      48             :    { /* H3 */  NS, H4, H2, NS, G3, G4, G2, NS, NS, NS, NS   },
      49             :    { /* A4 */  NS, A5, A3, NS, NS, NS, NS, NS, B4, B5, B3   },
      50             :    { /* B4 */  NS, B5, B3, NS, A4, A5, A3, NS, C4, C5, C3   },
      51             :    { /* C4 */  NS, C5, C3, NS, B4, B5, B3, NS, D4, D5, D3   },
      52             :    { /* D4 */  NS, D5, D3, NS, C4, C5, C3, NS, E4, E5, E3   },
      53             :    { /* E4 */  NS, E5, E3, NS, D4, D5, D3, NS, F4, F5, F3   },
      54             :    { /* F4 */  NS, F5, F3, NS, E4, E5, E3, NS, G4, G5, G3   },
      55             :    { /* G4 */  NS, G5, G3, NS, F4, F5, F3, NS, H4, H5, H3   },
      56             :    { /* H4 */  NS, H5, H3, NS, G4, G5, G3, NS, NS, NS, NS   },
      57             :    { /* A5 */  NS, A6, A4, NS, NS, NS, NS, NS, B5, B6, B4   },
      58             :    { /* B5 */  NS, B6, B4, NS, A5, A6, A4, NS, C5, C6, C4   },
      59             :    { /* C5 */  NS, C6, C4, NS, B5, B6, B4, NS, D5, D6, D4   },
      60             :    { /* D5 */  NS, D6, D4, NS, C5, C6, C4, NS, E5, E6, E4   },
      61             :    { /* E5 */  NS, E6, E4, NS, D5, D6, D4, NS, F5, F6, F4   },
      62             :    { /* F5 */  NS, F6, F4, NS, E5, E6, E4, NS, G5, G6, G4   },
      63             :    { /* G5 */  NS, G6, G4, NS, F5, F6, F4, NS, H5, H6, H4   },
      64             :    { /* H5 */  NS, H6, H4, NS, G5, G6, G4, NS, NS, NS, NS   },
      65             :    { /* A6 */  NS, A7, A5, NS, NS, NS, NS, NS, B6, B7, B5   },
      66             :    { /* B6 */  NS, B7, B5, NS, A6, A7, A5, NS, C6, C7, C5   },
      67             :    { /* C6 */  NS, C7, C5, NS, B6, B7, B5, NS, D6, D7, D5   },
      68             :    { /* D6 */  NS, D7, D5, NS, C6, C7, C5, NS, E6, E7, E5   },
      69             :    { /* E6 */  NS, E7, E5, NS, D6, D7, D5, NS, F6, F7, F5   },
      70             :    { /* F6 */  NS, F7, F5, NS, E6, E7, E5, NS, G6, G7, G5   },
      71             :    { /* G6 */  NS, G7, G5, NS, F6, F7, F5, NS, H6, H7, H5   },
      72             :    { /* H6 */  NS, H7, H5, NS, G6, G7, G5, NS, NS, NS, NS   },
      73             :    { /* A7 */  NS, A8, A6, NS, NS, NS, NS, NS, B7, B8, B6   },
      74             :    { /* B7 */  NS, B8, B6, NS, A7, A8, A6, NS, C7, C8, C6   },
      75             :    { /* C7 */  NS, C8, C6, NS, B7, B8, B6, NS, D7, D8, D6   },
      76             :    { /* D7 */  NS, D8, D6, NS, C7, C8, C6, NS, E7, E8, E6   },
      77             :    { /* E7 */  NS, E8, E6, NS, D7, D8, D6, NS, F7, F8, F6   },
      78             :    { /* F7 */  NS, F8, F6, NS, E7, E8, E6, NS, G7, G8, G6   },
      79             :    { /* G7 */  NS, G8, G6, NS, F7, F8, F6, NS, H7, H8, H6   },
      80             :    { /* H7 */  NS, H8, H6, NS, G7, G8, G6, NS, NS, NS, NS   },
      81             :    { /* A8 */  NS, NS, A7, NS, NS, NS, NS, NS, B8, NS, B7   },
      82             :    { /* B8 */  NS, NS, B7, NS, A8, NS, A7, NS, C8, NS, C7   },
      83             :    { /* C8 */  NS, NS, C7, NS, B8, NS, B7, NS, D8, NS, D7   },
      84             :    { /* D8 */  NS, NS, D7, NS, C8, NS, C7, NS, E8, NS, E7   },
      85             :    { /* E8 */  NS, NS, E7, NS, D8, NS, D7, NS, F8, NS, F7   },
      86             :    { /* F8 */  NS, NS, F7, NS, E8, NS, E7, NS, G8, NS, G7   },
      87             :    { /* G8 */  NS, NS, G7, NS, F8, NS, F7, NS, H8, NS, H7   },
      88             :    { /* H8 */  NS, NS, H7, NS, G8, NS, G7, NS, NS, NS, NS   },
      89             :    { /* NS */  NS, NS, NS, NS, NS, NS, NS, NS, NS, NS, NS   },
      90             :    { /* NS */  NS, NS, NS, NS, NS, NS, NS, NS, NS, NS, NS   }
      91             :  };
      92             : 
      93             : //~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      94             : // sqLast
      95             : //   Array indexed by square value and direction, giving the last
      96             : //   square reached by moving from the square in that direction.
      97             : //   The last square is the same as the original square if moving
      98             : //   in the specified direction would move off the board.
      99             :   const squareT
     100             : sqLast[66][11] = {
     101             :                 /* UP DOWN    LEFT UL  DL    RIGHT UR  DR */
     102             :    { /* A1 */  NS, A8, A1, NS, A1, A1, A1, NS, H1, H8, A1   },
     103             :    { /* B1 */  NS, B8, B1, NS, A1, A2, B1, NS, H1, H7, B1   },
     104             :    { /* C1 */  NS, C8, C1, NS, A1, A3, C1, NS, H1, H6, C1   },
     105             :    { /* D1 */  NS, D8, D1, NS, A1, A4, D1, NS, H1, H5, D1   },
     106             :    { /* E1 */  NS, E8, E1, NS, A1, A5, E1, NS, H1, H4, E1   },
     107             :    { /* F1 */  NS, F8, F1, NS, A1, A6, F1, NS, H1, H3, F1   },
     108             :    { /* G1 */  NS, G8, G1, NS, A1, A7, G1, NS, H1, H2, G1   },
     109             :    { /* H1 */  NS, H8, H1, NS, A1, A8, H1, NS, H1, H1, H1   },
     110             :    { /* A2 */  NS, A8, A1, NS, A2, A2, A2, NS, H2, G8, B1   },
     111             :    { /* B2 */  NS, B8, B1, NS, A2, A3, A1, NS, H2, H8, C1   },
     112             :    { /* C2 */  NS, C8, C1, NS, A2, A4, B1, NS, H2, H7, D1   },
     113             :    { /* D2 */  NS, D8, D1, NS, A2, A5, C1, NS, H2, H6, E1   },
     114             :    { /* E2 */  NS, E8, E1, NS, A2, A6, D1, NS, H2, H5, F1   },
     115             :    { /* F2 */  NS, F8, F1, NS, A2, A7, E1, NS, H2, H4, G1   },
     116             :    { /* G2 */  NS, G8, G1, NS, A2, A8, F1, NS, H2, H3, H1   },
     117             :    { /* H2 */  NS, H8, H1, NS, A2, B8, G1, NS, H2, H2, H2   },
     118             :    { /* A3 */  NS, A8, A1, NS, A3, A3, A3, NS, H3, F8, C1   },
     119             :    { /* B3 */  NS, B8, B1, NS, A3, A4, A2, NS, H3, G8, D1   },
     120             :    { /* C3 */  NS, C8, C1, NS, A3, A5, A1, NS, H3, H8, E1   },
     121             :    { /* D3 */  NS, D8, D1, NS, A3, A6, B1, NS, H3, H7, F1   },
     122             :    { /* E3 */  NS, E8, E1, NS, A3, A7, C1, NS, H3, H6, G1   },
     123             :    { /* F3 */  NS, F8, F1, NS, A3, A8, D1, NS, H3, H5, H1   },
     124             :    { /* G3 */  NS, G8, G1, NS, A3, B8, E1, NS, H3, H4, H2   },
     125             :    { /* H3 */  NS, H8, H1, NS, A3, C8, F1, NS, H3, H3, H3   },
     126             :    { /* A4 */  NS, A8, A1, NS, A4, A4, A4, NS, H4, E8, D1   },
     127             :    { /* B4 */  NS, B8, B1, NS, A4, A5, A3, NS, H4, F8, E1   },
     128             :    { /* C4 */  NS, C8, C1, NS, A4, A6, A2, NS, H4, G8, F1   },
     129             :    { /* D4 */  NS, D8, D1, NS, A4, A7, A1, NS, H4, H8, G1   },
     130             :    { /* E4 */  NS, E8, E1, NS, A4, A8, B1, NS, H4, H7, H1   },
     131             :    { /* F4 */  NS, F8, F1, NS, A4, B8, C1, NS, H4, H6, H2   },
     132             :    { /* G4 */  NS, G8, G1, NS, A4, C8, D1, NS, H4, H5, H3   },
     133             :    { /* H4 */  NS, H8, H1, NS, A4, D8, E1, NS, H4, H4, H4   },
     134             :    { /* A5 */  NS, A8, A1, NS, A5, A5, A5, NS, H5, D8, E1   },
     135             :    { /* B5 */  NS, B8, B1, NS, A5, A6, A4, NS, H5, E8, F1   },
     136             :    { /* C5 */  NS, C8, C1, NS, A5, A7, A3, NS, H5, F8, G1   },
     137             :    { /* D5 */  NS, D8, D1, NS, A5, A8, A2, NS, H5, G8, H1   },
     138             :    { /* E5 */  NS, E8, E1, NS, A5, B8, A1, NS, H5, H8, H2   },
     139             :    { /* F5 */  NS, F8, F1, NS, A5, C8, B1, NS, H5, H7, H3   },
     140             :    { /* G5 */  NS, G8, G1, NS, A5, D8, C1, NS, H5, H6, H4   },
     141             :    { /* H5 */  NS, H8, H1, NS, A5, E8, D1, NS, H5, H5, H5   },
     142             :    { /* A6 */  NS, A8, A1, NS, A6, A6, A6, NS, H6, C8, F1   },
     143             :    { /* B6 */  NS, B8, B1, NS, A6, A7, A5, NS, H6, D8, G1   },
     144             :    { /* C6 */  NS, C8, C1, NS, A6, A8, A4, NS, H6, E8, H1   },
     145             :    { /* D6 */  NS, D8, D1, NS, A6, B8, A3, NS, H6, F8, H2   },
     146             :    { /* E6 */  NS, E8, E1, NS, A6, C8, A2, NS, H6, G8, H3   },
     147             :    { /* F6 */  NS, F8, F1, NS, A6, D8, A1, NS, H6, H8, H4   },
     148             :    { /* G6 */  NS, G8, G1, NS, A6, E8, B1, NS, H6, H7, H5   },
     149             :    { /* H6 */  NS, H8, H1, NS, A6, F8, C1, NS, H6, H6, H6   },
     150             :    { /* A7 */  NS, A8, A1, NS, A7, A7, A7, NS, H7, B8, G1   },
     151             :    { /* B7 */  NS, B8, B1, NS, A7, A8, A6, NS, H7, C8, H1   },
     152             :    { /* C7 */  NS, C8, C1, NS, A7, B8, A5, NS, H7, D8, H2   },
     153             :    { /* D7 */  NS, D8, D1, NS, A7, C8, A4, NS, H7, E8, H3   },
     154             :    { /* E7 */  NS, E8, E1, NS, A7, D8, A3, NS, H7, F8, H4   },
     155             :    { /* F7 */  NS, F8, F1, NS, A7, E8, A2, NS, H7, G8, H5   },
     156             :    { /* G7 */  NS, G8, G1, NS, A7, F8, A1, NS, H7, H8, H6   },
     157             :    { /* H7 */  NS, H8, H1, NS, A7, G8, B1, NS, H7, H7, H7   },
     158             :    { /* A8 */  NS, A8, A1, NS, A8, A8, A8, NS, H8, A8, H1   },
     159             :    { /* B8 */  NS, B8, B1, NS, A8, B8, A7, NS, H8, B8, H2   },
     160             :    { /* C8 */  NS, C8, C1, NS, A8, C8, A6, NS, H8, C8, H3   },
     161             :    { /* D8 */  NS, D8, D1, NS, A8, D8, A5, NS, H8, D8, H4   },
     162             :    { /* E8 */  NS, E8, E1, NS, A8, E8, A4, NS, H8, E8, H5   },
     163             :    { /* F8 */  NS, F8, F1, NS, A8, F8, A3, NS, H8, F8, H6   },
     164             :    { /* G8 */  NS, G8, G1, NS, A8, G8, A2, NS, H8, G8, H7   },
     165             :    { /* H8 */  NS, H8, H1, NS, A8, H8, A1, NS, H8, H8, H8   },
     166             :    { /* NS */  NS, NS, NS, NS, NS, NS, NS, NS, NS, NS, NS   },
     167             :    { /* NS */  NS, NS, NS, NS, NS, NS, NS, NS, NS, NS, NS   }
     168             : };
     169             : 
     170             : // square_Move(): Return the new square resulting from moving in
     171             : //      direction d from x.
     172             :   inline squareT
     173             : square_Move(squareT sq, directionT dir)
     174             : {
     175    30411054 :     return sqMove[sq][dir];
     176             : }
     177             : 
     178             : // square_Last():
     179             : //   Return the last square reached by moving as far as possible in
     180             : //   the direction d from the square sq. If sq is a valid on-board
     181             : //   square and d is a valid direction, the result will always be
     182             : //   a valid on-board square; the result will be the same as the
     183             : //   input square if moving in the specified direction would end
     184             : //   up off the board.
     185             :   inline squareT
     186             : square_Last (squareT sq, directionT dir)
     187             : {
     188    13936400 :     return sqLast[sq][dir];
     189             : }
     190             : 
     191             : #endif
     192             : 
     193             : //////////////////////////////////////////////////////////////////////
     194             : //  EOF: sqmove.h
     195             : //////////////////////////////////////////////////////////////////////
     196             : 

Generated by: LCOV version 1.12