[ create a new paste ] login | about

Link: http://codepad.org/zEZiJKeR    [ raw code | output | fork ]

C, pasted on Nov 9:
    #include <stdio.h>
    #include <stdint.h>
    
    typedef uint64_t bboard;
    
    // Accessing a square of the bitboard
    bboard
    get (bboard b, int square)
    {
      return (b & (1ULL << square));
    }
    
    void
    print_board (bboard b)
    {
      int i, j, square;
      for (i = 7; i >= 0; i--) // rank => top to bottom
        {
          for (j = 0; j < 8; j++) // file => left to right
            printf ("%d ", get (b, j+8*i) ? 1 : 0);
          printf ("\n");
        }
    }
    
    int
    main ()
    {
      bboard b = 0xffffffffffffffffLL;
      print_board (b);
    }


Output:
1
2
3
4
5
6
7
8
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 


Create a new paste based on this one


Comments: