예제 #1
0
int handle_knowledge_book(void)
{
	open_book(knowledge_book_id + 10000);
	// Bring the new window to the front               <----- Doesn't work. Is in front for the first usage, but not after that
	select_window(book_win);
	return 1;
}
예제 #2
0
파일: main.c 프로젝트: johnwbyrd/superpawn
void bench()
{
	int i;
	int t[3];
	double nps;

	/* setting the position to a non-initial position confuses the opening
	   book code. */
	close_book();

	for (i = 0; i < 64; ++i) {
		color[i] = bench_color[i];
		piece[i] = bench_piece[i];
	}
	side = LIGHT;
	xside = DARK;
	castle = 0;
	ep = -1;
	fifty = 0;
	ply = 0;
	hply = 0;
	set_hash();
	print_board();
	max_time = 1 << 25;
	max_depth = 5;
	for (i = 0; i < 3; ++i) {
		think(1);
		t[i] = get_ms() - start_time;
		printf("Time: %d ms\n", t[i]);
	}
	if (t[1] < t[0])
		t[0] = t[1];
	if (t[2] < t[0])
		t[0] = t[2];
	printf("\n");
	printf("Nodes: %d\n", nodes);
	printf("Best time: %d ms\n", t[0]);
	if (!ftime_ok) {
		printf("\n");
		printf("Your compiler's ftime() function is apparently only accurate\n");
		printf("to the second. Please change the get_ms() function in main.c\n");
		printf("to make it more accurate.\n");
		printf("\n");
		return;
	}
	if (t[0] == 0) {
		printf("(invalid)\n");
		return;
	}
	nps = (double)nodes / (double)t[0];
	nps *= 1000.0;

	/* Score: 1.000 = my Athlon XP 2000+ */
	printf("Nodes per second: %d (Score: %.3f)\n", (int)nps, (float)nps/243169.0);

	init_board();
	open_book();
	gen();
}
예제 #3
0
int main(int argc, char *argv[])
{

	g_type_init();
	if (argc < 2)
		usage(argv[0], 1);
	if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
		usage(argv[0], 0);
		    
	if (argc <3)
		usage(argv[0], 1);
	if (!strcmp(argv[1], "--contact")) {
		open_book(argv[2]);
	} else if (!strcmp(argv[1], "--event")) {
		open_calendar(argv[2], E_CAL_SOURCE_TYPE_EVENT);
	} else if (!strcmp(argv[1], "--todo")) {
		open_calendar(argv[2], E_CAL_SOURCE_TYPE_TODO);
	} else if (!strcmp(argv[1], "--note")) {
		open_calendar(argv[2], E_CAL_SOURCE_TYPE_JOURNAL);
	} else {
		usage(argv[0], 1);
	}
	return 0;
}
예제 #4
0
파일: main.c 프로젝트: johnwbyrd/superpawn
int main()
{
	int computer_side;
	char s[256];
	int m;

	printf("\n");
	printf("Tom Kerrigan's Simple Chess Program (TSCP)\n");
	printf("version 1.81, 2/5/03\n");
	printf("Copyright 1997 Tom Kerrigan\n");
	printf("\n");
	printf("\"help\" displays a list of commands.\n");
	printf("\n");
	init_hash();
	init_board();
	open_book();
	gen();
	computer_side = EMPTY;
	max_time = 1 << 25;
	max_depth = 4;
	for (;;) {
		if (side == computer_side) {  /* computer's turn */
			
			/* think about the move and make it */
			think(1);
			if (!pv[0][0].u) {
				printf("(no legal moves)\n");
				computer_side = EMPTY;
				continue;
			}
			printf("Computer's move: %s\n", move_str(pv[0][0].b));
			makemove(pv[0][0].b);
			ply = 0;
			gen();
			print_result();
			continue;
		}

		/* get user input */
		printf("tscp> ");
		if (scanf("%s", s) == EOF)
			return 0;
		if (!strcmp(s, "on")) {
			computer_side = side;
			continue;
		}
		if (!strcmp(s, "off")) {
			computer_side = EMPTY;
			continue;
		}
		if (!strcmp(s, "st")) {
			scanf("%d", &max_time);
			max_time *= 1000;
			max_depth = 32;
			continue;
		}
		if (!strcmp(s, "sd")) {
			scanf("%d", &max_depth);
			max_time = 1 << 25;
			continue;
		}
		if (!strcmp(s, "undo")) {
			if (!hply)
				continue;
			computer_side = EMPTY;
			takeback();
			ply = 0;
			gen();
			continue;
		}
		if (!strcmp(s, "new")) {
			computer_side = EMPTY;
			init_board();
			gen();
			continue;
		}
		if (!strcmp(s, "d")) {
			print_board();
			continue;
		}
		if (!strcmp(s, "bench")) {
			computer_side = EMPTY;
			bench();
			continue;
		}
		if (!strcmp(s, "bye")) {
			printf("Share and enjoy!\n");
			break;
		}
		if (!strcmp(s, "xboard")) {
			xboard();
			break;
		}
		if (!strcmp(s, "help")) {
			printf("on - computer plays for the side to move\n");
			printf("off - computer stops playing\n");
			printf("st n - search for n seconds per move\n");
			printf("sd n - search n ply per move\n");
			printf("undo - takes back a move\n");
			printf("new - starts a new game\n");
			printf("d - display the board\n");
			printf("bench - run the built-in benchmark\n");
			printf("bye - exit the program\n");
			printf("xboard - switch to XBoard mode\n");
			printf("Enter moves in coordinate notation, e.g., e2e4, e7e8Q\n");
			continue;
		}

		/* maybe the user entered a move? */
		m = parse_move(s);
		if (m == -1 || !makemove(gen_dat[m].m.b))
			printf("Illegal move.\n");
		else {
			ply = 0;
			gen();
			print_result();
		}
	}
	close_book();
	return 0;
}
예제 #5
0
파일: main.c 프로젝트: odrevet/Chess-Wii
int main(int argc, char **argv) {

  GRRLIB_Init();	
	
  // Initialise the attached controllers
  WPAD_Init();
  WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
  // Initialise the audio subsystem
  AESND_Init(NULL);
	
  MODPlay_Init(&play);
  MODPlay_SetMOD(&play,bg_music);
  MODPlay_SetVolume(&play,63,63);
  MODPlay_Start(&play);

  cui_cursor cursor;
  cursor.tex[0]=GRRLIB_LoadTexture(player1_point_png);
  cursor.tex[1]=GRRLIB_LoadTexture(player1_grab_png);
  cursor.is_grabbing=false; 
	
  cui_board board;
	
  ENGINE engine = FIRSTCHESS;
  if(engine == TSCP){
    int i;
    for (i=0; i < CUI_TILE_NB; i++) {
      board.piece[i]=init_piece[i];
      if(init_color[i] == 1){
	board.color[i]=CUI_BLACK;
      }else if (init_color[i] == 6){
	board.color[i]=CUI_EMPTY;
      }else if (init_color[i] == 0){
	board.color[i]=CUI_WHITE;
      }
    }
			
    init_hash();
    init_board();
    open_book();
    gen();
  }


  cui_board_read_core(&board, engine);

  GRRLIB_SetBackgroundColour(0x030, 0x30, 0x42, 0xFF);
	
  board.tile_color1 = 0xAAAAAAFF;
  board.tile_color2 = 0x444444FF;
  board.piece_color1 = 0xAAAAAAFF;
  board.piece_color2 = 0x444444FF;
	
  cui_board_init(&board);

  cui_game game;
  game.board = &board;
  game.engine = engine; 
  game.cursor = &cursor;
  game.is_mute = false;
  GRRLIB_texImg *tex_wallpaper = GRRLIB_LoadTexture(wall_jpg);
  game.tex_wallpaper = tex_wallpaper;
			
	
  voice = AESND_AllocateVoice(aesnd_callback);
  AESND_SetVoiceVolume(voice, 0xFF, 0xFF);
  AESND_SetVoiceStream(voice, true);

  cui_menu current_state = CUI_MENU_MAIN;
	 
  while(current_state != CUI_MENU_EXIT) {
    switch(current_state){
    case CUI_MENU_MAIN:	current_state=menu_main(&game);break;
    case CUI_MENU_PLAY:	current_state=menu_play(&game);break;
    case CUI_MENU_OPTION:current_state=menu_option(&game);break;
    case CUI_MENU_OPTION_GENERAL:current_state=menu_option_general(&game);break;
    case CUI_MENU_OPTION_GFX:current_state=menu_option_gfx(&game);break;
    case CUI_MENU_OPTION_SND:current_state=menu_option_snd(&game);break;
    case CUI_MENU_CREDITS:current_state=menu_credits(&game);break;
    case CUI_MENU_PAUSE:current_state=menu_pause(&game);break;
    case CUI_MENU_HOME:current_state=menu_home(&game);break;
    case CUI_MENU_EXIT:current_state=menu_exit(&game);break;
    default:break;
    }
  }
	
  GRRLIB_FreeTexture(tex_wallpaper);
  GRRLIB_FreeTexture(cursor.tex[0]);
  GRRLIB_FreeTexture(cursor.tex[1]);
  GRRLIB_Exit();
  return 0;
}