Added cross-compiling to windows
This commit is contained in:
parent
bc67a1f7f9
commit
4b4ded94b6
2 changed files with 47 additions and 26 deletions
22
logic.c
22
logic.c
|
|
@ -17,13 +17,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbit.h>
|
||||
#include <stdio.h>
|
||||
#include "logic.h"
|
||||
#include "macros.h"
|
||||
|
||||
static column_t heightMask( const rowsint_t a ){
|
||||
return ( 1 << (column_t)a ) - (column_t)1;
|
||||
return (column_t)( (column_t)1 << (column_t)a ) - (column_t)1;
|
||||
}
|
||||
|
||||
static column_t safeHeightMask( const rowsint_t a ){
|
||||
|
|
@ -35,16 +33,18 @@ static column_t bottomHeightMask( const rowsint_t a, const rowsint_t b ){
|
|||
}
|
||||
|
||||
static void updateTotal( wincount_t *count ){
|
||||
count->total =
|
||||
count->total = (winint_t)(
|
||||
count->horizontal
|
||||
+ count->vertical
|
||||
+ count->diagonalUp
|
||||
+ count->diagonalDown;
|
||||
+ count->diagonalDown);
|
||||
}
|
||||
|
||||
// popcount for a column
|
||||
static winint_t popcnt_column( column_t column ){
|
||||
winint_t i = (winint_t)__builtin_popcountg( (uint64_t)column );
|
||||
static winint_t popcnt_column( const column_t column ){
|
||||
// winint_t i = (winint_t)__builtin_popcountg( (uint64_t)column );
|
||||
winint_t i = 0;
|
||||
for( column_t c = column; c != 0; i++ ) c &= c - 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ void calcWins_slow( board_t *boardptr ){
|
|||
& safeHeightMask( boardptr->height[ column + 1 ] )
|
||||
& safeHeightMask( boardptr->height[ column + 2 ] )
|
||||
& safeHeightMask( boardptr->height[ column + 3 ] )
|
||||
& ( ( (column_t)1 << (column_t)boardptr->rows ) - (column_t)1 )
|
||||
& safeHeightMask( boardptr->rows )
|
||||
);
|
||||
boardptr->count1.horizontal += popcnt_column(
|
||||
boardptr->column[ column ]
|
||||
|
|
@ -138,7 +138,7 @@ void calcWins_slow( board_t *boardptr ){
|
|||
& safeHeightMask( boardptr->height[ column + 1 ] - 1 )
|
||||
& safeHeightMask( boardptr->height[ column + 2 ] - 2 )
|
||||
& safeHeightMask( boardptr->height[ column + 3 ] - 3 )
|
||||
& ( ( (column_t)1 << (column_t)boardptr->rows ) - (column_t)1 )
|
||||
& safeHeightMask( boardptr->rows )
|
||||
);
|
||||
boardptr->count1.diagonalUp += popcnt_column(
|
||||
boardptr->column[ column ]
|
||||
|
|
@ -151,7 +151,7 @@ void calcWins_slow( board_t *boardptr ){
|
|||
| boardptr->column[ column + 1 ] << 1
|
||||
| boardptr->column[ column + 2 ] << 2
|
||||
| boardptr->column[ column + 3 ] << 3
|
||||
| 0x07 // A line diagonal down don't start at one of the bottom 3
|
||||
| (column_t)( 0x07 ) // A line diagonal down don't start at one of the bottom 3
|
||||
)
|
||||
& bottomHeightMask(
|
||||
bottom( boardptr->height[ column ],
|
||||
|
|
@ -161,7 +161,7 @@ void calcWins_slow( board_t *boardptr ){
|
|||
boardptr->height[ column + 3 ] + 3
|
||||
)
|
||||
)
|
||||
& ( ( (column_t)1 << (column_t)boardptr->rows ) - (column_t)1 )
|
||||
& safeHeightMask( boardptr->rows )
|
||||
);
|
||||
boardptr->count1.diagonalDown += popcnt_column(
|
||||
boardptr->column[ column ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue