Exemplo n.º 1
0
/**
* second play is tested over first play
* the second play adds 3 words to the board by amending tiles to the existing word to form 3 new words
*\author Abdallah
*/
void test_second_valid3()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	t1 = new_tile('h');
	t2 = new_tile('a');
	t3 = new_tile('s');
	t4 = new_tile ('r');
	t5 = new_tile('e');
	t6 = new_tile('m');
	t7 = new_tile('d');
	
	board_prev[7][7] = &t1;
	board_prev[8][7] = &t2;
	board_prev[9][7] = &t3;

	board[7][7] = &t1;
	board[8][7] = &t2;
	board[9][7] = &t3;

	board[6][8] = &t4;
	board[7][8] = &t5;
	board[8][8] = &t6;
	printf("Board before second play\n");
	display_board (board_prev);

	printf("Board after second play\n");
	display_board (board);

	check_board ( board , board_prev , str , &temp_score );
	printf("Expected value : 21\nR(1)*2 + E(1) + M(3)*2 = 9\nH(4) + E (1) =5 \nA(1) + M(3)*2 = 7\n");
}
Exemplo n.º 2
0
/**
* second play is tested over first play
* the second play adds a word that exists in the dictionary but is nor properly connected
*\author Abdallah
*/
void test_second_invalid2()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	t1 = new_tile('h');
	t2 = new_tile('a');
	t3 = new_tile('s');
	t4 = new_tile ('r');
	t5 = new_tile('e');
	t6 = new_tile('m');
	t7 = new_tile('d');
	
	board_prev[7][7] = &t1;
	board_prev[8][7] = &t2;
	board_prev[9][7] = &t3;

	board[7][7] = &t1;
	board[8][7] = &t2;
	board[9][7] = &t3;

	board[6][1] = &t4;
	board[7][1] = &t5;
	board[8][1] = &t6;
	printf("Board before second play\n");
	display_board (board_prev);

	printf("Board after second play\n");
	display_board (board);

	check_board ( board , board_prev , str , &temp_score );
}
Exemplo n.º 3
0
/**
* nth play where the board is in a valid state that can occur after one or more plays the added tiles are valid and pass by a triple word square
* \author Abdallah
*/
void test_nth_valid3()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	t1 = new_tile('c');
	t2 = new_tile('l');
	t3 = new_tile('a');
	t8 = new_tile('n');
	t4 = new_tile ('o');
	t5 = new_tile('v');
	t6 = new_tile('a');
	t7 = new_tile('l');

	t9 = new_tile('o');
	t10 = new_tile ('n');
	
	board_prev[7][7] = &t1;
	board_prev[7][8] = &t2;
	board_prev[7][9] = &t3;
	board_prev[7][10] = &t8;
	board_prev[6][10] = &t4;
	board_prev[6][11] = &t5;
	board_prev[6][12] = &t6;
	board_prev[6][13] = &t7;
	


	board [7][7] = &t1;
	board [7][8] = &t2;
	board [7][9] = &t3;
	board [7][10] = &t8;
	board [6][10] = &t4;
	board [6][11] = &t5;
	board [6][12] = &t6;
	board [6][13] = &t7;

	board[7][13] = &t9;
	board[7][14] = &t10;

	printf("Board before second play\n");
	display_board (board_prev);

	printf("Board after second play\n");
	display_board (board);

	check_board ( board , board_prev , str , &temp_score );
	printf("Expected added score is 8\nL(1) + O (1) =2 \n( O(1) + N (1) )*3 = 6\n");
}
Exemplo n.º 4
0
/** The added word is valid in term of position (vertically) and exists in the dictionary
*\author Abdallah
*/
void test_vertical_valid ()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	bag real_bag, inhand_bag;
	tile t1,t2, t3, t4;// tiles to be used for testing purposesone for the real bag and the other for hand
	real_bag = new_real_bag();//initializing the real bag
	inhand_bag = new_inhand_bag(&real_bag);// initializing the 7 tiles in posession of the player from the real bag
	


	//Testing horizontal "to"
	t1 = new_tile('l');
	t2 = new_tile('o');
	t3 = new_tile('s');
	t4 = new_tile ('e');
	board[7][7] = &t1;
	board[8][7] = &t2;
	board[9][7] = &t3;

	board[10][7] = &t4;
	display_board(board);
	display_bag (inhand_bag);

	char new_word [word_len];
	check_board ( board , board_prev , str , & temp_score);
	printf("The word added to the board is %s\n",str [0] );
}
Exemplo n.º 5
0
int main(int i, char **c)
{
	char buffer[64];

	brd_desc = get_board_desc();

	/* Check for double baud rate */
	if(brd_desc != NULL) {
		if(CSR_GPIO_IN & GPIO_DIP2)
			CSR_UART_DIVISOR = brd_desc->clk_frequency/230400/16;
	}

	/* Display a banner as soon as possible to show that the system is alive */
	putsnonl(banner);
	
	crcbios();
	display_board();
	display_capabilities();
	
	boot_sequence();

	splash_showerr();
	while(1) {
		putsnonl("\e[1mBIOS>\e[0m ");
		readstr(buffer, 64);
		do_command(buffer);
	}
	return 0;
}
Exemplo n.º 6
0
static void board_resized(void)
{
	GtkWidget *widget = g_object_get_data(G_OBJECT(main_win),
					      "drawingarea");
	int w = widget->allocation.width, h = widget->allocation.height;

	if (rvr_buf) {
		g_object_unref(rvr_buf);
		g_object_unref(blackpiece);
		g_object_unref(whitepiece);
		g_object_unref(mydot);
		g_object_unref(enemydot);
	}

	gtk_widget_realize(widget);
	rvr_buf = gdk_pixmap_new(widget->window, w, h, -1);
	gdk_draw_rectangle(rvr_buf, widget->style->black_gc, TRUE,
			   0, 0, w, h);

	PIXSIZE = MIN(w, h) / 8;

	/* Create the white piece, black piece, and dot images. */
	blackpiece = load_pixmap("black");
	whitepiece = load_pixmap("white");
	mydot = load_pixmap("dot");
	enemydot = load_pixmap("enemydot");

	draw_bg(widget);
	display_board();
}
Exemplo n.º 7
0
/**
* A word placed but not passing by the central square
* \author Abdallah
*/
void test_invalid4()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	bag real_bag, inhand_bag;
	tile t1,t2, t3, t4;// tiles to be used for testing purposesone for the real bag and the other for hand
	real_bag = new_real_bag();//initializing the real bag
	inhand_bag = new_inhand_bag(&real_bag);// initializing the 7 tiles in posession of the player from the real bag
	
	t1 = new_tile('g');
	t2 = new_tile('o');
	t3 = new_tile('o');
	t4 = new_tile ('d');
	
	board[7][8] = &t1;
	board[7][9] = &t2;
	board[7][10] = &t3;
	board[7][11] = &t4;
	display_board(board);
	display_bag (inhand_bag);

	char new_word [word_len];
	check_board ( board , board_prev , str , & temp_score);
printf("Invalid placement \n");
}
Exemplo n.º 8
0
//move by player
void player_play()
{
    int row,col,ck=1;
    while(ck){
    printf("\n Enter the row no(1..3): ");
    scanf("%d",&row);

    printf("\nEnter the column no(1..3): ");
    scanf("%d",&col);
    if((row<0 || row>3) || (col<0 || col>3))
    {
        printf("\nInvalid Row/Column");

    }
    else if(board[row-1][col-1]=='C' || board[row-1][col-1]=='0')
    {
        printf("\nCell Already Ocuppied.Enter Another Cell address");

    }
    else
    {
        board[row-1][col-1]='0';
        ck=0;
    }
    }
    printf("\nAfter Player Play\n");
    display_board();
}
Exemplo n.º 9
0
int main(void)
{
	brd_t brd[1], chld_brd[1];
	mv_slct_t slct[1];

	init();

	parse_fen(brd,"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
	//"3r4/p6k/4p1rp/1pp1Pp2/2pN3R/4PQ1R/P2K2PP/1q6 b - - 0 1");
	display_board(brd);

	slct->hash_mv = 0;

	printf("sq(28)="SQ_FMT"\n",SQ_ARGS(28));
	/* Move loop. */
#define MV_SLCT_FN(mv) \
		printf("got move: m=%o f="SQ_FMT" t="SQ_FMT" m=%i c=%i p=%i\n", mv,\
				SQ_ARGS(MV_GET_F(mv)), \
				SQ_ARGS(MV_GET_T(mv)),\
				MV_GET_M(mv),\
				MV_GET_C(mv),\
				MV_GET_P(mv));\

#include "mv_slct.c"

#undef MV_SLCT_FN

	int x;
	for (x = 1; x < 5; x++)
		printf("p[%i]=%i\n", x, perft(brd, x));
}
Exemplo n.º 10
0
/** The added word is invalid in term of position (horizontally) but it does not exist in the dictionary
*\author Abdallah
*/
void test_horizontal_invalid ()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	bag real_bag, inhand_bag;
	tile t1,t2, t3, t4;// tiles to be used for testing purposesone for the real bag and the other for hand
	real_bag = new_real_bag();//initializing the real bag
	inhand_bag = new_inhand_bag(&real_bag);// initializing the 7 tiles in posession of the player from the real bag
	


	//Testing horizontal "to"
	t1 = new_tile('t');
	t2 = new_tile('w');
	t3 = new_tile('o');
	t4 = new_tile ('x');
	board[7][7] = &t1;
	board[7][8] = &t2;
	board[7][9] = &t3;

	board[7][6] = &t4;
	display_board(board);
	display_bag (inhand_bag);

	char new_word [word_len];
	check_board ( board , board_prev , str , & temp_score);

}
Exemplo n.º 11
0
/* Requirement 5 - handle the logic for each individual move */
enum move_result player_move(enum cell_contents board[][BOARD_WIDTH])
{
	char input[INPUT_LENGTH];
	struct move move;
	enum move_validity move_validity;

	while (TRUE)
	{
		display_board(board);

		printf("\nPlease enter a move [enter Q or ctrl-D to quit]: ");

		/* quit conditions */
		if (get_input(input) == NULL)
			return QUIT_GAME;
		else if (strlen(input) == 1 && toupper(input[0]) == 'Q')
			return QUIT_GAME;

		move_validity = try_get_move(&move, input, board);
		if (move_validity == VALID)
		{
			perform_move(move, board);
			return SUCCESSFUL_MOVE;
		}
		else
			print_move_validity_string(move_validity);
	}
	return SUCCESSFUL_MOVE;
}
Exemplo n.º 12
0
/* Boucle principale du jeu */
int	game_loop(char board[3][3])
{
  int	win;
  int	turn;
  int	error;
  int	player;
  char	input[64];
  int	insert_nb;

  win = -1;
  turn = 0;
  error = -42;
  while (win == -1)
    {
      player = turn % 2;
      system("clear");
      display_board(board);
      display_error(error);
      printf("Player %d enter the case number where to put an %c : ", player + 1, player == 0 ? 'X' : 'O');
      scanf("%s", input);
      error = check_input(board, input);
      if (error == -42)
	{
	  insert_nb = input[0] - '1';
	  board[insert_nb / 3][insert_nb % 3] = player;
	  win = check_winner(board, player);
	  if (win >= 0)
	    return (player);
	  else if (turn >= 8)
	    return (2);
	  turn++;
	}
    }
  return (0);
}
Exemplo n.º 13
0
int main(void) {
   char board[9];
   char player = who_plays_first(); //funkcja losuje kto gra pierwszy
   char move;

   system("cls");
   fill_in_board(board); //wypelniamy tablice liczbami od 1 do 9
   do {
      if(player == 'x') {
         player = 'o'; //zmieniamy gracz
         display_board(board);
         do {
            move = read_move(player); //odczytujemy ruch gracza
         } while(!check_move_possibility(move, board));
      } else {
         player = 'x'; //zmieniamy gracza
         move = computer_move(board, player);
         system("cls");
         printf("Komputer wybral %d.\n\n", move + 1);
      }

      save_move(move, player, board);
   } while(!is_it_end(board)); //powtarzamy az do konca gry

   print_result(board, player);
   play_again();

   return 0;
}
Exemplo n.º 14
0
/**
* nth play where the board is in a valid state that can occur after one or more plays the added tiles are valid and pass by a double word square
* \author Abdallah
*/
void test_nth_valid2()
{
	
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	t1 = new_tile('c');
	t2 = new_tile('l');
	t3 = new_tile('a');
	t8 = new_tile('n');
	t4 = new_tile ('n');
	t5 = new_tile('o');
	t6 = new_tile('n');
	t7 = new_tile('e');
	
	board_prev[7][7] = &t1;
	board_prev[7][8] = &t2;
	board_prev[7][9] = &t3;
	board_prev[7][10] = &t8;
	board_prev[8][10] = &t5;
	board_prev[9][10] = &t6;
	


	board [7][7] = &t1;
	board [7][8] = &t2;
	board [7][9] = &t3;
	board [7][10] = &t8;
	board[8][10] = &t5;
	board[9][10] = &t6;
	

	board[10][10] = &t7;

	printf("Board before second play\n");
	display_board (board_prev);

	printf("Board after second play\n");
	display_board (board);

	check_board ( board , board_prev , str , &temp_score );
	printf("Expected added score is 8\n");
}
Exemplo n.º 15
0
void test_second_valid ()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	t1 = new_tile('f');
	t2 = new_tile('i');
	t3 = new_tile('l');
	t4 = new_tile ('l');
	t5 = new_tile('e');
	t6 = new_tile('d');
	t7 = new_tile('y');
	t8 = new_tile ('s');
	t9 = new_tile('t');
	t10 = new_tile('a');
	t11= new_tile('l');
	t12= new_tile ('l');
	t13= new_tile ('i');
	t14= new_tile ('n');
	t15= new_tile ('e');
	board_prev[7][7] = &t1;
	board_prev[7][8] = &t2;
	board_prev[7][9] = &t3;
	board_prev[7][10] = &t4;

	board[7][7] = &t1;
	board[7][8] = &t2;
	board[7][9] = &t3;
	board[7][10] = &t4;

	board[7][11] = &t5;
	board[7][12] = &t6;
	printf("Board before second play\n");
	display_board (board_prev);

	printf("Board after second play\n");
	display_board (board);

	check_board ( board , board_prev , str , &temp_score );
	printf("Expected added value : 11\nF(4) + I(1) + L (1) + L (1) +E (1)*2 + D (2) \n");
	temp_score = 0;

}
Exemplo n.º 16
0
int main()
{
   int board[BOARD_SIZE_HORIZ][BOARD_SIZE_VERT] = { {0} };
   int player_num, computer_num;
   int last_move; 


   /* Ask Alice if she wants to go first */
   player_num = print_welcome();
   if (player_num == 1) computer_num = 2;
   else computer_num = 1;

   /* If Alice wants to go first, let her make a move */
   if (player_num == 1)
   {
      display_board(board);
      last_move = player_move(board,player_num);
      display_board(board);
   }


   /* The main loop */
   
   while (1)
   {
      /* Make a computer move, then display the board */
      last_move = random_move(board,computer_num);
      printf("Computer moved in column: %d\n", last_move);
      display_board(board);

      /* Check whether the computer has won */
      if (check_win_or_tie(board,last_move)) return 0;


      /* Let Alice make a move, then display the board */
      last_move = player_move(board,player_num);
      display_board(board);

      /* Check whether Alice has won */
      if (check_win_or_tie(board,last_move)) return 0;


   } /* end of while (1) */

} /* end of main() */
Exemplo n.º 17
0
void print_result(char board[9], char player) {
   system("cls");
   display_board(board);

   if(did_somebody_win(board))
      printf("\n\nWygrywa gracz %c!", player);
   else
      printf("Remis!");
}
Exemplo n.º 18
0
Arquivo: game.c Projeto: martigan/Alcu
int			ai_turn(t_data *powf)
{
	ft_putstr(AI_TXT);
	if (ai_game(powf) == 0)
		return (0);
	display_board(powf);
	powf->current = powf->current == P1 ? AI : P1;
	powf->turn--;
	return (1);
}
Exemplo n.º 19
0
Arquivo: game.c Projeto: martigan/Alcu
int			ai_turn_drunk(t_data *powf)
{
	ft_putstr(DRUNK);
	while (!insert_piece(rand() % powf->col, powf->current, powf))
		;
	display_board(powf);
	powf->current = powf->current == P1 ? AI : P1;
	powf->turn--;
	return (1);
}
Exemplo n.º 20
0
int main()
{
// the first local variables
   int counter = 0;
   bool winner = false;
   
   srand(GetTickCount());   //sets randomizer as time *unique*
   // get TickCount returns a semi random number for feeding into the srand function

   cout << "Please select a number from 1-7" << endl;
   cout << "| 1| 2| 3| 4| 5| 6| 7" << endl;
   cout << "_____________________";
   
   // even through function hasn't been described in the code, the compiler knows to look further down here (possibly looking for angle brackets) 
   display_board();

   // MAIN GAME LOOP
   // 42 spaces (6 by 7 array), divded by 2 players == maximumm no. of rounds
   for (int i = 0; i < 21; i++)
   {
      player_movement(1);
      display_board();
      winner = check_for_winner(LastMoveX, LastMoveY, 1);
      if (winner)
      {
         cout << "\nYou Win" << endl;
         break;
      }
   
      player_movement(2);
      display_board();
      winner = check_for_winner(LastMoveX, LastMoveY, 2);
      if (winner)
      {
         cout << "\nYou Win" << endl;
         break;
      }   
   }
   
   system("PAUSE");
   return 0;
}
Exemplo n.º 21
0
/**
* second play is tested over first play
* the second play adds 4 words to the board by amending tiles to the existing word to form 4 new words
* this give me a huge error but from the analysis I can assume it is from the part when the the char is changed to int and vice versa because if the tenth is changed from 1 to 0 the answer would be correct
*\author Abdallah
*/
void test_second_valid4()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	t1 = new_tile('h');
	t2 = new_tile('a');
	t3 = new_tile('i');
	t8 = new_tile('r');
	t4 = new_tile ('r');
	t5 = new_tile('e');
	t6 = new_tile('m');
	t7 = new_tile('s');
	
	board_prev[7][7] = &t1;
	board_prev[7][8] = &t2;
	board_prev[7][9] = &t3;
	board_prev[7][10] = &t8;


	board [7][7] = &t1;
	board [7][8] = &t2;
	board [7][9] = &t3;
	board [7][10] = &t8;

	board[8][6] = &t4;
	board[8][7] = &t5;
	board[8][8] = &t6;
	board[8][9] = &t7;

	printf("Board before second play\n");
	display_board (board_prev);

	printf("Board after second play\n");
	display_board (board);

	check_board ( board , board_prev , str , &temp_score );
	printf("Expected value is 10 + 5 + 7 + 2 = 24 \n");
}
Exemplo n.º 22
0
//starting of tic tac toe
void play_tic_tac_toe()
{
    int won=0;
    int i;
    for(i=0;i<9;i++)
    {
        //printf("%d",i);
        if(i%2==0)
        {
            if(i==0)
            {
                int row=rand()%3;
                int col=rand()%3;
                board[row][col]='C';
            }
            else{
            //printf("!!!!");
            bot_play();}
            printf("\nAfter Bot Play\n");
            display_board();
        }
        else
        {
            player_play();

        }
        won=check_if_win();
        //printf("\n\n %d %c\n\n",won,win_char);
        if(won==1)
        {
            if(win_char=='0')
            {
                printf("\nPlayer Win!!!");
                return;
            }
            else if(win_char=='C')
            {
                printf("\nBot Wins\nYou Loose!");
                return;
            }
        }

    }
    if(i==9)
    {
        printf("\nMATCH DRAW");
    }

}
Exemplo n.º 23
0
/** The added word is valid in term of position (horizontally) exists in the dictionary
*\author Abdallah
*/
void test_horizontal_valid ()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	bag real_bag, inhand_bag;
	tile t1,t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
	real_bag = new_real_bag();//initializing the real bag
	inhand_bag = new_inhand_bag(&real_bag);// initializing the 7 tiles in posession of the player from the real bag
    //tested word:holocrystalline, longest possible (15 letters)
	t1 = new_tile('h');
	t2 = new_tile('o');
	t3 = new_tile('l');
	t4 = new_tile ('o');
	t5 = new_tile('c');
	t6 = new_tile('r');
	t7 = new_tile('y');
	t8 = new_tile ('s');
	t9 = new_tile('t');
	t10 = new_tile('a');
	t11= new_tile('l');
	t12= new_tile ('l');
	t13= new_tile ('i');
	t14= new_tile ('n');
	t15= new_tile ('e');
	board[7][0] = &t1;
	board[7][1] = &t2;
	board[7][2] = &t3;
	board[7][3] = &t4;
	board[7][4] = &t5;
	board[7][5] = &t6;
	board[7][6] = &t7;
	board[7][7] = &t8;
	board[7][8] = &t9;
	board[7][9] = &t10;
	board[7][10] = &t11;
	board[7][11] = &t12;
	board[7][12] = &t13;
	board[7][13] = &t14;
	board[7][14] = &t15;
	display_board(board);
	display_bag (inhand_bag);

	char new_word [word_len];
	check_board ( board , board_prev , str , & temp_score );
	printf("The word added to the board is %s\n",str [0] );

}
Exemplo n.º 24
0
void update_options(GtkButton * button, gpointer user_data)
{
	GtkWidget *last = lookup_widget(user_data, "last_button");
	GtkWidget *back = lookup_widget(user_data, "back_button");

	back_color = g_object_get_data(G_OBJECT(back), "color");
	last_color = g_object_get_data(G_OBJECT(last), "color");
	g_object_set_data(G_OBJECT(main_win), "last_color", last_color);
	g_object_set_data(G_OBJECT(main_win), "back_color", back_color);
	gdk_gc_set_foreground(bg_gc, back_color);
	gdk_gc_set_foreground(last_gc, last_color);

	display_board();

}
Exemplo n.º 25
0
/* Fonction principale qui fait appel au reste et gère l'affichage de fin */
int	main()
{
  char	board[3][3];
  int	win;

  init_board(board);
  win = game_loop(board);
  system("clear");
  display_board(board);
  if (win == 0 || win == 1)
    printf("Player %d won!\n", win + 1);
  else if (win == 2)
    printf("Draw! No winner this time :'(\n");
  return (0);
}
Exemplo n.º 26
0
/** The player tries to play the first turn without adding any tiles, a warning message is displayed to ask him to add a tile passing through the center
*\author Abdallah
*/
void test_empty()
{
	tile * board [max_rc] [max_rc];
	new_board(board);
	tile * board_prev [max_rc] [max_rc];
	new_board (board_prev);
	bag real_bag, inhand_bag;
	real_bag = new_real_bag();//initializing the real bag
	inhand_bag = new_inhand_bag(&real_bag);// initializing the 7 tiles in posession of the player from the real bag
	display_board(board);
	display_bag (inhand_bag);

	char new_word [word_len];
	check_board ( board , board_prev , str , & temp_score);
	printf("Invalid placement; no tiles \n");
}
Exemplo n.º 27
0
void display_result(enum cell_contents board[][BOARD_WIDTH])
{
	int peg_count = get_peg_count(board);

	display_board(board);
	printf("\n");

	if (peg_count == 1)
	{
		if (board[BOARD_HEIGHT / 2][BOARD_WIDTH / 2] == PEG)
			printf("You finished the puzzle with a single peg left in the centre hole!");
		else
			printf("You finished the puzzle with a single peg left.");
	}
	else
		printf("There are no more moves with %d pegs left.", peg_count);
}
void run_autotest(char *testset)
{
	FILE *testsuite;
	char readbuff[STR_BUFF];
        int searchdepth;
	rtime_t start, end;
	
	move_s comp_move;

	testsuite = fopen(testset, "r");

	if (testsuite == NULL) exit(EXIT_FAILURE);

	start = rtime();
	
	while (fgets(readbuff, STR_BUFF, testsuite) != NULL)
 	{
		setup_epd_line(readbuff);
                root_to_move = ToMove;
					        
		clear_tt();
		initialize_hash();
		           
		printf("\n");
		display_board(stdout, 1);

		printf("EPD: %s\n", readbuff);

		if (fgets(readbuff, STR_BUFF, testsuite) == NULL) exit(EXIT_FAILURE);
		searchdepth = atoi(readbuff);
		
		printf("Searching to %d ply\n", searchdepth);
		maxdepth = searchdepth;

		fixed_time = INF;
		comp_move = think();
	}
		
	end = rtime();
/*        printf("Total elapsed: %i.%02i seconds\n", rdifftime(end, start)/100,
			                           rdifftime(end, start)%100);
*/
	fclose(testsuite);
	exit(EXIT_SUCCESS);
}
Exemplo n.º 29
0
Arquivo: main.c Projeto: Wobow/Tek1
int		main(int ac, char **av)
{
  t_a		*t;

  t = xmalloc(sizeof(*t));
  t->nb_line = NB_LINE;
  t->nb_col = NB_COL;
  t->turn = 1;
  t->board = my_strdup("   |     |||   ||||| |||||||");
  t->head = xmalloc(sizeof(*t->head));
  init_tc(t);
  if (init_board(t))
    return (my_putstr(BOR_ERR));
  display_board(t);
  t->term.c_lflag |= ECHO;
  t->term.c_lflag |= ICANON;
  xtcset(t);
  return (0);
}
Exemplo n.º 30
0
Arquivo: game.c Projeto: martigan/Alcu
int			player_turn(t_data *powf)
{
	int		read_size;
	char	buff[4096];

	ft_putstr(PROMPT);
	if ((read_size = xread(0, buff, 4096)) == -1)
		return (0);
	if (read_size == 1)
		return (1);
	buff[read_size - 1] = '\0';
	if (insert_piece(ft_atoi(buff) - 1, powf->current, powf) == 1)
	{
		display_board(powf);
		powf->current = powf->current == P1 ? AI : P1;
		powf->turn--;
	}
	return (1);
}