Ejemplo n.º 1
0
int			launch_game(char **_tab, int r, t_cursor *cursor)
{
  struct termios	t;
  char			buff[1024];
  int			played;

  played = 0;
  cursor_init(cursor);
  aff_tab(_tab, cursor);
  while (42)
    {
      if (played == 1)
        {
          end_game(_tab, cursor, "IA");
          ia_turn(_tab, r);
          aff_tab(_tab, cursor);
          end_game(_tab, cursor, "Player");
        }
      init_read(&t);
      read(0, buff, 1024);
      played = move_cursor(cursor, r, buff, _tab);
      aff_tab(_tab, cursor);
    }
  return (0);
}
Ejemplo n.º 2
0
void		aff_opt_1(void)
{
      int	*tab;

      tab = create_tab(n);
      fill_tab(&tab);
      printf("\n%s - Tableau Initial :\n%s\t", COLOR, NONE);
      aff_tab(tab);
      printf("%s - Tri rapide :\n%s\t", COLOR, NONE);
      aff_tab(quicksort(tab, 0, n));
      printf("\n");
      free(tab);

      tab = create_tab(n);
      fill_tab(&tab);
      printf("%s - Tableau Initial :\n%s\t", COLOR, NONE);
      aff_tab(tab);
      printf("%s - Tri par fusion :\n%s\t", COLOR, NONE);
      aff_tab(fusionsort(tab, 0, n));
      printf("\n");
      free(tab);

      tab = create_tab(n);
      fill_tab(&tab);
      printf("%s - Tableau Initial :\n%s\t", COLOR, NONE);
      aff_tab(tab);
      printf("%s - Tri bulle :\n%s\t", COLOR, NONE);
      aff_tab(bubble_sort(tab));
      printf("\n");
      free(tab);

      tab = create_tab(n);
      fill_tab(&tab);
      printf("%s - Tableau Initial :\n%s\t", COLOR, NONE);
      aff_tab(tab);
      printf("%s - Tri selection :\n%s\t", COLOR, NONE);
      aff_tab(selectionsort(tab));
      printf("\n");
      free(tab);

      tab = create_tab(n);
      fill_tab(&tab);
      printf("%s - Tableau Initial :\n%s\t", COLOR, NONE);
      aff_tab(tab);
      printf("%s - Tri insertion :\n%s\t", COLOR, NONE);
      aff_tab(insertionsort(tab));
      printf("\n");
      free(tab);
}
Ejemplo n.º 3
0
void	ft_match(t_tab *obj, int i)
{
	int			count;

	count = 0;
	while (aff_tab(glob_obj(0)->tab), !obj->end && count < ft_mult(obj))
	{
		if (!is_win(obj))
		{
			if (!obj->player)
			{
				ft_putendl("YOUR TURN");
				i = real_player(obj);
			}
			else
			{
				ft_putendl("COMPUTER TURN");
				i = ia_turn(glob_obj(0)->tab);
			}
			if (check_col(i) == 0)
			{
				ins_col(i);
				obj->count_max--;
			}
		}
		else
			break ;
	}
}
Ejemplo n.º 4
0
int		main(int ac, char **av)
{
  char		**tab = malloc(sizeof(char *) * ac);
  int		i = 1;
  int		j = 0;

  if (ac < 2)
    {
      my_putstr("\n");
      return 0;
    }
  if (av[1] == NULL)
    {
      my_putstr("\n");
      return 0;
    }
  while (i < ac)
    {
      if (av[i] != NULL)
	tab[j] = strdup(av[i]);
      j++;
      ++i;
    }
  tab[i] = NULL;
  qsort(&tab[0], tab_len(tab), sizeof(char *), cmpstringp);
  tab = sort_tab(tab);
  aff_tab(tab);
  my_putstr("\n");
  return 0;
}
Ejemplo n.º 5
0
void	aff_list(t_l *list)
{
	if (list == NULL)
		return ;
	else
	{
		aff_tab(list->array);
		aff_list(list->next);
	}
}
Ejemplo n.º 6
0
void	move(int player, char **board, t_pow *power, int x)
{
  int	y;
  char	*line;

  y = 0;
  while (board[y+1][x] == ' ')
    y++;
  line = board[y];
  if (player == 1)
    line[x] = power->p1;
  else
    line[x] = power->p2;
  aff_tab(board);
}
Ejemplo n.º 7
0
int		main(int ac, char **av)
{
  if (ac < 2 || av[1][0] == 0)
    return (my_putchar('\n'));
  int		r;
  int		fd;
  char		buff[5001];
  char		**tab;

  if ((fd = open(av[1], O_RDONLY)) == -1)
    return (my_putchar('\n'));
  if ((r = read(fd, buff, 5000)) == -1 || r == 0)
    {
      printf("Read fail\n");
      return (my_putchar('\n'));
    }
  buff[r] = 0;

  int		x = 0;
  int		y = 0;
  r = 0;
  tab = malloc (1000 * sizeof (char *));
  tab[0] = malloc (1024);
  while (buff[r])
    {
      if (buff[r] == '\n')
	{
	  tab[y][x] = 0;
	  y++;
	  tab[y] = malloc(1024);
	  x = 0;
	  r++;
	}
      tab[y][x] = buff[r];
      x++;
      r++;
    }
  tab[y] = 0;
  count_island(tab);
  aff_tab(tab);
}
Ejemplo n.º 8
0
int		cmd_pbc(char **params, t_client *cl)
{
    t_player	*temp;
    int		p_id;

    aff_tab(params);
    if (tablen(params) < 3)
        return (0);
    temp = cl->plist;
    p_id = atoi(params[1]);
    while (temp)
    {
        if (temp->id == p_id)
        {
            temp->action = ACT_BRD;
            temp->message = params[2];
        }
        temp = temp->next;
    }
    aff_player(cl, p_id);
    return (0);
}
Ejemplo n.º 9
0
int		my_env(t_shell *sh)
{
  aff_tab(sh->env);
  return (0);
}