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 <stdint.h>
- // #define UINT64_C(c) c ## ULL
- uint64_t W[4] = {1,1,1,1}, B = {1,1,1,1};
- /* 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 */
- B[3] = B[3] << 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
- uint64_t BlackSet = B[0] & B[1] & B[2] & B[3];
- uint64_t WhiteSet = W[0] & W[1] & W[2] & W[3];
- uint64_t CollisionSet = BlackSet & WhiteSet;
- // 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[])
- {
- int x = lshift_white(*W[0], 1); // Should be 10000000
- printf("W[0] equals ", W[0]);
- return 0;
- }
- /*
- X:\lvAMZNS\Day7\C>cl main.c
- Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64
- Copyright (C) Microsoft Corporation. All rights reserved.
- main.c
- main.c(7): error C2078: too many initializers
- main.c(16): error C2040: 'B': 'int [3]' differs in levels of indirection from 'uint64_t'
- main.c(16): error C2109: subscript requires array or pointer type
- main.c(17): error C2040: 'B': 'int [1]' differs in levels of indirection from 'uint64_t'
- main.c(17): error C2109: subscript requires array or pointer type
- main.c(18): error C2040: 'B': 'int [2]' differs in levels of indirection from 'uint64_t'
- main.c(18): error C2109: subscript requires array or pointer type
- main.c(19): error C2466: cannot allocate an array of constant size 0
- main.c(19): error C2040: 'B': 'int [0]' differs in levels of indirection from 'uint64_t'
- main.c(19): error C2109: subscript requires array or pointer type
- main.c(20): error C2369: 'W': redefinition; different subscripts
- main.c(7): note: see declaration of 'W'
- main.c(20): error C2099: initializer is not a constant
- main.c(21): error C2369: 'W': redefinition; different subscripts
- main.c(7): note: see declaration of 'W'
- main.c(21): error C2099: initializer is not a constant
- main.c(22): error C2466: cannot allocate an array of constant size 0
- main.c(22): error C2371: 'W': redefinition; different basic types
- main.c(7): note: see declaration of 'W'
- main.c(22): error C2099: initializer is not a constant
- main.c(23): error C2369: 'W': redefinition; different subscripts
- main.c(7): note: see declaration of 'W'
- main.c(23): error C2099: initializer is not a constant
- main.c(25): error C2109: subscript requires array or pointer type
- main.c(26): error C2099: initializer is not a constant
- main.c(27): error C2099: initializer is not a constant
- main.c(45): error C2100: illegal indirection
- main.c(45): warning C4047: 'function': 'uint64_t *' differs in levels of indirection from 'uint64_t'
- main.c(45): warning C4024: 'lshift_white': different types for formal and actual parameter 1
- */
Add Comment
Please, Sign In to add comment