Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 64 bit uint used as 8x8 gameboard bitmap
- // what am i doing with my life
- #include <stdio.h>
- #include <stdint.h>
- // #define UINT64_C(c) c ## ULL
- uint64_t W[4] = {1,1,1,1}, B[4] = {1,1,1,1}, WhiteSet,BlackSet,CollisionSet;
- /* 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 1 */
- // return 1 if success
- int lshift_white(uint64_t selected_piece, unsigned int shift_amount)
- {
- if (!((CollisionSet ^ ((selected_piece) << shift_amount)) == CollisionSet)) {
- WhiteSet = WhiteSet ^ (selected_piece);
- selected_piece = (selected_piece) << shift_amount;
- WhiteSet = WhiteSet & (selected_piece);
- CollisionSet = WhiteSet & BlackSet;
- return 1;
- } else {
- return 0;
- }
- }
- int main(int argc, char *argv[])
- {
- printf("W[0] equals ", W[0], "\n");
- B[0] = B[0] << 62; // 1st byte is 01000000
- B[1] = B[1] << 57; // 1st byte is 00000010
- B[2] = B[2] << 55; // 2nd byte is 10000000
- B[0] = B[0] << 48; // 2nd byte is 00000001
- W[1] = W[1] << 15; // 7th byte is 10000000
- W[3] = W[3] << 8; // 7th byte is 00000001
- W[0] = W[0] << 6; // 8th byte is 01000000
- W[2] = W[2] << 1; // 8th byte is 00000010
- printf("W[0] equals ", W[0], "\n");
- BlackSet = B[0] & B[1] & B[2] & B[3];
- WhiteSet = W[0] & W[1] & W[2] & W[3];
- CollisionSet = BlackSet & WhiteSet;
- printf("W[0] equals ", W[0], "\n");
- int x = lshift_white(W[0], 1);
- printf("W[0] equals ", W[0], "!");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement