codex
Loading...
Searching...
No Matches
chess1.c File Reference
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include "chess_common.h"
Include dependency graph for chess1.c:

Classes

struct  board
 

Macros

#define P(c, t0, t1)
 
#define R(i, c, t0, t1, t2, t3, t4, t5, t6, t7)    [i] = P(c, t0, t1), P(c, t2, t3), P(c, t4, t5), P(c, t6, t7)
 

Typedefs

typedef uint8_t u8
 
typedef uint64_t u64
 
typedef u8 position
 

Enumerations

enum  {
  PAWN , ROOK , KNIGHT , BISHOP ,
  QUEEN , KING , WHITE = 0 , BLACK = 1 ,
  POS_BITS = 4 , PIECE_BITS = 3 , POS_MASK = (1 << POS_BITS) - 1 , PIECE_MASK = (1 << PIECE_BITS) - 1 ,
  COLOR_MASK = (1 << PIECE_BITS)
}
 

Functions

bool is_empty (const struct board *b, u8 x, u8 y)
 
int popcnt (u64 n)
 
position position0 (u8 i)
 
position position1 (u8 i)
 
bool color (position p)
 
u8 piece (position p)
 
position board_position (const struct board *b, u8 x, u8 y)
 
static void print_pos (const struct board *b, int x, int y)
 
int main (void)
 

Variables

const struct board b
 

Macro Definition Documentation

◆ P

#define P ( c,
t0,
t1 )
Value:
(u8)((c << (PIECE_BITS + POS_BITS)) | (t1 << POS_BITS) \
| (c << PIECE_BITS) | t0)
uint8_t u8
Definition chess1.c:8
@ POS_BITS
Definition chess1.c:14
@ PIECE_BITS
Definition chess1.c:14
Definition mult_inh.c:27

◆ R

#define R ( i,
c,
t0,
t1,
t2,
t3,
t4,
t5,
t6,
t7 )    [i] = P(c, t0, t1), P(c, t2, t3), P(c, t4, t5), P(c, t6, t7)

Typedef Documentation

◆ position

typedef u8 position

◆ u64

typedef uint64_t u64

◆ u8

typedef uint8_t u8

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAWN 
ROOK 
KNIGHT 
BISHOP 
QUEEN 
KING 
WHITE 
BLACK 
POS_BITS 
PIECE_BITS 
POS_MASK 
PIECE_MASK 
COLOR_MASK 

Function Documentation

◆ board_position()

position board_position ( const struct board * b,
u8 x,
u8 y )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ color()

bool color ( position p)
Here is the caller graph for this function:

◆ is_empty()

bool is_empty ( const struct board * b,
u8 x,
u8 y )
Here is the caller graph for this function:

◆ main()

int main ( void )
Here is the call graph for this function:

◆ piece()

u8 piece ( position p)
Here is the caller graph for this function:

◆ popcnt()

int popcnt ( u64 n)
Here is the caller graph for this function:

◆ position0()

position position0 ( u8 i)
Here is the caller graph for this function:

◆ position1()

position position1 ( u8 i)
Here is the caller graph for this function:

◆ print_pos()

static void print_pos ( const struct board * b,
int x,
int y )
static
Here is the call graph for this function:

Variable Documentation

◆ b

const struct board b
Initial value:
= {
.bitset = 0xffff00000000ffff,
.v = {
},
}
#define R(i, c, t0, t1, t2, t3, t4, t5, t6, t7)
Definition chess1.c:77
@ KING
Definition chess1.c:12
@ PAWN
Definition chess1.c:12
@ WHITE
Definition chess1.c:13
@ ROOK
Definition chess1.c:12
@ QUEEN
Definition chess1.c:12
@ BISHOP
Definition chess1.c:12
@ KNIGHT
Definition chess1.c:12
@ BLACK
Definition chess1.c:13