Difference between revisions of "Appearance rates"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>Fredg1
(code snippet is now obsolete)
 
(7 intermediate revisions by 3 users not shown)
Line 6: Line 6:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Adventuring|
 
  
 
function1={{Function|
 
function1={{Function|
Line 14: Line 13:
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
 
parameter1={{Param|location|place}}|
 
parameter1={{Param|location|place}}|
 +
}}|
 +
 +
function2={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|location|place}}|
 +
parameter2={{Param|boolean|queue}}|
 
p1desc={{Pspan|place}} is the adventuring location to parse|
 
p1desc={{Pspan|place}} is the adventuring location to parse|
 +
p2desc=The optional parameter {{Pspan|queue}} is false if not included.|
 
}}|
 
}}|
  
function_description=Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0; ultra-rare monsters have a negative value (the actual value varies; test by looking for value < 0, not value == -1). Does not account for combat rate modifiers, olfaction, etc.|
+
function_description=Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Account for combat rate modifiers, olfaction, etc. (as best as it can).<br> Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0.<br> Ultra-Rare monsters have a value of -1.0.<br> Impossible monsters (mostly just monsters that only appear on odd/even ascensions) have a value of -2.0.<br> (Properly, as in not-also-olfacted) Banished monsters have a value of -3.0.<br> Monsters banished by in-game mechanics (such as pygmy janitors in the hidden city) have a value of -4.0 (is often mixed up with 0.0 values). </p>
 +
<p>If there is a chance of non-combat encounters, that will be listed as the chance of encountering $monster[none].</p>
 +
<p>If {{Pspan|queue}} is true, then the monsters currently in the adventuring queue will be considered when determining the likelihood of future encounters. This is better for a real prediction of what monster will actually occur next while not considering the queue is better for modeling theoretical situations.|
  
 
code1={{CodeSample|
 
code1={{CodeSample|
Line 24: Line 35:
 
code=
 
code=
 
<syntaxhighlight>
 
<syntaxhighlight>
float[monster] freq = appearance_rates($location[Castle]);
+
foreach mob, freq in appearance_rates($location[Dungeon of Doom])
print("Encounters in the Castle:");
+
  switch {
foreach m in freq {
+
   case mob == $monster[none]:
   string str = m.to_string();
+
      if(freq > 0) print("Frequency of non-combats: "+ freq + "%");
  if(str=="none") str = "Noncombats";
+
      break;
   if(freq[m]>0 && m != $monster[none]) print("Frequency of " + str + ": " + freq[m] + "%");
+
   case freq > 0:
   if(freq[m]==-1) print("Frequency of " + str + ": Unknown");
+
      print("Frequency of " + mob + ": " + freq + "%");
   else print("Frequency of " + str + ": Unlikely (either semirare, boss, or ultra-rare)");
+
      break;
}
+
   case freq == 0:
</syntaxhighlight>}}
+
      print("Frequency of " + mob + ": Boss (one time encounter) or semirare encounter.");
 +
      break;
 +
   case freq < 0:
 +
      print("Frequency of " + mob + ": Ultra-rare!");
 +
      break;
 +
  default:
 +
      print("Frequency of " + mob + ": Unknown");
 +
      break;
 +
  }
 +
</syntaxhighlight>}}|
 +
see_also={{SeeAlso|get_monsters|last_monster}}|
 
special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia's data files.|
 
special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia's data files.|
 
}}
 
}}
 +
 +
[[Category:Adventuring]]

Latest revision as of 10:28, 31 August 2020

Function Syntax

float [monster] appearance_rates(location place )

float [monster] appearance_rates(location place ,boolean queue )

  • place is the adventuring location to parse
  • The optional parameter queue is false if not included.

Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Account for combat rate modifiers, olfaction, etc. (as best as it can).
Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0.
Ultra-Rare monsters have a value of -1.0.
Impossible monsters (mostly just monsters that only appear on odd/even ascensions) have a value of -2.0.
(Properly, as in not-also-olfacted) Banished monsters have a value of -3.0.
Monsters banished by in-game mechanics (such as pygmy janitors in the hidden city) have a value of -4.0 (is often mixed up with 0.0 values).

If there is a chance of non-combat encounters, that will be listed as the chance of encountering $monster[none].

If queue is true, then the monsters currently in the adventuring queue will be considered when determining the likelihood of future encounters. This is better for a real prediction of what monster will actually occur next while not considering the queue is better for modeling theoretical situations.

Simple Example

Prints the encounters in a zone and their rates of appearing.

foreach mob, freq in appearance_rates($location[Dungeon of Doom])
   switch {
   case mob == $monster[none]:
      if(freq > 0) print("Frequency of non-combats: "+ freq + "%");
      break;
   case freq > 0:
      print("Frequency of " + mob + ": " + freq + "%");
      break;
   case freq == 0:
      print("Frequency of " + mob + ": Boss (one time encounter) or semirare encounter.");
      break;
   case freq < 0:
      print("Frequency of " + mob + ": Ultra-rare!");
      break;
   default:
      print("Frequency of " + mob + ": Unknown");
      break;
   }

See Also

get_monsters() | last_monster()

Special

When not logged in, this function still returns the same data, as it is pulled from KoLmafia's data files.