Exemple #1
0
void print_move(move_t* m) {
    print_piece(b.pieces[m->from_square]);
    print_square(m->from_square);
    print_square(m->to_square);
    if (m->move_type & MOVE_PROMOTION) {
        piece_t promo = m->move_type & 0x7;
        print_piece(promo);
    }
}
Exemple #2
0
/** Funcao que nos permite movimentar o jogador no tabuleiro */
void print_move(ESTADO e, int dx,int dy){
	int x =e.jog.x +dx;
	int y = e.jog.y +dy;
	/*estado para qual o jogo transita ao clicar no link*/
	ESTADO ne=e;
	if(e.goal.x==x && e.goal.y==y){
		ne.acao=1;
		printf("<a xlink:href=http://127.0.0.1/cgi-bin/jogo?%s>\n",estado2str(ne));
		print_goal(e);
		printf("</a >\n");
	}else{
		if(posvalida(e,x,y)==0){
			ne.jog.x=x;
			ne.jog.y=y;
			printf("<a xlink:href=http://127.0.0.1/cgi-bin/jogo?%s>\n",estado2str(ne));
			print_enemies(e);



			printf("</a >\n");

		}else{
			ne.jog.x=x;
			ne.jog.y=y;
			printf("<a xlink:href=http://127.0.0.1/cgi-bin/jogo?%s>\n",estado2str(ne));
			print_square(x,y,TAM);
			printf("</a >\n");
		}



		}


		}
void main(){
  
  omp_set_num_threads(8);
#pragma omp parallel 
  {
    int id = omp_get_thread_num();
    print_square(id);
  }
}
Exemple #4
0
void	put_food(t_box *box)
{
	box->color = 0xff00ff;
	box->food = (t_food *)ft_memalloc(sizeof(t_food));
	srand(time(NULL));
	box->food->pos_x = rand() % 48 + 1;
	box->food->pos_y = rand() % 48 + 1;
	box->grid[box->food->pos_y][box->food->pos_x] = 1;
	P("y == %i\nx == %i\n", box->food->pos_x, box->food->pos_y);
	print_square(box, box->food->pos_x * 20, box->food->pos_y * 20);
}
#define 		MAX_ROWS 3
#define 		MAX_COLS 4
void print_square(int [ ] );					/*function declaration */
void main (void)
{
	int row;
	int num [MAX_ROWS][MAX_COLS] = 
													{
																{	0,	1,	2,	3},
																{	4,	5,	6,	7},
																{	8,	9,	10,	 11} 
														};
	for(row=0; row<MAX_ROWS; row++)
			print_square(num[row]);
}
int main(void)
{
  print_square(1);
  print_square(2);
  print_square(3);
  print_square(4);
  print_square(10);
  print_square(0);
  return (0);
}
Exemple #7
0
void perm(int arr[], int l, int n, int k)
{
    int i;

    if (l == k) {
        if (is_magic_square(arr))
            print_square(arr);
        return;
    }

    for (i = l; i < n; i++) {
        swap(&arr[i], &arr[l]);
        perm(arr, l + 1, n, k);
        swap(&arr[i], &arr[l]);
    }
}
Exemple #8
0
void display_maze() {
	int i, j, width;
	ansi_set_position(3, 1);
	if (g_maze != NULL) {
		ansi_clear_screen_after();
		width = get_terminal_width();
		for (i = 0 ; i < g_maze->size ; i++) {
			ansi_set_column((width - g_maze->size) / 2);
			for (j = 0 ; j < g_maze->size ; j++) {
				print_square(g_maze->squares + (i * g_maze->size + j));
			}
			ansi_set_bg_color(ANSI_BLACK);
			putchar('\n');
		}
		g_maze_height = g_maze->size + 2;
	} else {
		ansi_clear_screen_after();
		g_maze_height = 0;
	}
	fflush(stdout);
}
Exemple #9
0
void print_fen() {
    for (uint8_t rank = 7; rank != 0xff; rank--) {
        int blanks = 0;
        for (uint8_t file = 0; file < 8; file++) {
            square_t sq = SQUARE(rank, file);
            if (b.pieces[sq] == PIECE_EMPTY) {
                blanks++;
                continue;
            } else {
                if (blanks > 0) {
                    plog("%d", blanks);
                    blanks = 0;
                }
                plog("%c", piece_chars[b.colors[sq]][b.pieces[sq]]);
            }
        }
        if (blanks > 0) {
            plog("%d", blanks);
            blanks = 0;
        }
        if (rank > 0) plog("/");
    }
    plog(" %c ", (b.stm == WHITE) ? 'w' : 'b');
    if (!(b.flags & (CASTLE_WK | CASTLE_WQ | CASTLE_BK | CASTLE_BQ))) {
        plog("-");
    } else {
        if (b.flags & CASTLE_WK) plog("K");
        if (b.flags & CASTLE_WQ) plog("Q");
        if (b.flags & CASTLE_BK) plog("k");
        if (b.flags & CASTLE_BQ) plog("q");
    }
    plog(" ");
    if (IS_SQUARE(b.ep)) {
        print_square(b.ep);
    } else {
        plog("-");
    }
    plog(" 0 %d", (b.ply / 2) + 1);
}
Exemple #10
0
int test_square(unsigned short x, unsigned short y, unsigned short size,
		unsigned long color) {

	if (vg_init(MODE_105) == NULL) {
		printf("Failed vg_init().\n");
		return 1;
	}

	if(print_square(x, y, size, color)==1)
	{
		if(vg_exit()==1)
		{
			printf("Failed vg_exit().\n");
		}
		printf("Wrong coordinates.\n");
		return 1;
	}

	if (wait_for_ESC() ==1) {
		printf("Failed wait_for_ESC().\n");
		return 1;
	}
	return 0;
}
Exemple #11
0
void update_square(Square * square) {
	Location location = get_square_location(square);
	ansi_set_position(1 + 2 + location.row, (get_terminal_width() - g_maze->size) / 2 + location.column);
	print_square(square);
	fflush(stdout);
}
Exemple #12
0
int muste_magic(char *argv)
{
    int i,j,method,spec,offs,raja,magic;

    s_init(argv);

    if (g<3)
    {
        sur_print("\nUsage: MAGIC CREATE <dim>");
        WAIT;
        return(1);
    }

    results_line=r1+r;
    i=sp_init(r1+r-1);
    if (i<0) return(-1);
    dim=atoi(word[2]);
    i=varaa_tilat(dim);
    if (i<0) return(-1);

    if (dim%2==0)
    {
        sur_print("\nCurrently only odd dimensions allowed!");
        WAIT;
        return(-1);
    }
    method=1; // Default method for odd dimensions
    spec=1;
    offs=dim>>1;
    magic=0;
    i=spfind("METHOD");
    if (i>=0) {
        method=atoi(spb[i]);
    }

    i=spfind("OFFSET");
    if (i>=0) {
        offs=atoi(spb[i])-1;
    }
    if (offs<0 || offs>=(dim*dim))
    {
        if (strcmp(spb[i],"ALL")==0) offs=-1;
        else
        {
            sprintf(sbuf,"\nERROR! OFFSET must be between 1 and %d!",dim*dim);
            sur_print(sbuf);
            WAIT;
            return(-1);
        }
    }

    raja=offs+1;
    if (offs<0)  // ALL
    {
        raja=dim*dim;
        offs=0;
    }
    for (j=offs; j<raja; j++)
    {
        tyhjenna(dim);

        switch(method)
        {
        case 0:
            i=magic_random(dim);
            break;
        case 1:
            i=magic_staircase(dim);
            break;
        case 2:
            i=magic_pyramid(dim);
            break;
        case 3:
            i=magic_variation_staircase(dim);
            break;
        case 4:
            i=spfind("MOVE");
            if (i>=0) {
                spec=atoi(spb[i]);
            }
            if (spec<1 || spec>8)
            {
                sur_print("\nERROR! Knight's move should be:");
                sur_print("\n1 - 2 up, 1 right     5 - 2 down, 1 left");
                sur_print("\n2 - 1 up, 2 right     6 - 1 down, 2 left");
                sur_print("\n3 - 2 right, 1 down   7 - 2 left, 1 up");
                sur_print("\n4 - 1 right, 2 down   8 - 1 left, 2 up");
                sur_print("\nUse specification MOVE to define the move.");
                WAIT;
                return(-1);
            }
            i=magic_knights_move(dim,j,spec);
            break;
        default:
            break;
        }
        i=is_magic(dim);
        if (i<0)
        {
            if (method==0) print_square(dim);

            /*
            			sprintf(sbuf,"Non magic! Offset=%d",j+1); print_line();
            			print_square(dim);

            			if (i<99) sprintf(sbuf,"Wrong sum(s) in diagonal(s)!"); print_line();
            			if (i<9) sprintf(sbuf,"Wrong sum(s) in column(s)!"); print_line();
            			sprintf(sbuf,"Wrong sum(s) in row(s)!"); print_line();
            */
        }
        else
        {
            magic++;
            print_square_info(dim,j+1);
            print_square(dim);
            sprintf(sbuf,"                                     ");
            print_line();
        }
    }
    if (magic<1)
    {
        sprintf(sbuf,"Non magic!                                         ");
        print_line();
    }
    s_end(argv);
    return(1);
}
Exemple #13
0
/** Funcao que imprime o tabuleiro*/
void print_board(){
	int x,y;
	for(y=0;y<SIZE;y++)
		for(x=0; x<SIZE;x++)
			print_square(x,y,TAM);
}