void train_network(int num) { int i, h, o; unsigned int n; for(n = 0; n < num; n++) { init_pattern(); calculate_network(); calculate_errors(); for(h=0; h < NUM_HIDDEN; h++) for(o=0; o < NUM_OUTPUT; o++) W_HIDDEN_OUT(h, o) += (((learn * N_HIDDEN(h)) / 1024) * E_OUT(o)) / 1024; for(i=0; i < NUM_INPUT; i++) for(h=0; h < NUM_HIDDEN; h++) W_IN_HIDDEN(i, h) += (((learn * N_IN(i)) / 1024) * E_HIDDEN(h)) / 1024; } return; }
/* --------------------------------------------------------------------------------------- * *---------------------------------------------------------------------------------------- */ int initialize_dpin_0007( uchar * buf, uint test_area_start, uint test_area_length ) { int ret = 0; uint scts_per_chunk_arr[7] = {8, 16, 32, 64, 128, 256, 512}; // 1 2 4 8 16 32 64 uint test_sectors_in_zone = 0; struct Pattern_Function pattern_linker; init_case_info(test_area_start, test_area_length); set_chunk_info(scts_per_chunk_arr, 7); test_sectors_in_zone = get_sectors_in_zone() - NUM_OF_SECTORS_PER_PAGE; set_test_sectors_in_zone(test_sectors_in_zone); /* * NOTE ************************************************************************************* * 포팅을 위한 임시 코드. * ****************************************************************************************** */ init_pattern(&g_plr_state, FALSE); /* * NOTE ************************************************************************************* * 사용자는 initialize level 에서 register pattern을 호출해야 한다. * ****************************************************************************************** */ memset(&pattern_linker, 0, sizeof(struct Pattern_Function)); pattern_linker.do_pattern_1 = pattern1_interleaving; pattern_linker.do_pattern_2 = pattern2_sequential; pattern_linker.init_pattern_1 = init_pattern_1_2; pattern_linker.init_pattern_2 = init_pattern_1_2; pattern_linker.do_extra_verification = extra_verification; regist_pattern(pattern_linker); /* * NOTE ************************************************************************************* * 포팅을 위한 임시 코드. * ****************************************************************************************** */ ret = check_pattern_func(); if(ret) return ret; return ret; }
int pattern_5 (int chess_ax, int chess_ay, int locate, int chess_flag) //寻找 类型五的点及其返回值 { init_pattern(chess_ax,chess_ay,locate); int flag_pa5 = 0; if( search_pattern_double("1","101",chess_flag)) { flag_pa5 = 1; } else if( search_pattern_double("1","011",chess_flag)) { flag_pa5 = 1; } else if( search_pattern_double("11","01",chess_flag)) { flag_pa5 = 1; } else { ; } if (flag_pa5 == 1) { if (chess_flag == 2) return 95; else if (chess_flag == 1) return 25; else { return 0; } } else return 0; }
int initialize_dpin_0003( uchar * buf, uint test_area_start, uint test_area_length ) { int ret = 0; struct Pattern_Function pattern_linker; init_case_info(test_area_start, test_area_length); set_test_sectors_in_zone(get_sectors_in_zone()); /* * NOTE ************************************************************************************* * 포팅을 위한 임시 코드. * ****************************************************************************************** */ init_pattern(&g_plr_state, FALSE); /* * NOTE ************************************************************************************* * 사용자는 initialize level 에서 register pattern을 호출해야 한다. * ****************************************************************************************** */ memset(&pattern_linker, 0, sizeof(struct Pattern_Function)); pattern_linker.do_pattern_1 = pattern_sequential; pattern_linker.init_pattern_1 = init_pattern_1_2; pattern_linker.do_extra_verification = extra_verification; regist_pattern(pattern_linker); /* * NOTE ************************************************************************************* * 포팅을 위한 임시 코드. * ****************************************************************************************** */ ret = check_pattern_func(); if(ret) return ret; return ret; }
void reset_game_state() { frog_rank = 0; frog_x = 60; frog_orientation = NORTH; nfrogs = NUMBER_OF_LIVES; mode = PLAYING_MODE; // Initialize traffic pattern init_pattern (traffic + 0, 40, 16, 40, 16, 20, 16, 40, 16, 30, 16, 0, -2); init_pattern (traffic + 1, 40, 16, 40, 16, 20, 16, 40, 16, 30, 16, 30, 2); init_pattern (traffic + 2, 40, 16, 40, 16, 20, 16, 40, 16, 20, 16, 10, -2); init_pattern (traffic + 3, 40, 16, 40, 16, 20, 16, 40, 16, 50, 16, 50, 2); init_pattern (traffic + 4, 40, 16, 40, 16, 20, 16, 40, 16, 30, 16, 103, -2); // Initialize log pattern init_pattern (logs + 0, 40, 50, 40, 50, 40, 50, 40, 50, 40, 50, 0, 3); init_pattern (logs + 1, 40, 50, 40, 50, 40, 50, 40, 50, 40, 50, 50, -3); init_pattern (logs + 2, 40, 50, 40, 50, 40, 50, 40, 50, 40, 50, 93, -5); init_pattern (logs + 3, 40, 50, 40, 30, 40, 50, 20, 50, 40, 30, 20, 5); init_pattern (logs + 4, 40, 50, 40, 50, 40, 50, 40, 50, 40, 50, 64, -4); // Initialize lily pad init_pattern (&lily_pads, 0, 15, 14, 14, 14, 14, 14, 14, 14, 15, 0, 0); }
int pattern_2 (int chess_ax, int chess_ay, int locate, int chess_flag) // 寻找类型为2的点 { init_pattern(chess_ax,chess_ay,locate); int flag_pa21 = 0; int flag_pa22 = 0; int flag_pa23 = 0; //int dn = 0; if(search_pattern_double("","1",chess_flag)) flag_pa21 = 1; else if(search_pattern_double("","01",chess_flag)) flag_pa22 = 1; else if(search_pattern_double("","001",chess_flag)) flag_pa23 = 1; else { ; } if (flag_pa21 == 1) { if (side_one_num > 0 && side_two_num > 0) { if (side_one_num + side_two_num >= 3) return 50; else return 40; } else if (side_one_num > 0 || side_two_num > 0) { if (side_one_num + side_two_num > 3) return 3; else return 2; } else { return 0; } } else if (flag_pa22 == 1) { if (side_one_num > 0 && side_two_num > 0) { if (side_one_num + side_two_num > 2) return 0; //7 else return 0; //6 } else if (side_one_num > 0 || side_two_num > 0) { if (side_one_num + side_two_num > 3) return 0; // 3 else return 0; //0 } else { return 0; } } else if (flag_pa23 == 1) { if (side_one_num > 0 && side_two_num > 0) { if (side_one_num + side_two_num >= 2) return 0; //6 else return 0; } else if (side_one_num > 0 || side_two_num > 0) { if (side_one_num + side_two_num > 1) return 0; //4 else return 0; } } else { return 0; } return 0; }
int pattern_3 (int chess_ax, int chess_ay, int locate, int chess_flag) //计算该点为类型3的权值 { init_pattern(chess_ax,chess_ay,locate); int flag_pa31 = 0; int flag_pa32 = 0; if( search_pattern_double("1","1",chess_flag) ) { flag_pa31 = 1; } else if( search_pattern_double("","11",chess_flag)) { flag_pa31 = 1; } else if( search_pattern_double("1","01",chess_flag)) { flag_pa32 = 1; } #if 0 else if( search_pattern_double("","011",chess_flag)) //FIXME { flag_pa33 = 1; } #endif else { ; } if (flag_pa31 == 1) { if (side_one_num > 0 && side_two_num > 0) { if (side_one_num + side_two_num >= 3) { if (chess_flag == 2) return 30; else if (chess_flag == 1) { // printf("akaedu\n"); //FIXME return 28; } else return 0; } else if (side_one_num + side_two_num == 2) { if (chess_flag == 2) return 27; else if (chess_flag == 1) return 22; else return 0; } else return 0; } else if (side_one_num > 0 || side_two_num > 0) { if (side_one_num + side_two_num >= 2) { if (chess_flag == 2) return 13; else if (chess_flag == 1) return 8; else return 0; } else { return 0; } } else { return 0; } } else if (flag_pa32 == 1) { if (side_one_num > 0 && side_two_num > 0) { if (side_one_num + side_two_num >= 2) { if (chess_flag == 2) return 27; else if (chess_flag == 1) return 25; else return 0; } else { return 0; } } else if (side_one_num > 0 || side_two_num > 0) { if (side_one_num + side_two_num >= 1) { if (chess_flag == 2) return 13; // 25 else if (chess_flag == 1) return 8; // 8 else return 0; } else { return 0; } } else { return 0; } } else { return 0; } }
int pattern_4 (int chess_ax, int chess_ay, int locate, int chess_flag) // 寻找类型为4的点的权值 { init_pattern(chess_ax,chess_ay,locate); int flag_pa4 = 0; if(search_pattern_double("","111",chess_flag)) { flag_pa4 = 1; } else if(search_pattern_double("1","11",chess_flag)) { flag_pa4 = 1; } #if 0 else if(search_pattern_double("","0111",chess_flag)) //FIXME { flag_pa4 = 1; } #endif else { ; } if (flag_pa4 == 1) { if (side_one_num > 0 && side_two_num > 0) { if (chess_flag == 2) return 85; else if (chess_flag == 1) { // printf ("akaedu\n"); return 80; } else return 0; } else if (side_one_num > 0 || side_two_num > 0) { if (side_one_num + side_two_num >= 1) // 我方60 { if (chess_flag == 2) return 70; else if (chess_flag == 1) { return 25; // FIXME } else return 0; } else { return 0; } } else return 0; } else { return 0; } }