# This is the configuration file for the Borg. For a high-level overview
# of the Borg and its features, see the official documentation in
# docs/hacking/borg.rst.

# This file will allow you to customize your borg along certain themes.
# The borg is fairly successful, having won the game several times.
# However, some players/observers of borgs would like to see it function
# differently. Some would like to see the borg play more aggressively, or
# more conservatively. While others would like to value armour class more.
# Still others would like to see it collect more speed items. With the
# expressions below, you can influence the borg's behavior and
# equipment selection choices. To modify, simply set values to TRUE or FALSE,
# with the exception of a few integers.


### Worships ###

# The 'borg_worship_' variables will influence his equipment selection by
# adding additional bonuses to items which enhance that attribute. For example:
# if a borg receives 2000 pts for a single point of armour class, an 'ac
# worshipping' borg would receive 3000 pts. This bonus would significantly
# influence equipment choices.
#
# borg_worships_gold explained:
# The borg_worships_gold option will greatly impact how the borg treats items
# which he finds in the dungeon. With this option on, he will return to town
# whenever he fills up with items then sell those items. This can cause
# the borg to lose some artifacts, since he will sell them even if not ID'd.
# Generally speaking the borg will not sell an item unless it is at least
# pseudo ID'd. The benefit of this option is that the borg will significantly
# increase his income at the low clevels. This will increase his survivability
# by allowing him to invest in armour and arrows. With this on,
# he will not recall to town to sell stuff but climb the stairs instead.
# He will also not recall into the dungeon until dlevel 8 (instead of 5).
# This option has no effect after clevel 20. One other downside of this is
# that the borg will spend more time in town and may have to evade Vets more.

borg_worships_damage = FALSE
borg_worships_speed = FALSE
borg_worships_hp = FALSE
borg_worships_mana = FALSE
borg_worships_ac = FALSE
borg_worships_gold = FALSE


### Risky ###

# A risky borg is one who is not confined by character level requirements
# in order to dive deeper. It is also more likely to stay in a battle than
# to teleport out. A risky borg will dive faster but is more likely to die.
# A risky borg is not concerned with killing uniques before diving deeper.
#
# A borg who scums for uniques will set the auto_scum flag in order to generate
# more exciting levels and hopefully encounter a unique
# 
# borgs who kill_uniques will wait for uniques to die before diving deeper
# into the dungeon. Usually, he will not dive deeper than three uniques.
# Example, Unique Monsters who normally reside on levels 12, 15, and 18 are
# still alive so the borg will not dive deeper than level 18 until at least one
# of those uniques are dead. Setting this to FALSE will allow the borg to dive
# deeper, faster, not being held up by the uniques. But, he does run the risk
# of finding 3 or 4 uniques on one level. That can be a bit scary.

borg_plays_risky = FALSE
borg_kills_uniques = FALSE


### Swap Items ###

# The borg is designed to use Swap Items in the inventory. A swap item
# is an equipment item (like a sword or armour item) which possesses a
# desirable resistance or trait. If the borg is in danger, then he will
# consider exchanging his current item for the swap item. A prime example of
# this is at dungeon level 60. He is required to have several resists in
# place. If he does not have them then he will not dive deeper. However,
# with Swaps enabled he will select an item to cover the open resist then
# dive down. Having Swaps enabled allows the borg to dive deeper, faster.
# The draw back is the Swap Items take up two inventory slots.

borg_uses_swaps = TRUE


### Strange Opts ###

# some birth options don't allow the borg to run well. If you want to allow
# the borg to run anyways, set this to TRUE and run at your own risk.

borg_allow_strange_opts = FALSE


### Cheat Death ###

# If borg_cheat_death is set, the option to cheat death will be set and, when
# the borg dies, he will cheat death and keep going. If this is false and the
# option to cheat death in the game is true the borg will reincarnate (respawn)
# as a player using the options below to pick the new player. If the option
# to cheat death is false and this is false, the borg will stop on death.

borg_cheat_death = FALSE


### Respawn ###

# If the borg is in continual play mode (as with the screen saver),
# he will respawn a randomly generated character at death. This section
# allows the user to make certain bias for the type of character generated.
# You may select the race and or class and or minimal stats for the Borg.
# You may also select the minimal character level needed before the
# character dump is created in the game directory.
#
# With regards to race, the borg is programmed to accept the variety of
# user defined races which may be in the p_info.txt file. So the values
# given in table below are for the default races. But if you are bright
# enough to modify the p_info.txt file then you are bright enough to figure
# out that race 0 does not necessarily equal Human. It's just the first
# race listed in your p_info.txt file.
#
# RACE:-1 Random Race          CLASS:  -1 Random Class
#       0 Human                         0 Warrior
#       1 Half Elf                      1 Mage
#       2 Elf                           2 Druid
#       3 Hobbit                        3 Priest
#       4 Gnome                         4 Necromancer
#       5 Dwarf                         5 Paladin
#       6 Half Orc                      6 Rogue
#       7 Half Troll                    7 Ranger
#       8 Dunadan                       8 Blackguard
#       9 High Elf
#	   10 Kobold
#
# With regards to the stats. The minimal stats are rolled by the
# borg. CON will be 16, the secondary stat (usually DEX) will be 17,
# The primary stat will be 17. These are the maximal values which
# can be rolled (racial and class bonuses added after).
# If the borg can not reach the stats after 500,000 tries the game
# will just assign you a random stat.
#
# After killing Morgoth, generally, the borg will stop and allow you
# to inspect the victory. If you set the respawn_winners then after
# killing Morgoth,the borg will generate a new character. A map file
# is created so you can see what the final battle looked like.

borg_respawn_race = -1
borg_respawn_class = -1
borg_respawn_winners = FALSE


### Dumps ###

# This variable will determine the minimal character level at which the borg
# will create a character dump file. That file contains some vital information
# concerning the status of the borg at the time of his demise. It is placed
# in the archive directory.
# The borg_save_death variable will tell the borg to save the game in the
# archive directory so that it can be examined more closely. The clevel of the
# borg must at least equal the borg_dump_level in order for the game to save.

borg_dump_level = 1
borg_save_death = 1


### Autosave ###

# This causes the borg to do a (redundant) save at the start of every level and
# create a backup of that save to the archive directory

borg_autosave = FALSE


### Auto Stops ###

# The borg is able to stop when it reaches a certain dungeon depth or character
# level. He will also stop when he wins the game. If you want him to keep
# playing, even after Morgoth is dead, then change the borg_stop_king to FALSE.
# Set the other values to the level at which you want the borg to stop. Set
# them out of bounds if you do not want him to stop.

borg_stop_dlevel = 128
borg_stop_clevel = 51
borg_no_deeper = 127
borg_stop_king = TRUE


### Stop On Bell ###

# If stop on bell is set, the borg will stop when the game plays the bell, 
# which generally only happens on an error. This is to help debug issues. The
# message log will contain a list of up to 50 of the latest keypresses.

borg_stop_on_bell = FALSE


### Chest Tolerance ###

# The borg is able to search, disarm, and open chests. There is an inherent
# risk when dealing with chests. The risk of setting off the trap vs the
# benefit of the loot within the chest. The game uses a straight forward 
# formula for calculating the success of a chest. It is:
# randint(100) < the skill of the player minus the difficulty of the chest.
# Difficulties run from 1 to 63.

borg_chest_fail_tolerance = 7


### Speed Of The Borg ###

# You can slow the borg down a couple of ways. One way is to set the
# base game delay factor in the options menu. This will slow down the borg
# and the visual effects (like missiles shooting, explosions). If using the
# screensaver, you will need to load angband.exe load the savefile, make the
# modifications, then save and exit. Another way to slow the borg down is
# to use the following variable. The formula is:
# base_game_delay_factor^2 + borg_delay_factor^2.

borg_delay_factor = 0


### Money Scumming ###

# This started as more of a joke but it does have a useful purpose. If you 
# find yourself shopping in the BM and you really want that item and its just 
# out of your price range, then you can set a dollar amount into this variable 
# and the borg will run around town killing monsters and collecting items for 
# cash. Once he has reached his monetary goal, it will unhook and stop moving. 
# The borg will wait on the level, to build up more townspeople, kill them, 
# buy food when it needs to. But it won't leave the level until the goal
# is reached. To disengage the money scum, leave this variable at 0 (zero).
# This will also simulate the borg_worships_gold and allow the borg to sell 
# non-ID'd items which will be dropped in town. The borg will flee from town 
# from Scary Guys. So keep this in mind with borgs under clevel 6. The borg 
# will not scum unless he has a perma light source (phial, or some glowing 
# artifact). The borg will stop if the General Store runs out of food to buy.
# It is not recommended for borgs with Regeneration and no Slow 
# Digestion, since they will spend all their money on food. But if you have a
# borg with Satisfy Hunger spell, they can stay in town forever.
# NOTE: if a human wants the borg to scum to a particular amount, turn the 
# borg_self_scum to FALSE or else he will buy his own gear with that money.

borg_money_scum_amount = 0


### Borg Scumming ###

# This is a companion to the Money Scum above. The borg will scum town if
# a stat potion is in the BM. If the borg finds an item in town that he would
# really like to have, then he will stay in town until he has gathered enough
# money to buy it. The borg will behave like the borg_money_scum_amount above.
# If this is TRUE, then the borg is allowed to scum for items that he wants.
# To forbid this behavior (which can take a very long time) set it FALSE.
# NOTE: if a human wants the borg to scum to a particular amount, turn the 
# borg_self_scum to FALSE or else he will buy his own gear with that money.
# Also, the borg must be at least clevel 10, with a perma light, 
# a 65% chance to avoid the pick pocket, and lots of food.

borg_self_scum = TRUE


### Lunal Borg ###

# The borg will dive deep in the dungeon, even while he is still
# low level, bouncing between levels to take nearby down stairs.
# Once deep, he will gather items, then recall to town. He will not recall
# back down into the dungeon, but walk all the way down again. If you want
# a fast win, this is not the option for you. If you want the borg to have
# maxed stats early on at the expense of game turns, then give this a try.
# The best way to use this is to have a borg that can cast Satisfy Hunger.
# This is a one way trip for the borg and he will be getting hungry.
# The borg should also have a perma light source (like the phial). Again,
# one way trip. He won't be stopping to restock his fuel source. However,
# if he has food or fuel, he will use them when appropriate. Having extra
# speed will help the borg too. Often he will come down the stairs, and 
# find himself right next to a monster. Sometimes, that monster can get
# the first hit on a borg, killing him instantly. Even +3 speed would help
# to avoid this type of instadeath.
#
# Self Lunal Mode will allow the borg to use the stair scumming in order to
# dive deep in the dungeon for his own goals. For example, if the borg has
# been down to depth 99, and now has no more potions of healing, he will
# only be prepared for depth 45. He will remain shallow in the dungeon,
# from depth 1-10 waiting for the shops to cycle. Then he will attempt to 
# buy a healing potion from the town shops. If none is available, he will
# return to the shallow dungeon depths and wait for the shops to cycle. He 
# will repeat this pattern until he gets a potion of healing. If the borg 
# is allowed to self-lunal, then it will bounce the stairs down to a depth
# where it feels comfortable. In the case above, it will do this until
# about depth 40.

borg_lunal_mode = FALSE
borg_self_lunal = FALSE


### Borg Verbose ###

# Verbose is default off. It makes the borg give more reports on his actions
# and thoughts. He still gives reports when verbose is FALSE, but when TRUE, 
# he really chats up a storm.

borg_verbose = FALSE


### Munchkin Start ###

# Munchkin start will have the borg stair-scum at depth 5-6, looking for items
# which he will then sell in town. He will continue this process until about
# clevel 6 or 7. The advantage is a sizable boost to his early income and
# he can find some wands early on to assist with monster killing.

borg_munchkin_start = FALSE
borg_munchkin_level = 12
borg_munchkin_depth = 16


### Enchant Limit ###

# The borg knows how to enchant his equipment using scrolls and spells.
# For ammo, he will stop enchanting about +10 or so. If he has access 
# to the *enchant* spell, he can go up to +15. But the borg will spend
# a lot of time casting and resting in order to get his item up to +15.
# The borg has plenty of time, to waste doing this. If you want a fast
# win, then choose a lower number like +11.

borg_enchant_limit = 12

# keep the ignore settings from before the borg was run

borg_restore_ignore_settings = false


### Dynamic Calculations ###

# Use the FORMULA SECTION below. If false the borg will
# use the calcs in the C code. Which is recommended since those are honed
# more frequently than the dynamic calcs. Most borg users will
# have more successful borgs by leaving this option as FALSE.
# note: the dynamic calcs are slower than the internal calcs

borg_uses_dynamic_calcs = FALSE


[BEGIN FORMULA SECTION]

# There are three sections 
#	Power   - used to calculate the "power" of the borg
#	Depth   - used to determine what depth a borg feels prepared for (don't go deeper than)
#	Restock - used to determine if the borg feels it needs to go shopping
#				this is a subset of being prepared but is also used on its own.
#
# special formula:  
#	depth( n ) - the depth to check for. if condition true, don't go below this depth.
#	range(from, to) - loop from until to and add value to power each time
#	value( type, name ) - returns a value dependent on the types
#		type list:
#		ACTIVATION: returns the number of items the borg is wearing that use that activation
#		TRAIT: value from the borg.trait list. This can be dumped by ^zh
#		CONFIG: value from the configuration as read from borg.txt
#		CLASS: true/false (1/0) if the borgs current class matches the name
#		RANGE: index into the range(from, to) above,  returns -1 if no range is given
#				also used for depth checks as the depth being checked.
#		type from object.txt with name matching the name from that file. Count of that object that the borg is carrying or wearing.
#			ex: value(potion, Cure Critical Wounds) is the number of CCW potions
#				** worth noting value(trait, amt potion ccw) will be a calculated amount of ccw, which might include other healing
#				such as spells that cure that amount so may not have the same value as value(potion, Cure Critical Wounds)
#	reward: calculation of what power increase for each, if you have range, or just for having, if you don't
#	condition: if calculates to zero you don't get the reward. For ranges, is calculated once before the range is processed
#
# note on calculations: some order of operations are handled, some are not. When in doubt, parentheses are your friend

#### future enhancement value_home( type, name) - same as above but in the home, HomePower ... 

# there are some values still done in the code (approximate values given)
# 1) getting to zero fail on spell casting gives 30,000. fail rate gives 100 per percent success on best spell
# 2) Reward the borg for carrying a NON-ID items that have random powers (999999)
# 3) Penalize armor weight (250 per item that is too heavy)
# 4) Penalize heavy armor for reducing spell points (~400 per point lost)
# 5) Reward carrying a shovel if low level (5000)
# 6) books - 15000/spell you can cast from a book (50000 if it is a dungeon book)
# 7) encumbrance loses ((weight - max carry/2) / max carry / 10) * 10000

Power
[
# weapon stuff	
# wielding un-ID'd weapon
	condition((value(trait, depth) < 10) and (value(trait, max clevel) < 15) and !value(trait, wep id)): reward(1000000);
# "damage" and increased blows per round
	reward(value(trait, wep damage dice) * value(trait, wep damage sides) * 20 * (value(trait, blows) + 1));
# "bonus to hit"
	reward((value(trait, to hit) + value(trait, wep to hit)) * 100);
# "bonus to dam"
	reward((value(trait, to damage) + value(trait, wep to damage)) * 30);
# extra damage? for some
	condition(value(config, worships_damage)): reward((value(trait, to hit) + value(trait, wep to hit)) * 15);
# extra boost for deep dungeon
	condition(value(trait, max depth) >= 75): reward((value(trait, to hit) + value(trait, wep to hit)) * 15);
	condition(value(trait, max depth)>= 75): reward(value(trait, wep damage dice) * value(trait, wep damage sides) * 40 * value(trait, blows));
# assume 2x base damage for x% of creatures
	condition(value(trait, wep slay animal)): reward(value(trait, blows) * 2 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20);
	condition(value(trait, wep slay evil)): reward((((value(trait, blows) * 2 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 7) / 2));
# extra damage for some 		
	condition(value(config, worships_damage)): reward(value(trait, blows) * 2 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20);
# assume 3x base damage for x% of creatures 
	condition(value(trait, wep slay undead) and !value(trait, wep kill undead)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 5) / 2));
	condition(value(trait, wep slay demon) and !value(trait, wep kill demon)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 3) / 2));
	condition(value(trait, wep slay dragon) and !value(trait, wep kill dragon)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 6) / 2));
	condition(value(trait, wep slay giant)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 4) / 2));
	condition(value(trait, wep brand acid)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 4) / 2));
	condition(value(trait, wep brand elec)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 5) / 2));
	condition(value(trait, wep brand fire)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 3) / 2));
	condition(value(trait, wep brand cold)): reward((((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 3) / 2));
	condition(value(trait, wep slay orc)): reward(((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) / 2));
	condition(value(trait, wep slay troll)): reward(value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20);
	condition(value(trait, wep slay orc) and !value(trait, wep slay evil)): reward((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) / 2);
	condition(value(trait, wep slay troll) and !value(trait, wep slay evil)): reward((value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) / 2);
	condition(value(config, worships_damage)): reward(value(trait, blows) * 3 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20);
# assume 5x base damage for x% of creatures 
	condition(value(trait, wep kill undead)): reward((((value(trait, blows) * 5 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 5) / 2));
	condition(value(trait, wep kill demon)): reward((((value(trait, blows) * 5 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 5) / 2));
	condition(value(trait, wep kill dragon)): reward((((value(trait, blows) * 5 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20) * 5) / 2));
	condition(value(config, worships_damage)): reward(value(trait, blows) * 5 * value(trait, wep damage dice) * value(trait, wep damage sides) * 20);
# It used to be only on Grond
	condition(value(trait, wep impact)): reward(50);
# It is hard to hold a heavy weapon
	condition(value(trait, heavy weapon)): reward(-500000);
# We want low level borgs to have high blows (dagger, whips)
	condition(value(trait, clevel) <= 10): reward(value(trait, blows) * 45000);

# bow stuff
# wearing an unID'D bow but not at high level since bow likely to have traits
	condition((value(trait, depth) < 10) and (value(trait, max clevel) < 15) and !value(trait, bow id)): reward(6000000);
# bow damage
	condition(((value(trait, bow to damage) > 8) or (value(trait, clevel) < 25)) and value(config, worships_damage)): reward((value(trait, ammo sides) + value(trait, bow to damage)) * value(trait, ammo power) * value(trait, shots) * 11);
	condition(((value(trait, bow to damage) > 8) or (value(trait, clevel) < 25)) and !value(config, worships_damage)): reward((value(trait, ammo sides) + value(trait, bow to damage)) * value(trait, ammo power) * value(trait, shots) * 9);
	condition(((value(trait, bow to damage) <= 8) and (value(trait, clevel) >= 25)) and value(config, worships_damage)): reward((value(trait, ammo sides) + 8) * value(trait, ammo power) * value(trait, shots) * 11);
	condition(((value(trait, bow to damage) <= 8) and (value(trait, clevel) >= 25)) and !value(config, worships_damage)): reward((value(trait, ammo sides) + 8) * value(trait, ammo power) * value(trait, shots) * 9);
# extra bonus for low levels, they need a ranged weapon 
	condition((value(trait, bow to damage) > 8 or value(trait, clevel) < 25) and value(trait, clevel) < 15): reward((value(trait, ammo sides) + value(trait, bow to damage)) * value(trait, ammo power) * value(trait, shots) * 200);
# slings force you to carry heavy ammo. Penalty for that unless you have lots of str 
	condition(value(trait, bow is sling) and !value(trait, bow artifact) and (value(trait, str) < 9)): reward(-5000);
	condition(value(trait, bow is sling) and (value(trait, clevel) = 1) and (value(trait, str) >= 9)): reward(5000);
# "bonus to hit"
	reward((value(trait, bow to hit) + value(trait, to hit)) * 100);
# extra damage for some 
	condition(value(config, worships_damage)): reward((value(trait, bow to hit) + value(trait, to hit)) * 25);
# this is just rangers !FIX note ugly tval hardcode 
	condition(value(trait, fast shots) and (value(trait, ammo tval) = 3)): reward(30000);
	condition(value(trait, heavy bow)): reward(-500000);

#light radius
	condition(value(class, necromancer)): reward(value(trait, light) * 10000);
	condition(value(trait, light) <= 3 and !value(class, necromancer)): reward(value(trait, light) * 10000);
	condition(value(trait, light) > 3 and ! value(class, necromancer)): reward(value(trait, light) * 1000 + 30000);

	reward(value(trait, extra moves) * 3000);
	reward(value(trait, damage reduction) * 10000);

#speed
	condition(value(config, worships_speed) and value(trait, speed) >= 150): reward(((value(trait, speed) - 120) * 1500) + 185000);
	condition(value(config, worships_speed) and value(trait, speed) >= 145 and value(trait, speed) <= 149): reward(((value(trait, speed) - 120) * 1500) + 180000);
	condition(value(config, worships_speed) and value(trait, speed) >= 135 and value(trait, speed) <= 144): reward(((value(trait, speed) - 120) * 1500) + 175000);
	condition(value(config, worships_speed) and value(trait, speed) >= 130 and value(trait, speed) <= 134): reward(((value(trait, speed) - 120) * 1500) + 160000);
	condition(value(config, worships_speed) and value(trait, speed) >= 125 and value(trait, speed) <= 129): reward(((value(trait, speed) - 110) * 1500) + 135000);
	condition(value(config, worships_speed) and value(trait, speed) >= 120 and value(trait, speed) <= 124): reward(((value(trait, speed) - 110) * 1500) + 110000);
	condition(value(config, worships_speed) and value(trait, speed) >= 115 and value(trait, speed) <= 119): reward(((value(trait, speed) - 110) * 1500) + 85000);
	condition(value(config, worships_speed) and value(trait, speed) >= 110 and value(trait, speed) <= 114): reward(((value(trait, speed) - 110) * 1500) + 65000);

	condition(!value(config, worships_speed) and value(trait, speed) >= 140): reward(((value(trait, speed) - 120) * 1000) + 175000);
	condition(!value(config, worships_speed) and value(trait, speed) >= 135 and value(trait, speed) <= 139): reward(((value(trait, speed) - 120) * 1000) + 165000);
	condition(!value(config, worships_speed) and value(trait, speed) >= 130 and value(trait, speed) <= 134): reward(((value(trait, speed) - 120) * 1000) + 150000);
	condition(!value(config, worships_speed) and value(trait, speed) >= 125 and value(trait, speed) <= 129): reward(((value(trait, speed) - 110) * 1000) + 125000);
	condition(!value(config, worships_speed) and value(trait, speed) >= 120 and value(trait, speed) <= 124): reward(((value(trait, speed) - 110) * 1000) + 100000);
	condition(!value(config, worships_speed) and value(trait, speed) >= 115 and value(trait, speed) <= 119): reward(((value(trait, speed) - 110) * 1000) + 75000);
	condition(!value(config, worships_speed) and value(trait, speed) >= 110 and value(trait, speed) <= 114): reward(((value(trait, speed) - 110) * 1000) + 55000);

	condition(value(trait, speed) < 110): reward((value(trait, speed) - 110) * 2500);

# strength bonus
	reward(value(trait, str index) * 100);

	condition((value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin))): reward(value(trait, wis index) * 500);
	condition((value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin)) and value(config, worships_mana)): reward((value(trait, sp adj) / 2) * 255);
	condition((value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin)) and !value(config, worships_mana)): reward((value(trait, sp adj) / 2) * 155);

	condition((value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue))): reward(value(trait, int index) * 500);
	condition((value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue)) and value(config, worships_mana)): reward((value(trait, sp adj) / 2) * 255);
	condition((value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue)) and !value(config, worships_mana)): reward((value(trait, sp adj) / 2) * 155);

# dex bonus
	condition(value(trait, dex index) <= 37): reward(value(trait, dex index) * 120);
# con bonus
	condition(value(config, worships_hp) and (value(trait, con index) <= 37)): reward(value(trait, con index) * 250);
	condition(value(config, worships_hp) and (value(trait, con index) <= 37) and value(trait, hp adj) < 800): reward(value(trait, hp adj) * 450);
	condition(value(config, worships_hp) and (value(trait, con index) <= 37) and value(trait, hp adj) >= 800): reward(((value(trait, hp adj) - 800) * 100) + 175000);
	condition(!value(config, worships_hp) and (value(trait, con index) <= 37)): reward(value(trait, con index) * 150);
	condition(!value(config, worships_hp) and (value(trait, con index) <= 37) and value(trait, hp adj) < 500): reward(value(trait, hp adj) * 350);
	condition(!value(config, worships_hp) and (value(trait, con index) <= 37) and value(trait, hp adj) >= 500): reward(((value(trait, hp adj) - 500) * 100) + 175000);

# adjust to stat
	reward(value(trait, str adj));
	reward(value(trait, int adj));
	reward(value(trait, wis adj));
	reward(value(trait, dex adj));
	reward(value(trait, con adj));

# some extra attributes
	reward(value(trait, disarm ph) * 2);
	reward(value(trait, disarm mag) * 2);
	reward(value(trait, use device) * 25);
	reward(value(trait, save) * 25);
#  perfect save worth extra
	condition(value(trait, save) > 99): reward(10000);
	reward(value(trait, stealth) * 2);
	reward(value(trait, search));
	reward(value(trait, to hit normal) * 5);
	reward(value(trait, to hit bow) * 35);
	reward(value(trait, to hit throw) * 2);
	reward(value(trait, dig) * 2);

	condition(value(trait, slow dig)): reward(750);
	condition(value(trait, slow dig) and value(trait, is hungry)): reward(7500);
	condition(value(trait, slow dig) and value(trait, is weak)): reward(7500);

	condition((value(trait, max depth) < 20) and value(trait, feather fall)): reward(500);
	condition((value(trait, max depth) >= 20) and value(trait, feather fall)): reward(50);

	condition(value(trait, light)): reward(2000);
	condition(value(trait, esp) and value(trait, see inv)): reward(500);
	condition(!value(trait, detect inv) and value(trait, see inv)): reward(5000);
	condition(value(trait, free action)): reward(10000);

	condition((value(trait, max clevel) < 50) and value(trait, hold life)): reward(2000);
	condition((value(trait, max clevel) = 50) and value(trait, hold life)): reward(200);

	condition(value(trait, regen)): reward(2000);
	condition(value(trait, esp)): reward(80000);

# Immunity flags
	condition(value(trait, immune cold)): reward(65000);
	condition(value(trait, immune elec)): reward(40000);
	condition(value(trait, immune fire)): reward(80000);
	condition(value(trait, immune acid)): reward(50000);

# Resistance flags
	condition(value(trait, resist cold)): reward(3000);
	condition(value(trait, resist elec)): reward(4000);
	condition(value(trait, resist acid)): reward(6000);
	condition(value(trait, resist fire)): reward(8000);
# extra bonus for getting all basic resist
	condition(value(trait, resist cold) and value(trait, resist elec) and value(trait, resist fire) and value(trait, resist acid)): reward(10000);
	condition(value(trait, resist poison)): reward(20000);
	condition(value(trait, resist sound)): reward(3500);
	condition(value(trait, resist lite)): reward(800);
	condition(value(trait, resist dark)): reward(800);
	condition(value(trait, resist chaos)): reward(5000);
	condition(value(trait, resist conf)): reward(80000);
	condition(value(class, mage) and value(trait, resist conf)): reward(2000);
	condition(value(trait, resist dis)): reward(5000);
	condition(value(trait, resist shards)): reward(100);
	condition(value(trait, resist nexus)): reward(100);
	condition(value(trait, resist blind)): reward(5000);
	condition(value(trait, resist nether)): reward(5500);
	condition(value(trait, resist fear)): reward(2000);

# Sustain flags
	condition(value(trait, sust str)): reward(50);
	condition(value(trait, sust int)): reward(50);
	condition(value(trait, sust wis)): reward(50);
	condition(value(trait, sust con)): reward(50);
	condition(value(trait, sust dex)): reward(50);
	condition(value(trait, sust str) and value(trait, sust int) and value(trait, sust wis) and value(trait, sust con) and value(trait, sust dex)): reward(1000);

# "necessary" flags
	condition((value(trait, see inv) or value(trait, esp)) and (value(trait, max depth) >= 9)): reward(100000);
	condition(value(trait, free action) and (value(trait, max depth) >= 19)): reward(100000);
	condition(value(trait, resist fire) and (value(trait, max depth) >= 24)): reward(100000);
	condition(value(trait, resist poison) and (value(trait, max depth) >= 39)): reward(100000);
	condition(value(trait, resist elec) and (value(trait, max depth) >= 39)): reward(100000);
	condition(value(trait, resist acid) and (value(trait, max depth) >= 39)): reward(100000);
	condition(value(trait, resist cold) and (value(trait, max depth) >= 39)): reward(100000);
	condition(value(trait, hold life) and (value(trait, max clevel) < 50) and (value(trait, max depth) >= 45)): reward(100000);
	condition((value(trait, speed) >= 115) and (value(trait, max depth) >= 45)): reward(100000);
	condition((value(class, warrior) and (value(trait, speed) >= 140) and (value(trait, max depth) >= 79))): reward(100000);
	condition(value(trait, resist conf) and (value(trait, max depth) >= 45)): reward(100000);
	condition(value(trait, resist nether) and (value(trait, max depth) >= 49)): reward(55000);
	condition(value(trait, resist sound) and (value(trait, max depth) >= 49)): reward(100000);
	condition(value(trait, resist blind) and (value(trait, max depth) >= 55)): reward(100000);
	condition(value(trait, esp) and (value(trait, max depth) >= 55)): reward(100000);
	condition(value(trait, resist nether) and (value(trait, max depth) >= 59)): reward(55000);
	condition(value(trait, resist chaos) and (value(trait, max depth) >= 59)): reward(104000);
	condition(value(trait, resist dis) and (value(trait, max depth) >= 59)): reward(90000);
	condition((value(trait, speed) >= 120) and (value(trait, max depth) >= 59)): reward(100000);
	condition((value(trait, speed) >= 130) and (value(trait, max depth) >= 79)): reward(100000);
	condition(value(trait, resist nether) and (value(trait, max depth) >= 79)): reward(15000);
	condition(value(trait, resist dark) and (value(trait, max depth) >= 79)): reward(25000);

# ac
	condition(value(config, worships_ac) and (value(trait, armor) < 15)): reward(value(trait, armor) * 2500);
	condition(value(config, worships_ac) and (value(trait, armor) >= 15) and (value(trait, armor) < 75)): reward((value(trait, armor) * 2000) + 28250);
	condition(value(config, worships_ac) and (value(trait, armor) >= 75)): reward((value(trait, armor) * 1500) + 73750);
	condition(!value(config, worships_ac) and (value(trait, armor) < 15)): reward(value(trait, armor) * 2000);
	condition(!value(config, worships_ac) and (value(trait, armor) >= 15) and (value(trait, armor) < 75)): reward((value(trait, armor) * 500) + 28350);
	condition(!value(config, worships_ac) and (value(trait, armor) >= 75)): reward((value(trait, armor) * 100) + 73750);

# Penalize various flags
	condition(value(trait, aggravate)): reward(-800000);
	condition(value(trait, impair hp)): reward(-35000);
	condition(!value(class, warrior) and value(trait, impair hp)): reward(-15000);
	condition((value(class, mage) or value(class, priest) or value(class, druid) or value(class, necromancer)) and value(trait, impair hp)): reward(-15000);
	condition(value(trait, fear)): reward(-400000);
	condition(!value(class, mage) and value(trait, fear)): reward(-200000);
	condition(value(trait, drain xp)): reward(-400000);
	condition(value(trait, vuln fire)): reward(-30000);
	condition(value(trait, vuln elec)): reward(-30000);
	condition(value(trait, vuln acid)): reward(-30000);
	condition(value(trait, vuln cold)): reward(-30000);
	condition(value(trait, teleport)): reward(-100000);
	condition(value(trait, enveloping)): reward(-50000);
	condition(value(trait, irritation)): reward(-20000);
	condition(value(trait, curse poison)): reward(-10000);
	condition(value(trait, siren)): reward(-800000);
	condition(value(trait, hallucinate)): reward(-100000);
	condition(value(trait, paralysis)): reward(-800000);
	condition(value(trait, summon demon)): reward(-100000);
	condition(value(trait, summon dragon)): reward(-100000);
	condition(value(trait, summon undead)): reward(-100000);
	condition(value(trait, curse stone) and (value(trait, speed) >= 140)): reward(-10000);
	condition(value(trait, curse steel) and (value(trait, speed) >= 140)): reward(-10000);
	condition(value(trait, no teleport)): reward(-700000);
	condition(value(trait, treach wep)): reward(-100000);
	condition(value(trait, air swing)): reward(-10000);
	condition(value(trait, unknown curse)): reward(-9999999);

# something with multiple useful bonuses
	reward(value(trait, multi bonus) * 3000);

# wearing something that needs an ID
	reward(value(trait, worn need id) * 10000);

# activations. 
	condition(value(activation, illumination)): reward(500 * value(activation, illumination));
	condition(value(activation, mapping)): reward(550 * value(activation, mapping));
	condition(value(activation, clairvoyance)): reward(600 * value(activation, clairvoyance));
	condition(value(activation, fire_bolt)): reward(540 * value(activation, fire_bolt));
	condition(value(activation, cold_bolt)): reward(527 * value(activation, cold_bolt));
	condition(value(activation, elec_bolt)): reward(518 * value(activation, elec_bolt));
	condition(value(activation, acid_bolt)): reward(522 * value(activation, acid_bolt));
	condition(value(activation, mana_bolt)): reward(554 * value(activation, mana_bolt));
	condition(value(activation, stinking_cloud)): reward(524 * value(activation, stinking_cloud));
	condition(value(activation, cold_ball50)): reward(596 * value(activation, cold_ball50));
	condition(value(activation, cold_ball100)): reward(700 * value(activation, cold_ball100));
	condition(value(activation, fire_ball72)): reward(572 * value(activation, fire_ball72));
	condition(value(activation, cold_bolt2)): reward(554 * value(activation, cold_bolt2));
	condition(value(activation, fire_ball)): reward(644 * value(activation, fire_ball));
	condition(value(activation, dispel_evil)): reward((500 + (10 + (value(trait, clevel) *5)/ 2)) * value(activation, dispel_evil));
	condition(value(activation, detect_objects)): reward(10 * value(activation, detect_objects));
	condition(!value(class, mage) and value(activation, tele_other)): reward(1000 * value(activation, tele_other));
	condition(value(class, mage) and value(activation, tele_other)): reward(500 * value(activation, tele_other));
	condition(value(activation, drain_life1)): reward(590 * value(activation, drain_life1));
	condition(value(activation, drain_life2)): reward(620 * value(activation, drain_life2));
	condition(value(activation, berserker)): reward(500 * value(activation, berserker));
	condition(value(activation, loskill)): reward(700 * value(activation, loskill));
	condition(value(activation, arrow)): reward(700 * value(activation, arrow));
	condition((value(class, mage) or value(class, priest) or value(class, druid)) and value(activation, rem_fear_pois)): reward(500 * value(activation, rem_fear_pois));
	condition((!value(class, mage) and !value(class, priest) and !value(class, druid)) and value(activation, rem_fear_pois)): reward(700 * value(activation, rem_fear_pois));
	condition(value(activation, tele_phase)): reward(500 * value(activation, tele_phase));
	condition(value(activation, destroy_doors)): reward(50 * value(activation, destroy_doors));
	condition(value(activation, banishment)): reward(1000 * value(activation, banishment));
	condition(value(activation, resist_all)): reward(650 * value(activation, resist_all));
	condition(!value(class, mage) and value(activation, resist_all)): reward(25000 * value(activation, resist_all));
	condition(value(activation, sleepii)): reward(500 * value(activation, sleepii));
	condition(!value(class, druid) and !value(class, necromancer) and value(activation, sleepii)): reward(200 * value(activation, sleepii));
	condition(value(activation, recharge)): reward(500 * value(activation, recharge));
	condition(!value(class, mage) and !value(class, rogue) and value(activation, recharge)): reward(100 * value(activation, recharge));
	condition(value(activation, tele_long)): reward(300 * value(activation, tele_long));
	condition(value(activation, missile)): reward(507 * value(activation, missile));
	condition(value(activation, cure_temp)): reward(500 * value(activation, cure_temp));
	condition(value(activation, starlight2)): reward(145 * value(activation, starlight2));
# one ring
	condition(value(activation, bizarre)): reward(999999 * value(activation, bizarre));
	condition(value(activation, star_ball)): reward(800 * value(activation, star_ball));
	condition(value(activation, rage_bless_resist)): reward(650 * value(activation, rage_bless_resist));
	condition(!value(class, mage) and value(activation, rage_bless_resist)): reward(25000 * value(activation, rage_bless_resist));
	condition(value(activation, starlight)): reward(127 * value(activation, starlight));
	condition(value(activation, firebrand)): reward(500 * value(activation, firebrand));
	condition(value(activation, enlightenment)): reward(500 * value(activation, enlightenment));
	condition(value(activation, hero)): reward(500 * value(activation, hero));
	condition(value(activation, shero)): reward(500 * value(activation, shero));
	condition(value(activation, cure_paranoia)): reward(100 * value(activation, cure_paranoia));
	condition(value(activation, cure_mind)): reward(1000 * value(activation, cure_mind));
	condition(value(activation, cure_body)): reward(1000 * value(activation, cure_body));
	condition(value(activation, mon_slow)): reward(500 * value(activation, mon_slow));
	condition(value(activation, mon_confuse)): reward(500 * value(activation, mon_confuse));
	condition(value(activation, sleep_all)): reward(500 * value(activation, sleep_all));
	condition(value(activation, mon_scare)): reward(500 * value(activation, mon_scare));
	condition(value(activation, light_line)): reward(50 * value(activation, light_line));
	condition(value(activation, disable_traps)): reward(50 * value(activation, disable_traps));
	condition(value(activation, drain_life3)): reward(650 * value(activation, drain_life3));
	condition(value(activation, drain_life4)): reward(750 * value(activation, drain_life4));
	condition(value(activation, elec_ball)): reward(564 * value(activation, elec_ball));
	condition(value(activation, elec_ball2)): reward(750 * value(activation, elec_ball2));
	condition(value(activation, acid_bolt2)): reward(545 * value(activation, acid_bolt2));
	condition(value(activation, acid_bolt3)): reward(554 * value(activation, acid_bolt3));
	condition(value(activation, acid_ball)): reward(620 * value(activation, acid_ball));
	condition(value(activation, cold_ball160)): reward(660 * value(activation, cold_ball160));
	condition(value(activation, cold_ball2)): reward(700 * value(activation, cold_ball2));
	condition(value(activation, fire_ball2)): reward(620 * value(activation, fire_ball2));
	condition(value(activation, fire_ball200)): reward(700 * value(activation, fire_ball200));
	condition(value(activation, fire_bolt2)): reward(554 * value(activation, fire_bolt2));
	condition(value(activation, fire_bolt3)): reward(572 * value(activation, fire_bolt3));
	condition(value(activation, dispel_evil60)): reward(560 * value(activation, dispel_evil60));
	condition(value(activation, dispel_undead)): reward(560 * value(activation, dispel_undead));
	condition(value(activation, dispel_all)): reward(620 * value(activation, dispel_all));
	condition(value(activation, earthquakes)): reward(500 * value(activation, earthquakes));
	condition(value(activation, destruction2)): reward(500 * value(activation, destruction2));
	condition(value(activation, losslow)): reward(50 * value(activation, losslow));
	condition(value(activation, lossleep)): reward(100 * value(activation, lossleep));
	condition(value(activation, losconf)): reward(100 * value(activation, losconf));
	condition(value(activation, satisfy)): reward(50 * value(activation, satisfy));
	condition(value(activation, blessing)): reward(50 * value(activation, blessing));
	condition(value(activation, blessing2)): reward(50 * value(activation, blessing2));
	condition(value(activation, blessing3)): reward(50 * value(activation, blessing3));
	condition(value(activation, tele_level)): reward(5000 * value(activation, tele_level));
	condition(value(activation, remove_curse)): reward(9000 * value(activation, remove_curse));
	condition(value(activation, remove_curse2)): reward(10000 * value(activation, remove_curse2));
	condition(value(activation, detect_invis)): reward(50 * value(activation, detect_invis));
	condition(value(activation, detect_evil)): reward(50 * value(activation, detect_evil));
	condition(value(activation, restore_mana)): reward(5000 * value(activation, restore_mana));
	condition(value(activation, restore_int)): reward(50 * value(activation, restore_int));
	condition(value(activation, restore_wis)): reward(50 * value(activation, restore_wis));
	condition(value(activation, restore_dex)): reward(50 * value(activation, restore_dex));
	condition(value(activation, restore_con)): reward(50 * value(activation, restore_con));
	condition(value(activation, restore_all)): reward(150 * value(activation, restore_all));
	condition(value(activation, tmd_sinvis)): reward(50 * value(activation, tmd_sinvis));
	condition(value(activation, tmd_esp)): reward(50 * value(activation, tmd_esp));
	condition(value(activation, resist_acid)): reward(100 * value(activation, resist_acid));
	condition(value(activation, resist_elec)): reward(100 * value(activation, resist_elec));
	condition(value(activation, resist_fire)): reward(100 * value(activation, resist_fire));
	condition(value(activation, resist_cold)): reward(100 * value(activation, resist_cold));
	condition(value(activation, resist_pois)): reward(150 * value(activation, resist_pois));
	condition(value(activation, cure_confusion)): reward(50 * value(activation, cure_confusion));
	condition(value(activation, wonder)): reward(300 * value(activation, wonder));
	condition(value(activation, staff_holy)): reward(1000 * value(activation, staff_holy));
	condition(value(activation, food_waybread)): reward(50 * value(activation, food_waybread));
	condition(value(activation, shroom_stone)): reward(50 * value(activation, shroom_stone));
	condition(value(activation, shroom_purging)): reward(50 * value(activation, shroom_purging));
	condition(value(activation, ring_acid)): reward(10000 * value(activation, ring_acid));
	condition(value(activation, ring_flames)): reward(25000 * value(activation, ring_flames));
	condition(value(activation, ring_ice)): reward(15000 * value(activation, ring_ice));
	condition(value(activation, ring_lightning)): reward(10000 * value(activation, ring_lightning));
	condition(value(activation, dragon_blue)): reward(1100 * value(activation, dragon_blue));
	condition(value(activation, dragon_green)): reward(2750 * value(activation, dragon_green));
	condition(value(activation, dragon_red)): reward(1100 * value(activation, dragon_red));
	condition(value(activation, dragon_multihued)): reward(3250 * value(activation, dragon_multihued));
	condition(value(activation, dragon_gold)): reward(5150 * value(activation, dragon_gold));
	condition(value(activation, dragon_chaos)): reward(5150 * value(activation, dragon_chaos));
	condition(value(activation, dragon_law)): reward(5150 * value(activation, dragon_law));
	condition(value(activation, dragon_balance)): reward(5150 * value(activation, dragon_balance));
	condition(value(activation, dragon_shining)): reward(5150 * value(activation, dragon_shining));
	condition(value(activation, dragon_power)): reward(5150 * value(activation, dragon_power));

########################


# inventory 
# fuel
	value(trait, fuel): range(1, 6): reward(60000);
	value(trait, fuel): range(7, 10): condition(value(trait, str) >= 15): reward(6000 - (value(range, n) *100));
# food
	condition(value(trait, food) and (value(trait, is hungry) or value(trait, is weak))): reward(100000);
	value(trait, food): range(1, 7): reward(50000);
	value(trait, food): range(8, 10): condition(value(trait, str) >= 15): reward(200);
	value(trait, food): range(1, 15): condition(value(trait, regen) and value(trait, CLEVEL) <= 15): reward(700);
# Prefer to buy HiCalorie foods over LowCalorie
	value(trait, food high): range(1, 7): reward(52);
	value(trait, food low): range(1, 15): reward(-2);

# Cure Poison and Cuts
	condition(value(trait, amt potion ccw) and (value(trait, is cut) or value(trait, is poisoned))): reward(100000);
	condition(value(trait, amt heal) and (value(trait, is cut) or value(trait, is poisoned))): reward(50000);
	value(trait, amt potion csw): range(1, 5): condition(value(trait, is cut) or value(trait, is poisoned)): reward(25000);

	condition(value(trait, is poisoned) and value(trait, amt cure poison)): reward(15000);

# collect Resistance pots if not immune
	value(trait, amt resist poison): range(1, 4): condition(!value(trait, immune poison) and value(trait, amt cure poison) < 20 and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(300);

# Resistance Potions for Warriors
	value(trait, amt resist heat): range(1, 4): condition((value(class, warrior) and !value(trait, immune fire) and value(trait, max depth) > 20) and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(500);
	value(trait, amt resist cold): range(1, 4): condition((value(class, warrior) and !value(trait, immune cold) and value(trait, max depth) > 20) and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(500);
	value(trait, amt resist poison): range(1, 4): condition((value(class, warrior) and !value(trait, immune poison) and value(trait, max depth) > 20) and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(500);

# ident
	value(trait, amt id): range(1, 5): condition(value(trait, clevel) >= 10): reward(6000);
	value(trait, amt id): range(6, 15): condition(value(trait, clevel) >= 10): reward(600);

# ID if I am carrying a {magical} or {excellent} item
	value(trait, amt need id): range(1, 20): condition(value(trait, amt need id) and value(trait, amt need id) <= value(trait, amt id)): reward(6000);
	value(trait, amt id): range(1, 20): condition(value(trait, amt need id) and value(trait, amt need id) > value(trait, amt id)): reward(6000);

# PFE carry lots of these
	value(trait, amt prot evil): range(1, 10): condition(!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level)): reward(10000);
	value(trait, amt prot evil): range(11, 25): condition(!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level)): reward(2000);

# Glyph- Rune of Protection-  carry lots of these
	value(trait, amt glyph): range(1, 10): reward(10000);
	value(trait, amt glyph): range(11, 25): reward(2000);
	value(trait, amt glyph): range(1, 10): condition(value(trait, max depth) >= 100): reward(10000);
	value(trait, amt glyph): range(11, 75): condition(value(trait, max depth) >= 100): reward(2000);

# Scroll of Mass Genocide, only when fighting Morgoth
	value(trait, mass banishment): range(1, 99): condition(value(trait, max depth) >= 100): reward(2500);

# recall
	value(trait, recall): range(1, 3): condition(value(trait, clevel) > 7 and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(50000);
	value(trait, recall): range(4, 7): condition(value(trait, clevel) > 7 and value(trait, str) >= 15 and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(5000);

# Deep borgs need the rod to avoid low mana traps
	condition(value(trait, max depth) >= 50 and value(rod, recall)): reward(12000);

# phase
	condition(value(trait, amt phase)): reward(50000);
	value(trait, amt phase): range(2, 8): condition(!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level)): reward(500);
	value(trait, amt phase): range(9, 15): condition(value(trait, str) >= 15 and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(500);

# escape (staff of teleport or artifact)
	value(trait, amt escape): range(1, 2): condition(!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level)): reward(10000);
	value(trait, amt escape): range(1, 3): condition(value(trait, max depth) > 70 and (!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level))): reward(10000);

# teleport scrolls
	condition(value(trait, amt teleport) and value(trait, clevel) >= 3): reward(10000);
	value(trait, amt teleport): range(1, 3): condition(value(trait, clevel) >= 7): reward(10000);
	value(trait, amt teleport): range(4, 10): condition(value(trait, clevel) >= 30): reward(10000);

# Teleport Level scrolls 
	value(trait, amt teleport level): range(1, 5): condition(value(trait, clevel) >= 15): reward(5000);

# Healing 
	value(trait, amt heal): range(1, 15): condition(value(class, warrior) or value(class, rogue) or value(class, blackguard)): reward(8000);
# These guys need to carry the rods more, town runs low on supply.
	value(rod, healing): range(1, 6): condition(value(class, warrior) or value(class, rogue) or value(class, blackguard)): reward(20000);

	value(trait, amt heal): range(1, 10): condition(value(class, ranger) or value(class, paladin) or value(class, necromancer) or value(class, mage)): reward(4000);

	value(potion, healing): range(1, 3): condition(value(class, paladin)): reward(5000);
	value(rod, healing): range(1, 4): condition(value(class, ranger) or value(class, paladin) or value(class, necromancer) or value(class, mage)): reward(20000);

# Level 1 priests are given a Potion of Healing. It is better for them to sell that potion and buy equipment or several Cure Crits with it.
	value(potion, healing): range(1, 10): condition((value(class, druid) or value(class, priest)) and value(trait, clevel) = 1): reward(-2000);
	value(potion, healing): range(1, 5): condition(value(class, druid) or value(class, priest)): reward(2000);

	value(trait, amt ezheal): range(1, 2): condition(value(trait, max depth) >= 46 and !value(trait, prep big fight)): reward(10000);
	value(trait, amt ezheal): range(1, 1): condition(value(trait, max depth) >= 46 and value(trait, prep big fight)): reward(10000);

# Collecting Potions, prepping for Morgoth/Sauron fight
	value(potion, healing): range(1, 99): condition(value(trait, max depth) >= 99 and !value(trait, prep big fight)): reward(8000);
	value(trait, amt ezheal): range(1, 99): condition(value(trait, max depth) >= 99 and !value(trait, prep big fight)): reward(10000);
	value(trait, amt speed): range(1, 99): condition(value(trait, max depth) >= 99 and !value(trait, prep big fight)): reward(8000);
	value(trait, amt life): range(1, 99): condition(value(trait, max depth) >= 99 and !value(trait, prep big fight)): reward(10000);
	value(potion, restore mana): range(1, 99): condition(value(trait, max depth) >= 99  and !value(trait, prep big fight) and !value(class, warrior)): reward(5000);
	value(mushroom, stoneskin): range(1, 40): condition(value(trait, max depth) >= 99 and !value(trait, prep big fight)): reward(5000);
# Scroll of Mass Genocide, only when fighting Morgoth
	value(trait, mass banishment): range(1, 40): condition(value(trait, max depth) >= 99 and value(trait, sauron dead) and !value(trait, prep big fight)): reward(2500);

# Restore Mana
	value(potion, restore mana): range(1, 10): condition(value(trait, max sp) > 100): reward(4000);
	value(trait, amt staff magi): range(1, 100): condition(value(trait, max sp) > 100): reward(4000);

# Cure Critical
	value(trait, amt potion ccw): range(1, 10): condition(value(trait, clevel) < 35 and value(trait, clevel) > 10): reward(5000);
	value(trait, amt potion ccw): range(1, 10): condition(value(trait, clevel) >= 35): reward(5000);
	value(trait, amt potion ccw): range(11, 15): condition(value(trait, clevel) >= 35 and value(trait, str) > 15): reward(500);

# Cure serious
	value(trait, amt potion csw): range(1, 7): condition(value(trait, clevel) < 35 and value(trait, clevel) > 10 and value(trait, amt potion ccw) < 5 and !value(trait, resist conf)): reward(50);
	value(trait, amt potion csw): range(8, 10): condition(value(trait, clevel) < 35 and value(trait, clevel) > 10 and value(trait, amt potion ccw) < 5 and !value(trait, resist conf) and value(trait, str) > 15): reward(5);

# Cure light 
	value(trait, amt potion clw): range(1, 5): condition((value(trait, amt potion ccw) + value(trait, amt potion csw)) < 5 and value(trait, clevel) < 10): reward(550);

# Cures
	value(trait, food cure conf): range(1, 10): condition(!value(trait, resist conf) and (!value(config, munchkin_start) or value(trait, max clevel) >= 10)): reward(400);
	value(trait, food cure blind): range(1, 10): condition(!value(trait, resist blind) and (!value(config, munchkin_start) or value(trait, max clevel) >= 10)): reward(300);
	value(trait, amt cure poison): range(1, 5): condition(!value(trait, resist poison) and (!value(config, munchkin_start) or value(trait, max clevel) >= 10)): reward(250);

# detect
	value(trait, amt detect traps): range(1, 1): reward(4000);
	value(trait, amt detect door): range(1, 1): reward(2000);

# detect evil 
	value(trait, amt detect evil): range(1, 1): condition(!value(trait, esp)): reward(1000);

# magic map
	value(trait, amt magic map): range(1, 1): reward(4000);

# call lite
	value(trait, amt call lite): condition(!value(class, necromancer)): range(1, 1): reward(1000);

# genocide
	value(scroll, mass banishment): range(1, 10): condition(value(trait, max depth) >= 100): reward(10000);
	value(scroll, mass banishment): range(11, 25): condition(value(trait, max depth) >= 100): reward(2000);

# speed potions/rods/staves
	value(trait, amt speed): range(1, 20): condition(!value(config, munchkin_start) or value(trait, max clevel) >= value(config, munchkin_level)): reward(5000);

# Recharge ability
	condition(value(trait, amt recharge) and value(trait, max depth) < 99): reward(5000);

# missles
	value(trait, amt missiles): range(1, 40): condition(value(class, warrior) or value(class, ranger)): reward(100);
	value(trait, amt missiles): range(41, 80): condition((value(class, warrior) or value(class, ranger)) and value(trait, str) > 15 and value(trait, str) <= 18): reward(10);
	value(trait, amt missiles): range(81, 180): condition((value(class, warrior) or value(class, ranger)) and value(trait, str) > 18): reward(8);
	value(trait, quiver slots): range(5, 10): condition(value(class, warrior) or value(class, ranger)): reward(-10000);

	value(trait, amt missiles): range(1, 20): condition(!value(class, warrior) and !value(class, ranger)): reward(100);
	value(trait, amt missiles): range(21, 50): condition((!value(class, warrior) and !value(class, ranger)) and value(trait, str) > 15): reward(10);
	condition((!value(class, warrior) and !value(class, ranger)) and value(trait, str) <= 15 and value(trait, amt missiles) > 20): reward(-1000);
	value(trait, quiver slots): range(3, 10): condition(!value(class, warrior) and !value(class, ranger)): reward(-10000);

#  cursed arrows are "bad"
	reward(value(trait, amt cursed missiles) * -1000);

# ego arrows are worth a bonus
	reward(value(trait, amt ego missiles) * 100);

# carrying a staff of destruction
	condition(value(trait, amt staff destruction)): reward(5000);
	value(trait, amt staff destruction): range(1, 9): reward(200);

# carrying a wand of Teleport Other
	condition(value(trait, amt teleport other)): reward(5000);
# greater reward for Warrior
	condition(value(trait, amt teleport other) and value(class, warrior)): reward(50000);
	value(trait, amt teleport other): range(1, 15): reward(5000);

# carrying an attack wand
	condition((value(wand, magic missile) or value(wand, stinking cloud)) and (value(trait, max depth) < 30)): reward(5000);
	condition(value(wand, annihilation) and (value(trait, max depth) < 30)): reward(5000);
# Much greater reward for Warrior or lower level
	condition((value(wand, annihilation) or value(wand, magic missile) or value(wand, stinking cloud)) and ((value(trait, clevel) <= 20) or value(class, warrior))): reward(10000);
	reward(value(trait, amt good wand chg) * 50);

# These staves are great but do not clutter inven with them
#  -- Reward carrying a staff of holiness/power
	condition(value(trait, amt good staff chg)): reward(2500);
	value(trait, amt good staff chg): range(1, 3): reward(500);

# Rods of attacking are good too
#   bolt rods 
	value(trait, amt attack rods1): range(1, 6): reward(8000);
#   ball rods & drain life
	value(trait, amt attack rods2): range(1, 6): reward(12000);

# Reward being at max stat
	condition(value(trait, cur str) >= 118): reward(50000);
	condition(value(trait, cur int) >= 118): reward(20000);
	condition(value(trait, cur wis) >= 118): reward(20000);
	condition(value(trait, cur dex) >= 118): reward(50000);
	condition(value(trait, cur con) >= 118): reward(50000);

	condition(value(trait, cur int) >= 118 and (value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue))): reward(50000);
	condition(value(trait, cur wis) >= 118 and (value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin))): reward(50000);

# Reward stat potions
	condition((value(potion, strength) + value(potion, augmentation)) and value(trait, cur str) < 118): reward(550000);
	condition((value(potion, intelligence) + value(potion, augmentation)) and value(trait, cur int) < 118): reward(520000);
	condition((value(potion, intelligence) + value(potion, augmentation)) and value(trait, cur int) < 118 and (value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue))): reward(575000);
	condition((value(potion, wisdom) + value(potion, augmentation)) and value(trait, cur wis) < 118): reward(520000);
	condition((value(potion, wisdom) + value(potion, augmentation)) and value(trait, cur wis) < 118 and (value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin))): reward(575000);
	condition((value(potion, dexterity) + value(potion, augmentation)) and value(trait, cur dex) < 118): reward(550000);
	condition((value(potion, constitution) + value(potion, augmentation)) and value(trait, cur con) < 118): reward(550000);

# Remove Curse 
	condition(value(trait, first cursed) and value(scroll, *remove curse*)): reward(90000);
	condition(value(trait, first cursed) and value(scroll, remove curse)): reward(90000);

# Restore experience
	condition(value(trait, has fixexp) ): reward(50000);

# Enchantment
	condition((value(trait, amt ench to armor) < 1000) and value(trait, need ench to armor)): reward(540);
	condition((value(trait, amt ench to hit) < 1000) and value(trait, need ench to hit)): reward(540);
	condition((value(trait, amt ench to dam) < 1000) and value(trait, need ench to dam)): reward(500);
	condition(value(trait, amt *ench to wep*)): reward(5000);
	condition(value(trait, amt *ench to armor*)): reward(5000);

#   empty slots (2 to 6) 
	value(trait, empty slots): range(2, 6): reward(40);
#   empty slots: first one counts extra 
	value(trait, empty slots): reward(4000);
]

Depth Requirement
[
	depth(1): condition(value(trait, fuel) < 5 and !value(trait, light));
	depth(1): condition(value(trait, food) < 5);

# go no deeper than your char level
# special hack using "range" as "depth being checked"
	depth(2): condition(value(trait, max clevel) < value(range, n) and value(trait, max clevel) < 50);
	depth(2): condition(value(range, n) >= value(config, no_deeper));

	depth(2): condition(value(trait, max hp) < 30 and !value(config, plays_risky));

	depth(3): condition((value(class, warrior) or value(class, blackguard)) and value(trait, max hp) < 50 and !value(config, plays_risky));
	depth(3): condition((value(class, warrior) or value(class, blackguard)) and value(trait, max clevel) < 4 and !value(config, plays_risky));
	depth(3): condition(value(class, rogue) and value(trait, max hp) < 50 and !value(config, plays_risky));
	depth(3): condition(value(class, rogue) and value(trait, max clevel) < 8 and !value(config, plays_risky));
	depth(3): condition((value(class, priest) or value(class, druid)) and value(trait, max hp) < 40 and !value(config, plays_risky));
	depth(3): condition((value(class, priest) or value(class, druid)) and value(trait, max clevel) < 9 and !value(config, plays_risky));
	depth(3): condition((value(class, paladin) or value(class, ranger)) and value(trait, max hp) < 50 and !value(config, plays_risky));
	depth(3): condition((value(class, paladin) or value(class, ranger)) and value(trait, max clevel) < 4 and !value(config, plays_risky));
	depth(3): condition((value(class, mage) or value(class, necromancer)) and value(trait, max hp) < 60 and !value(config, plays_risky));
	depth(3): condition((value(class, mage) or value(class, necromancer)) and value(trait, max clevel) < 11 and !value(config, plays_risky));

	depth(3): condition(value(trait, max clevel) < 30 and (value(trait,  amt potion clw) + value(trait,  amt potion csw) + value(trait,  amt potion ccw)) < 2);

	depth(5): condition((value(class, warrior) or value(class, blackguard)) and value(trait, max hp) < 60 and !value(config, plays_risky));
	depth(5): condition((value(class, warrior) or value(class, blackguard)) and value(trait, max clevel) < 6 and !value(config, plays_risky));
	depth(5): condition(value(class, rogue) and value(trait, max hp) < 60 and !value(config, plays_risky));
	depth(5): condition(value(class, rogue) and value(trait, max clevel) < 10 and !value(config, plays_risky));
	depth(5): condition((value(class, priest) or value(class, druid)) and value(trait, max hp) < 60 and !value(config, plays_risky));
	depth(5): condition((value(class, priest) or value(class, druid)) and value(trait, max clevel) < 15 and !value(config, plays_risky));
	depth(5): condition((value(class, paladin) or value(class, ranger)) and value(trait, max hp) < 60 and !value(config, plays_risky));
	depth(5): condition((value(class, paladin) or value(class, ranger)) and value(trait, max clevel) < 6 and !value(config, plays_risky));
	depth(5): condition((value(class, mage) or value(class, necromancer)) and value(trait, max hp) < 80 and !value(config, plays_risky));
	depth(5): condition((value(class, mage) or value(class, necromancer)) and value(trait, max clevel) < 15 and !value(config, plays_risky));

	depth(5): condition(value(trait, recall) < 1);

# skipping these because they seem redundant given the "go no deeper than your char level" check earlier
#	depth(10): condition((value(class, warrior) or value(class, blackguard)) and value(trait, max clevel) < (value(range, n) - 4) and value(range, n) <= 19 and !value(config, plays_risky));
#	depth(10): condition(value(class, rogue) and value(trait, max clevel) < value(range, n) and value(range, n) <= 19 and !value(config, plays_risky));
#	depth(10): condition((value(class, priest) or value(class, druid)) and value(trait, max clevel) < value(range, n) and value(range, n) <= 19 and !value(config, plays_risky));
#	depth(10): condition((value(class, paladin) or value(class, ranger)) and value(trait, max clevel) < value(range, n) and value(range, n) <= 19 and !value(config, plays_risky));
	depth(10): condition((value(class, mage) or value(class, necromancer)) and value(trait, max clevel) < value(range, n) + 4 and value(range, n) <= 19 and !value(config, plays_risky));

	depth(10): condition(value(trait, max clevel) < 30 and value(trait,  amt potion ccw) < 3);
	depth(10): condition(!value(trait, see inv) and !value(trait, detect inv) and !value(trait, esp));

	depth(20): condition(!value(trait, free action));

	depth(21): condition(!value(trait, resist fire));
	depth(21): condition((value(trait, resist acid) + value(trait, resist cold) + value(trait, resist elec)) < 2);

	depth(21): condition(value(trait, cur str) < 7);
	depth(21): condition((value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin)) and value(trait, cur wis) < 7);
	depth(21): condition((value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue)) and value(trait, cur int) < 7);
	depth(21): condition(value(trait, cur dex) < 7);
	depth(21): condition(value(trait, cur con) < 7);

# skipping these because they seem redundant given the "go no deeper than your char level" check earlier
#	depth(21): condition((value(class, warrior) or value(class, blackguard)) and value(trait, max clevel) < (value(range, n) - 5) and value(trait, max clevel) <= 38 and !value(config, plays_risky));
#	depth(21): condition(value(class, rogue) and value(trait, max clevel) < value(range, n) + 10 and value(trait, max clevel) <= 46 and !value(config, plays_risky));
#	depth(21): condition((value(class, priest) or value(class, druid)) and value(trait, max clevel) < value(range, n) + 13 and value(trait, max clevel) <= 46 and !value(config, plays_risky));
#	depth(21): condition(value(class, paladin) and value(trait, max clevel) < value(range, n) + 7 and value(trait, max clevel) <= 40 and !value(config, plays_risky));
#	depth(21): condition(value(class, ranger) and value(trait, max clevel) < value(range, n) + 8 and value(trait, max clevel) <= 41 and value(trait, max clevel) > 28 and !value(config, plays_risky));
#	depth(21): condition((value(class, mage) or value(class, necromancer)) and value(trait, max clevel) < value(range, n) + 8 and value(trait, max clevel) <= 38 and !value(config, plays_risky));
#	depth(21): condition((value(class, mage) or value(class, necromancer)) and ((value(trait, max clevel) - 38) * 2 + 30) < value(range, n) and value(trait, max clevel) <= 44 and value(trait, max clevel) > 38 and !value(config, plays_risky));

	depth(26): condition(!value(trait, resist cold with swap));
	depth(26): condition(!value(trait, resist elec with swap));
	depth(26): condition(!value(trait, resist acid with swap));
	depth(26): condition((value(trait,  amt teleport) + value(trait,  amt escape)) < 6);
	depth(26): condition(value(trait, max clevel) < 30 and (value(trait,  amt potion csw) + value(trait,  amt potion ccw)) < 10);

# skipping again redundant given the "go no deeper than your char level" check earlier
#	depth(34): condition(value(trait, max clevel) < 40 and !value(config, plays_risky));

	depth(40): condition(!value(trait, resist poison with swap));
	depth(40): condition(!value(trait, resist conf with swap));
	depth(40): condition(value(trait, str) < 16);
	depth(40): condition((value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin)) and value(trait, wis) < 16);
	depth(40): condition((value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue)) and value(trait, int) < 16);
	depth(40): condition(value(trait, dex) < 16);
	depth(40): condition(value(trait, con) < 16);

	depth(46): condition(value(trait, speed) < 115);
	depth(46): condition(value(trait, amt heal) < 1 and value(trait, amt ezheal) < 1);
	depth(46): condition(value(trait, max hp) < 500 and !value(config, plays_risky));
	depth(46): condition(value(trait, str) < (18+40));
	depth(46): condition((value(class, priest) or value(class, druid) or value(class, ranger) or value(class, paladin)) and value(trait, wis) < 18+100);
	depth(46): condition((value(class, mage) or value(class, necromancer) or value(class, blackguard) or value(class, rogue)) and value(trait, int) < 18+100);
	depth(46): condition(value(trait, dex) < (18+60));
	depth(46): condition(value(trait, con) < (18+60));
	depth(46): condition(!value(trait, hold life with swap) and value(trait, max clevel) < 50);

	depth(56): condition(value(trait, amt heal) < 2 and value(trait, amt ezheal) < 1);
	depth(56): condition(!value(trait, resist blind with swap));
#	depth(56): condition(!value(trait, resist nether with swap) and !value(config, plays_risky));
	depth(56): condition(!value(trait, esp));

	depth(60): condition(value(trait, speed) < 120);
	depth(60): condition(!value(trait, resist chaos with swap));
	depth(60): condition(!value(trait, resist dis with swap));

	depth(81): condition(value(trait, speed) < 130);

# going after morgoth
	depth(100): condition(!value(trait, king) and (value(potion, restore mana) < 15));
	depth(100): condition(!value(trait, king) and (value(potion, healing) < 5));
	depth(100): condition(!value(trait, king) and (value(potion, *healing*) + value(potion, life)) < 15);
	depth(100): condition(!value(trait, king) and (value(potion, speed) < 10));
]

Restock Requirement
[
	depth(1): condition(value(trait, light) < 1);
	depth(1): condition(value(trait, fuel) < 1 and !value(trait, light));

	depth(2): condition(value(trait, fuel) < 2 and !value(trait, light));
	depth(2): condition(value(trait, food) < 3);

	depth(6): condition(value(trait, amt phase) < 1);
	depth(6): condition(value(trait, max clevel) < 30 and (value(trait,  amt potion clw) + value(trait,  amt potion csw) + value(trait,  amt potion ccw)) < 1);

	depth(10): condition(value(trait, light) < 2 and !value(class, necromancer));
	depth(10): condition(value(trait, max clevel) < 30 and (value(trait,  amt potion clw) + value(trait,  amt potion csw) + value(trait,  amt potion ccw)) < 2);
	depth(10): condition((value(trait,  amt teleport) + value(trait,  amt escape)) < 2);

	depth(20): condition(value(trait, max clevel) < 30 and (value(trait,  amt potion csw) + value(trait,  amt potion ccw)) < 4);
	depth(20): condition((value(trait,  amt teleport) + value(trait,  amt escape)) < 4);

	depth(36): condition((value(trait,  amt teleport) + value(trait,  amt teleport level)) < 2);

	depth(65): condition((value(trait,  amt heal) + value(trait,  amt ezheal) + value(rod,  healing)) < 1);

# !FIX there is a "borg_t - borg_began < 10" but 10 steps is hardly anything so ... ignoring for now
	depth(100): condition(value(trait,  amt ezheal) + (value(trait,  amt life)) < 15);
]

[END FORMULA SECTION]
