void create_map(void) { struct island_data *isle; init_grid(); // make a ton of plains islands printf("Generating islands with %d total land target...\n", TARGET_LAND_SIZE); create_islands(); printf("Adding mountains and rivers...\n"); for (isle = island_list; isle; isle = isle->next) { // fillings based on location (it's not desert or jungle YET, so we check prcs if (IS_IN_Y_PRC_RANGE(Y_COORD(isle->loc), DESERT_START_PRC, DESERT_END_PRC)) { // desert add_mountains(isle); // rare chance of river if (!number(0, 2)) { add_river(isle); } } else if (IS_IN_Y_PRC_RANGE(Y_COORD(isle->loc), JUNGLE_START_PRC, JUNGLE_END_PRC)) { // jungle // chance of mountain if (!number(0, 1)) { add_mountains(isle); } // always get extra river add_river(isle); add_river(isle); } else { // not jungle or desert add_mountains(isle); add_river(isle); // chance to add additional river if (!number(0, 2)) { add_river(isle); } } // not currently adding passes // add_pass(isle); } // these really need to go in order, as they modify the map in passes printf("Adding desert...\n"); add_latitude_terrain(DESERT, DESERT_START_PRC, DESERT_END_PRC); printf("Adding jungle...\n"); add_latitude_terrain(JUNGLE, JUNGLE_START_PRC, JUNGLE_END_PRC); printf("Numbering islands and fixing lakes...\n"); number_islands_and_fix_lakes(); printf("Irrigating from rivers...\n"); replace_near(DESERT, PLAINS, RIVER, 2); replace_near(DESERT, PLAINS, LAKE, 2); replace_near(JUNGLE, SWAMP, RIVER, 2); replace_near(JUNGLE, SWAMP, LAKE, 2); // tundra if no y-wrap if (!USE_WRAP_Y && TUNDRA_HEIGHT >= 1) { printf("Adding tundra...\n"); add_tundra(); } // center maps if they use only x-wrap if (USE_WRAP_X && !USE_WRAP_Y) { printf("Centering map horizontally...\r\n"); center_map(); } // finish up the map printf("Finishing map...\n"); complete_map(); add_start_points(); }
wchar_t* recognize(kanji unknown, kanjis data) { kanji dummy_k; dummy_k.c_strokes = 0; dummy_k.c_points = 0; dummy_k.xy = 0; dummy_k.kji = 'c'; result best_100[100]; result dummy; dummy.weight = 100000; dummy.k = dummy_k; for(int i=0;i<100;i++) { best_100[i] = dummy; } // coarse recognition with endpoints int (*p_endpoint) (kanji, int, kanji, int); p_endpoint = endpoint; int (*p_endpoint_conc) (kanji, int, kanji, int, int); p_endpoint_conc = endpoint_conc; wchar_t hirag_ri = L'\u308a'; for(int i=0;i<data.count;i++) { //if(data.arr[i].kji == unknown.kji || data.arr[i].kji == hirag_ri) { { // printf("unknown:\n"); // print_kanji(unknown); // printf("from data-set:\n"); // print_kanji(data.arr[i]); kanji larger; kanji smaller; if(unknown.c_strokes >= data.arr[i].c_strokes) { larger = unknown; smaller = data.arr[i]; } else { larger = data.arr[i]; smaller = unknown; } smap sm_init_ep = get_initial_map(larger, smaller, p_endpoint); // print_smap(sm_init_ep); smap sm_comp_ep = complete_map(sm_init_ep, larger, smaller, p_endpoint_conc); // print_smap(sm_comp_ep); int weight_i = compute_coarse_weight(sm_comp_ep, larger, smaller); // wprintf(L"\n coarse weight: %i for %lc ", weight_i, data.arr[i].kji); // weight_i = (10 * larger.c_strokes * weight_i)/(smaller.c_strokes); // return ((largeX.length*10)/(smallX.length))*weight; // wprintf(L"\n coarse weight: %i for %lc ", weight_i, data.arr[i].kji); if(1) { insert_into(best_100, 100, weight_i, data.arr[i]); // wprintf(L"\n %lc ", data.arr[i].kji); // print_smap(sm_comp_ep); // printf("weight: %i\n",weight_i); } free(sm_init_ep.m); // free(sm_comp_ep.m); } } // fine recognition with initialization by // init-dist and completion by whole-dist dummy.weight = 100000; dummy.k = dummy_k; result best_10[10]; for(int i=0;i<10;i++) { best_10[i] = dummy; } int (*p_initial) (kanji, int, kanji, int); p_initial = initial; int (*p_whole) (kanji, int, kanji, int, int); p_whole = whole; int (*p_whole_delta) (kanji, int, kanji, int, int); p_whole_delta = whole_delta; for (int i = 0; i < 100; i++) { // skip the inserted dummy kanji // which has zero strokes // skip "smaller" kanji if (best_100[i].k.c_strokes > 0) { // && best_100[i].k.kji == unknown.kji) { if(best_100[i].k.kji == unknown.kji ) { // printf("within best 100\n"); } kanji larger; kanji smaller; if (unknown.c_strokes >= best_100[i].k.c_strokes) { larger = unknown; smaller = best_100[i].k; } else { larger = best_100[i].k; smaller = unknown; } smap sm_init_wh = get_initial_map(larger, smaller, p_initial); smap sm_comp_wh; if (unknown.c_strokes < 5) { sm_comp_wh = complete_map(sm_init_wh, larger, smaller, p_whole_delta); } else { sm_comp_wh = complete_map(sm_init_wh, larger, smaller, p_whole); } // print_smap(sm_comp_wh); int weight_i = 0; if(unknown.c_strokes < 5) { wchar_t wc = strtol("30c8", NULL, 16); if(unknown.kji == wc) { // wprintf(L"%lc and %lc",larger.kji, smaller.kji); // print_smap(sm_comp_wh); } weight_i = compute_fine_weight(sm_comp_wh, larger, smaller, true); } else { weight_i = compute_fine_weight(sm_comp_wh, larger, smaller, false); } // weight_i = compute_initial_weight(sm_comp_wh, larger, smaller); // wprintf(L"\n fine weight: %i for %lc ", weight_i, best_100[i].k.kji); insert_into(best_10, 10, weight_i, best_100[i].k); free(sm_init_wh.m); //free(sm_comp_wh.m); } } static wchar_t matching_kjis[10]; for(int i=0;i<10;i++) { matching_kjis[i] = best_10[i].k.kji; // printf("w: %i", best_10[i].weight); } // printf("\n"); return matching_kjis; }