/* Based on the entries in the reading cache and their nodes field, * compute where the relatively most expensive tactical reading is * going on. */ void reading_hotspots(float values[BOARDMAX]) { int pos; int k; int sum_nodes = 0; for (pos = BOARDMIN; pos < BOARDMAX; pos++) values[pos] = 0.0; /* Compute the total number of nodes for the cached entries. */ for (k = 0; k < reading_cache.current_size; k++) sum_nodes += reading_cache.table[k].cost; if (sum_nodes <= 100) return; /* Loop over all entries and increase the value of vertices adjacent * to dragons involving expensive tactical reading. */ for (k = 0; k < reading_cache.current_size; k++) { struct persistent_cache_entry *entry = &(reading_cache.table[k]); float contribution = entry->cost / (float) sum_nodes; if (0) { gprintf("Reading hotspots: %d %1m %f\n", entry->routine, entry->apos, contribution); } switch (entry->routine) { case ATTACK: case FIND_DEFENSE: mark_string_hotspot_values(values, I(entry->apos), J(entry->apos), contribution); break; default: gg_assert(0); /* Shouldn't happen. */ break; } } }
/* Based on the entries in the reading cache and their nodes field, * compute where the relatively most expensive tactical reading is * going on. */ void reading_hotspots(float values[BOARDMAX]) { int m, n, k; int sum_nodes = 0; for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) values[POS(m, n)] = 0.0; /* Compute the total number of nodes for the cached entries. */ for (k = 0; k < persistent_reading_cache_size; k++) sum_nodes += persistent_reading_cache[k].nodes; if (sum_nodes <= 100) return; /* Loop over all entries and increase the value of vertices adjacent * to dragons involving expensive tactical reading. */ for (k = 0; k < persistent_reading_cache_size; k++) { struct reading_cache *entry = &(persistent_reading_cache[k]); float contribution = entry->nodes / (float) sum_nodes; if (0) { gprintf("Reading hotspots: %d %1m %f\n", entry->routine, entry->str, contribution); } switch (entry->routine) { case ATTACK: case FIND_DEFENSE: mark_string_hotspot_values(values, I(entry->str), J(entry->str), contribution); break; default: gg_assert(0); /* Shouldn't happen. */ break; } } }