codex
Loading...
Searching...
No Matches
chess0.c File Reference
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "chess_common.h"
Include dependency graph for chess0.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 u8 position
 

Enumerations

enum  {
  EMPTY , 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

position position0 (u8 i)
 
position position1 (u8 i)
 
bool is_empty (position p)
 
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

static 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 chess0.c:7
@ POS_BITS
Definition chess0.c:12
@ PIECE_BITS
Definition chess0.c:12
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

◆ u8

typedef uint8_t u8

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EMPTY 
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 call graph for this function:
Here is the caller graph for this function:

◆ is_empty()

bool is_empty ( position p)
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 call graph for this function:
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:
Here is the caller graph for this function:

Variable Documentation

◆ b

const struct board b
static
Initial value:
= {
.v = {
},
}
#define R(i, c, t0, t1, t2, t3, t4, t5, t6, t7)
Definition chess0.c:55
@ KING
Definition chess0.c:10
@ PAWN
Definition chess0.c:10
@ WHITE
Definition chess0.c:11
@ ROOK
Definition chess0.c:10
@ QUEEN
Definition chess0.c:10
@ BISHOP
Definition chess0.c:10
@ KNIGHT
Definition chess0.c:10
@ BLACK
Definition chess0.c:11