Coolmaster
Member
- Joined
- Aug 16, 2013
- Messages
- 709
Under test
What is a Rule?
The Rules is a simple mechanism for interacting with the bot through which you can easily change the bot's behavior and play by own rules.
Should not simultaneously create a lot of rules - you can get unexpected results from the combination of the rules and you will be hard to find the cause of strange behavior.
Rules should be created step by step. Sometimes it is enough to create only a few rules that would radically change the style of playing. AI will do all the work, you should just slightly specify the correct direction.
One Rule is a single line consisting of several parameters (conditions) and a bonus.
- The bonus can be positive and negative.
- The more positive bonus, the higher chance that this option will be played.
- The less negative bonus, the less chance that this scenario will be chosen (remember that -100 is less than -10).
The rule looks like:
condition,bonus=X
(where X is any number)
Conditions can be connected to each other within one rule:
& - And (condition1&condition2,bonus=X - playfield gets this bonus if only the condition 1 AND condition 2 are true);
|| - Or (condition1||condition2,bonus=X - playfield gets this bonus if the condition 1 is true OR condition 2 is true);
You can connect as many conditions as you wish (no spaces or any extra characters between conditions).
Example: cond_1&cond_2||cond_3||cond_4&cond_5,bonus=10 - true(gets bonus) if condition_1 = true And (condition 2 or 3 or 4) = true And condition_5 = true;
There are 3 types of rules:
1. Board state rule (including cards in your hand and minions on board)
2. Play card rule.
3. Attack rule.
You can mix these rules.
There are 3 types of comparison within one condition:
1. Comparison with a number.
[hide]
Comparison operators (=, !=, >, <) !ONLY NUMERIC VALUE!
(= - equal, != - not equal, > - greater than, < - less than)
tm - turn mana (default mana at this turn);
am - available mana (at this turn);
t - turn;
overload - overload, which can cause a card in the current round;
ohhp - own hero health points;
ehhp - enemy hero health points;
owa - own weapon attack;
ewa - enemy weapon attack;
owd - own weapon durability;
ewd - enemy weapon durability;
occ - own cards count (the number of cards in own hand);
ecc - enemy cards count (the number of cards in enemy's hand);
omc - own minions count (the number of own minions on the board);
emc - enemy minions count (the number of enemy minions on the board);
For "omc" and "emc" you can use these extensions:
:Murlocs (the number own/enemy Murlocs on the board)
:Demons (the number own/enemy Demons on the board)
:Mechs (the number own/enemy Mechs on the board)
:Beasts (the number own/enemy Beasts on the board)
:Totems (the number own/enemy Totems on the board)
:Pirates (the number own/enemy Pirates on the board)
:Dragons (the number own/enemy Dragons on the board)
:SHR (the number own/enemy Silver Hand Recruits on the board)
:undamaged (the number undamaged own/enemy minions on the board)
:damaged (the number damaged own/enemy minions on the board)
:shields (the number own/enemy shields on the board)
:taunts (the number own/enemy taunts on the board)
Also you can compare "omc" and "emc"
Example:
omc>3 - means that you must have more than 3 minions on the board
omc:Murlocs>3 - means that you must have more than 3 murlocs on the board
omc>emc - means that you must have more minions than your opponent
[/hide]
2. Logical comparison.[hide]
Boolean operators (=, !=)
(= - equal/contain; != - not equal/does't contain)
ob - own board (own board must/must not contain this minion (CardID));
eb - enemy board (enemy board must/must not contain this minion (CardID));
oh - own hand (own hand must/must not contain this card (CardID));
ow - own weapon (CardID);
ew - enemy weapon (CardID);
ohero - own hero class (ALL, DRUID, HUNTER, MAGE, PALADIN, PRIEST, ROGUE, SHAMAN, WARLOCK, WARRIOR);
ehero - enemy hero class;
[/hide]
3. Unique.
[hide]
Unique:
coin - must be a coin in hand at turn start;
!coin - must not be a coin in hand at turn start;
noduplicates - if your deck contain no duplicates
p= - play - card in hand that must be played (CardID);
p2= - play 2 identical cards - 2 identical card in hand that must be played (CardID);
a= - attacker - minion on board (CardID);
[/hide]
Examples:
* Don't allow the enemy to have more than 2 Murloc on the board (if the enemy has more than 2 Murlocs on the board, give a small negative bonus):
emc:Murlocs>2,bonus=-5
* If we have own minion with Divine Shield on the board and Flametongue Totem (EX1_565) in hand, give a small positive bonus (for example if there a choice between 2 minions to play, the priority will have a minion with Divine Shield)
omc:shields>0&oh=EX1_565,bonus=2
* If we want to play Doomhammer (EX1_567) on turn 4 (with coin) we must be not overloaded in turn 3.
The rule read as: if at the end of the turn 3 we have overload (we played a card with overload) and (we play coin or we have coin in own hand) and we have Doomhammer in own hand, then completely forbids this action (big negative bonus)):
t=3&overload>0&p=coin||oh=coin&oh=EX1_567,bonus=-600
With conditions "play a card" (p=) or "attack" (a=) you can use additional rules and additional penalties if these conditions were broken.
[hide]
For "p=" and "p2=" and "a=" you can use these extensions:
:pen= (after CardID) - penalty for playing/attacking this card outside of this rule;
:tgt= - target - target for spell or for minion/weapon (CardID/hero/!hero);
If a minion/hero/spell has a target, you can use comparison operators ( =, !=, >, < !ONLY NUMERIC VALUE!) for these parameters:
:aAt - attacker's attack (mob/hero)
:aHp - attacker's health points
:tAt - target's attack
:tHp - target's health points
[/hide]
* If own Grommash Hellscream (EX1_414) have attack=4 and attacks enemy minion (target not hero) and target's hp<5 then give a small positive bonus (if attack condition is broken, give a small penality).
a=EX1_414:aAt=4:tgt=!hero:tHp<5:pen=2,bonus=3
Consider a combination of rules.
Board:
OwnHero HP = 25, No cards, Own Minion: 1)HP=5, Attack=4, Windfury (Windfury Harpy, EX1_033)
EnemyHero HP = 18, No cards, EnemyMinions: 1)Attack=3, HP=2 2)Attack=2, HP=3
Rules: (_rules.txt)
//negative bonus if Windfury Harpy attacks minions with low HP
a=EX1_033:tgt!=hero:tHp<3:pen=13,bonus=-7
//positive bonus if we have at least one minion on the board
omc>0,bonus=5
Possible actions and their bonuses:
1) 1x attack enemy hero: -13(the rule isn't broken, but additional condition tgt!=hero is broken, pen=13) + 5(omc>0 bonus) = -8
2) Attack 2/3: -13(tHp<3 broken pen=13) + 5(omc>0 bonus) = -8
3) Attack 3/2: -7(bonus) + 5(omc>0 bonus) = -2
4) 2x attack enemy hero: -13(tgt!=hero broken pen=13) + -13(tgt!=hero broken pen=13) + 5(omc>0 bonus) = -21
5) Attack enemy hero + attack 2/3: -13(tgt!=hero broken pen=13) + -13(tHp<3 broken pen=13) + 5(omc>0 bonus) = -21
6) Attack enemy hero + attack 3/2: -13(tgt!=hero broken pen=13) + -7(bonus) + 5(omc>0 bonus) = -15
7) attack 2/3 + attack 3/2: -13(tHp<3 broken pen=13) + -7(bonus) = -20
Point 3 has the highest bonus in this situation.
How to start to use the rules?
1. Create a text file _rules.txt and place it in the behavior folder (for example \Routines\DefaultRoutine\Silverfish\behavior\Control).
2. Open this file in any text editor and create a new rule.
a)Comments begin with //
b)Should not be any extra characters at the end of the rules
c)The new rule must start on a new line
3. Save the file and run the bot. Your rules will be used automatically.
If you want to debug your rules you can add this lile in the _settings.txt:
printRules = 1; //0 - off, 1 - on
The rules that were used will be displayed in files Log/UILogg and in the main window of the bot.
Currently bot includes a RulesEngine, but it's not available for users.
If you want to use your rules right now, you need to download this file.
With the next release all users will be able to use rules.
If you wish to have the new conditions - describe it in the post.
If you are faced with a situation that the rule is not used or is used incorrectly - describe it in the post and attach Log/UILogg/_rules.txt files
What is a Rule?
The Rules is a simple mechanism for interacting with the bot through which you can easily change the bot's behavior and play by own rules.
Should not simultaneously create a lot of rules - you can get unexpected results from the combination of the rules and you will be hard to find the cause of strange behavior.
Rules should be created step by step. Sometimes it is enough to create only a few rules that would radically change the style of playing. AI will do all the work, you should just slightly specify the correct direction.
One Rule is a single line consisting of several parameters (conditions) and a bonus.
- If all conditions are TRUE then a Playfield gets this bonus.
- If at least one condition is broken, the Playfield gets nothing (or gets penality only).
- The bonus can be positive and negative.
- The more positive bonus, the higher chance that this option will be played.
- The less negative bonus, the less chance that this scenario will be chosen (remember that -100 is less than -10).
The rule looks like:
condition,bonus=X
(where X is any number)
Conditions can be connected to each other within one rule:
& - And (condition1&condition2,bonus=X - playfield gets this bonus if only the condition 1 AND condition 2 are true);
|| - Or (condition1||condition2,bonus=X - playfield gets this bonus if the condition 1 is true OR condition 2 is true);
You can connect as many conditions as you wish (no spaces or any extra characters between conditions).
Example: cond_1&cond_2||cond_3||cond_4&cond_5,bonus=10 - true(gets bonus) if condition_1 = true And (condition 2 or 3 or 4) = true And condition_5 = true;
There are 3 types of rules:
1. Board state rule (including cards in your hand and minions on board)
2. Play card rule.
3. Attack rule.
You can mix these rules.
There are 3 types of comparison within one condition:
1. Comparison with a number.
[hide]
Comparison operators (=, !=, >, <) !ONLY NUMERIC VALUE!
(= - equal, != - not equal, > - greater than, < - less than)
tm - turn mana (default mana at this turn);
am - available mana (at this turn);
t - turn;
overload - overload, which can cause a card in the current round;
ohhp - own hero health points;
ehhp - enemy hero health points;
owa - own weapon attack;
ewa - enemy weapon attack;
owd - own weapon durability;
ewd - enemy weapon durability;
occ - own cards count (the number of cards in own hand);
ecc - enemy cards count (the number of cards in enemy's hand);
omc - own minions count (the number of own minions on the board);
emc - enemy minions count (the number of enemy minions on the board);
For "omc" and "emc" you can use these extensions:
:Murlocs (the number own/enemy Murlocs on the board)
:Demons (the number own/enemy Demons on the board)
:Mechs (the number own/enemy Mechs on the board)
:Beasts (the number own/enemy Beasts on the board)
:Totems (the number own/enemy Totems on the board)
:Pirates (the number own/enemy Pirates on the board)
:Dragons (the number own/enemy Dragons on the board)
:SHR (the number own/enemy Silver Hand Recruits on the board)
:undamaged (the number undamaged own/enemy minions on the board)
:damaged (the number damaged own/enemy minions on the board)
:shields (the number own/enemy shields on the board)
:taunts (the number own/enemy taunts on the board)
Also you can compare "omc" and "emc"
Example:
omc>3 - means that you must have more than 3 minions on the board
omc:Murlocs>3 - means that you must have more than 3 murlocs on the board
omc>emc - means that you must have more minions than your opponent
[/hide]
2. Logical comparison.[hide]
Boolean operators (=, !=)
(= - equal/contain; != - not equal/does't contain)
ob - own board (own board must/must not contain this minion (CardID));
eb - enemy board (enemy board must/must not contain this minion (CardID));
oh - own hand (own hand must/must not contain this card (CardID));
ow - own weapon (CardID);
ew - enemy weapon (CardID);
ohero - own hero class (ALL, DRUID, HUNTER, MAGE, PALADIN, PRIEST, ROGUE, SHAMAN, WARLOCK, WARRIOR);
ehero - enemy hero class;
[/hide]
3. Unique.
[hide]
Unique:
coin - must be a coin in hand at turn start;
!coin - must not be a coin in hand at turn start;
noduplicates - if your deck contain no duplicates
p= - play - card in hand that must be played (CardID);
p2= - play 2 identical cards - 2 identical card in hand that must be played (CardID);
a= - attacker - minion on board (CardID);
[/hide]
Examples:
* Don't allow the enemy to have more than 2 Murloc on the board (if the enemy has more than 2 Murlocs on the board, give a small negative bonus):
emc:Murlocs>2,bonus=-5
* If we have own minion with Divine Shield on the board and Flametongue Totem (EX1_565) in hand, give a small positive bonus (for example if there a choice between 2 minions to play, the priority will have a minion with Divine Shield)
omc:shields>0&oh=EX1_565,bonus=2
* If we want to play Doomhammer (EX1_567) on turn 4 (with coin) we must be not overloaded in turn 3.
The rule read as: if at the end of the turn 3 we have overload (we played a card with overload) and (we play coin or we have coin in own hand) and we have Doomhammer in own hand, then completely forbids this action (big negative bonus)):
t=3&overload>0&p=coin||oh=coin&oh=EX1_567,bonus=-600
With conditions "play a card" (p=) or "attack" (a=) you can use additional rules and additional penalties if these conditions were broken.
[hide]
For "p=" and "p2=" and "a=" you can use these extensions:
:pen= (after CardID) - penalty for playing/attacking this card outside of this rule;
:tgt= - target - target for spell or for minion/weapon (CardID/hero/!hero);
If a minion/hero/spell has a target, you can use comparison operators ( =, !=, >, < !ONLY NUMERIC VALUE!) for these parameters:
:aAt - attacker's attack (mob/hero)
:aHp - attacker's health points
:tAt - target's attack
:tHp - target's health points
[/hide]
* If own Grommash Hellscream (EX1_414) have attack=4 and attacks enemy minion (target not hero) and target's hp<5 then give a small positive bonus (if attack condition is broken, give a small penality).
a=EX1_414:aAt=4:tgt=!hero:tHp<5:pen=2,bonus=3
Consider a combination of rules.
Board:
OwnHero HP = 25, No cards, Own Minion: 1)HP=5, Attack=4, Windfury (Windfury Harpy, EX1_033)
EnemyHero HP = 18, No cards, EnemyMinions: 1)Attack=3, HP=2 2)Attack=2, HP=3
Rules: (_rules.txt)
//negative bonus if Windfury Harpy attacks minions with low HP
a=EX1_033:tgt!=hero:tHp<3:pen=13,bonus=-7
//positive bonus if we have at least one minion on the board
omc>0,bonus=5
Possible actions and their bonuses:
1) 1x attack enemy hero: -13(the rule isn't broken, but additional condition tgt!=hero is broken, pen=13) + 5(omc>0 bonus) = -8
2) Attack 2/3: -13(tHp<3 broken pen=13) + 5(omc>0 bonus) = -8
3) Attack 3/2: -7(bonus) + 5(omc>0 bonus) = -2
4) 2x attack enemy hero: -13(tgt!=hero broken pen=13) + -13(tgt!=hero broken pen=13) + 5(omc>0 bonus) = -21
5) Attack enemy hero + attack 2/3: -13(tgt!=hero broken pen=13) + -13(tHp<3 broken pen=13) + 5(omc>0 bonus) = -21
6) Attack enemy hero + attack 3/2: -13(tgt!=hero broken pen=13) + -7(bonus) + 5(omc>0 bonus) = -15
7) attack 2/3 + attack 3/2: -13(tHp<3 broken pen=13) + -7(bonus) = -20
Point 3 has the highest bonus in this situation.
How to start to use the rules?
1. Create a text file _rules.txt and place it in the behavior folder (for example \Routines\DefaultRoutine\Silverfish\behavior\Control).
2. Open this file in any text editor and create a new rule.
a)Comments begin with //
b)Should not be any extra characters at the end of the rules
c)The new rule must start on a new line
3. Save the file and run the bot. Your rules will be used automatically.
If you want to debug your rules you can add this lile in the _settings.txt:
printRules = 1; //0 - off, 1 - on
The rules that were used will be displayed in files Log/UILogg and in the main window of the bot.
Currently bot includes a RulesEngine, but it's not available for users.
If you want to use your rules right now, you need to download this file.
With the next release all users will be able to use rules.
If you wish to have the new conditions - describe it in the post.
If you are faced with a situation that the rule is not used or is used incorrectly - describe it in the post and attach Log/UILogg/_rules.txt files
Last edited: