Last active
May 23, 2023 13:15
-
-
Save Alessandro-Barbieri/a0f4486489be1c5442e34ace13c4110c to your computer and use it in GitHub Desktop.
using a genetic algorithm in R to optimize classic wow mage dps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2013 Alessandro Barbieri | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see <https://www.gnu.org/licenses/>. | |
library(methods) | |
library(data.table) | |
library("stringi") | |
library("tidyr") | |
library("dplyr") | |
#library("rPref") | |
library("GA") | |
#library("rmoo") | |
slots <- vector(mode='list', length=21) | |
chest <- data.frame() | |
cloak <- data.frame() | |
feet <- data.frame() | |
finger <- data.frame() | |
hands <- data.frame() | |
head <- data.frame() | |
legs <- data.frame() | |
neck <- data.frame() | |
ranged <- data.frame() | |
shoulder <- data.frame() | |
trinket <- data.frame() | |
trinket_active <- data.frame() | |
twohanded <- data.frame() | |
waist <- data.frame() | |
wrist <- data.frame() | |
#PROFESSIONS | |
chest <- bind_rows(chest,data.frame(name = "Robe of the Archmage",int = 12,sp = 40,crit = 0.01, mp5 = 5*(375+625)/(2*60*5))) | |
##cloak <- bind_rows(cloak,data.frame(name="Hide of the Wild",int=10)) | |
##cloak <- bind_rows(cloak,data.frame(name="Chromatic Cloak",crit=0.01)) | |
hands <- bind_rows(hands,data.frame(name="Gloves of Spell Mastery",int=10,spi=8,crit=0.02)) | |
waist <- bind_rows(waist,data.frame(name="Belt of the Archmage",int=25,crit=0.01)) | |
#DARKMOON FAIRE | |
neck <- bind_rows(neck,data.frame(name="Orb of the Darkmoon",spi=8,sp=22)) | |
#SILITHUS | |
##cloak <- bind_rows(cloak,data.frame(name="Windshear Cape",int=7)) | |
finger <- bind_rows(finger,data.frame(name="Elemental Focus Band", sp=22,int=11)) | |
##neck <- bind_rows(neck,data.frame(name="Wavefront Necklace",int=6,mp5=8)) | |
wrist <- bind_rows(wrist,data.frame(name="Rockfury Bracers",sp=27,hit=0.01)) | |
#PVP | |
chest <- bind_rows(chest,data.frame(name="Warlord's Silk Raiment",spi=6,int=17,sp=33,crit=0.01,PVP=1)) | |
feet <- bind_rows(feet,data.frame(name="General's Silk Boots",int=14,spi=6,PVP=1,sp=21,hit=0.01)) | |
##finger <- bind_rows(finger,data.frame(name="Don Rodrigos's Band", crit=0.01)) | |
hands <- bind_rows(hands,data.frame(name="General's Silk Handguards",int=12,spi=5,sp=27,PVP=1)) | |
head <- bind_rows(head,data.frame(name="Warlord's Silk Cowl",int=17,spi=6,crit=0.01,sp=33,PVP=1)) | |
legs <- bind_rows(legs,data.frame(name="General's Silk Trousers",int=20,spi=10,sp=30,PVP=1,crit=0.01)) | |
##legs <- bind_rows(legs,data.frame(name="Outrider's Silk Leggings",int=19,spi=10,sp=28)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Warlord's Silk Amice",int=15,spi=5,sp=25,PVP=1)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Defiler's Epaulets",int=17,sp=12,mp5=4)) | |
twohanded <- bind_rows(twohanded,data.frame(name="High Warlord's War Staff",int=23,spi=17,sp=71)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Ironbark Staff",int=10,sp=41,crit=0.01)) | |
waist <- bind_rows(waist,data.frame(name="General's Silk Sash",int=23,spi=15)) | |
wrist <- bind_rows(wrist,data.frame(name="General's Silk Cuffs",int=19,spi=10)) | |
#WORLD BOE | |
chest <- bind_rows(chest,data.frame(name="Alanna's Embrace",int=20,spi=20,sp=20)) | |
chest <- bind_rows(chest,data.frame(name="Robes of Insight",int=25,spi=15)) | |
##finger <- bind_rows(finger,data.frame(name="Underworld Band", spi=6)) | |
##finger <- bind_rows(finger,data.frame(name="Freezing Band", frostsp=21)) | |
neck <- bind_rows(neck,data.frame(name="Lady Maye's pendant",spi=10,int=19)) | |
##neck <- bind_rows(neck,data.frame(name="Lei of Lilies",spi=15)) | |
##neck <- bind_rows(neck,data.frame(name="Jeweled Amulet of Cainwyn",spi=10,int=18)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Staff of Jordan",int=11,spi=11,sp=26)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Glowing Brightwood Staff",int=29,spi=9)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Elemental Mage Staff",frostsp=36,firesp=36)) | |
#INSTANCE | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Burst of Knowledge",sp=15,cooldown=15*60,duration=10)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Fire Ruby",cooldown=3*60,duration=60)) | |
#ARGENT DAWN | |
neck <- bind_rows(neck,data.frame(name="Amulet of the Dawn",int=13,sp=15)) | |
wrist <- bind_rows(wrist,data.frame(name="Bracers of Hope",int=11,spi=12,sp=18)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Talisman of Ascendance",cooldown=60,duration=20)) | |
#TIER 0 | |
chest <- bind_rows(chest,data.frame(name="Magister's Robes",int=31,spi=8,T0=1)) | |
feet <- bind_rows(feet,data.frame(name="Magister's Boots",int=14,spi=14,T0=1)) | |
hands <- bind_rows(hands,data.frame(name = "Magister's Gloves",T0=1,spi=14,int=14)) | |
head <- bind_rows(head,data.frame(name = "Magister's Crown",T0=1,spi=5,int=30)) | |
legs <- bind_rows(legs,data.frame(name = "Magister's Leggings",T0=1,spi=21,int=20)) | |
shoulder <- bind_rows(shoulder,data.frame(name = "Magister's Mantle",T0=1,spi=6,int=22)) | |
waist <- bind_rows(waist,data.frame(name="Magister's Belt",int=21,spi=6,T0=1)) | |
wrist <- bind_rows(wrist,data.frame(name="Magister's Bindings",int=15,spi=5,T0=1)) | |
#TIER 0.5 | |
chest <- bind_rows(chest,data.frame(name="Sorcerer's Robes",int=25,spi=9,sp=16,T0_5=1)) | |
feet <- bind_rows(feet,data.frame(name="Sorcerer's Boots",int=16,spi=10,sp=21,T0_5=1)) | |
hands <- bind_rows(hands,data.frame(name = "Sorcerer's Gloves",T0_5=1,spi=10,int=14,sp=12,hit=0.01)) | |
head <- bind_rows(head,data.frame(name = "Sorcerer's Crown",T0_5=1,spi=14,int=25,sp=11,crit=0.01)) | |
legs <- bind_rows(legs,data.frame(name = "Sorcerer's Leggings",T0_5=1,spi=10,int=22,sp=16)) | |
shoulder <- bind_rows(shoulder,data.frame(name = "Sorcerer's Mantle",T0_5=1,spi=7,int=17,sp=9)) | |
waist <- bind_rows(waist,data.frame(name="Sorcerer's Belt",int=14,spi=7,sp=14,T0_5=1)) | |
wrist <- bind_rows(wrist,data.frame(name="Sorcerer's Bindings",int=12,spi=5,sp=8,T0_5=1)) | |
#INSTANCE EPIC | |
chest <- bind_rows(chest,data.frame(name="Embrace of the Wind Serpent",spi=30,int=17)) | |
head <- bind_rows(head,data.frame(name="Eye of Flame",int=10,spi=10,firesp=43)) | |
##head <- bind_rows(head,data.frame(name="Cap of the Scarlet Savant",int=20,crit=0.02)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Headmaster's Charge",int=20)) | |
#WORLD BOSSES | |
chest <- bind_rows(chest,data.frame(name="Jade Inlaid Vestments",int=18,spi=8,sp=44)) | |
cloak <- bind_rows(cloak,data.frame(name="Drape of Benediction",int=13,spi=8)) | |
feet <- bind_rows(feet,data.frame(name="Mendicant's Slippers",int=23,mp5=10)) | |
feet <- bind_rows(feet,data.frame(name="Snowblind Shoes",int=10,sp=32,mp5=5)) | |
finger <- bind_rows(finger,data.frame(name="Ring of Entropy", int=13,spi=8, crit=0.01)) | |
finger <- bind_rows(finger,data.frame(name="Mindtear Band",sp=21,int=6,crit=0.01)) | |
hands <- bind_rows(hands,data.frame(name="Gloves of Delusional Power",int=16,mp5=5,sp=27)) | |
##head <- bind_rows(head,data.frame(name="Crystal Adorned Crown",int=14,spi=13)) | |
legs <- bind_rows(legs,data.frame(name="Leggings of Arcane Supremacy",int=24,spi=14)) | |
##neck <- bind_rows(neck,data.frame(name="Dragonheart Necklace",int=6,spi=6)) | |
ranged <- bind_rows(ranged,data.frame(name="Cold Snap",int=7,frostsp=20)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Amberseal Keeper",int=20,sp=44,mp5=12)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Staff of Rampant Growth",int=16,mp5=11)) | |
##waist <- bind_rows(waist,data.frame(name="Belt of the Dark Bog",int=8,sp=14)) | |
wrist <- bind_rows(wrist,data.frame(name="Blacklight Bracer",int=13,spi=8,crit=0.01)) | |
wrist <- bind_rows(wrist,data.frame(name="Dryad's Wrist Bindings",int=8,spi=7,sp=22)) | |
wrist <- bind_rows(wrist,data.frame(name="Black Bark Wristbands",int=4,spi=4,sp=25)) | |
#AHN'QUIRAJ OPENING | |
##chest <- bind_rows(chest,data.frame(name="Darkwater Robes",int=17,frostsp=39)) | |
head <- bind_rows(head,data.frame(name="Gnomish Turban of Psychic Might",int=31,mp5=9)) | |
##neck <- bind_rows(neck,data.frame(name="Amulet of Shadow Shielding",spi=7)) | |
##neck <- bind_rows(neck,data.frame(name="Drake Tooth Necklace",int=12)) | |
#ONYXIA'S LAIR | |
cloak <- bind_rows(cloak,data.frame(name="Sapphiron Drape",int=17,sp=14)) | |
finger <- bind_rows(finger,data.frame(name="Dragonslayer's Signet", int=12,spi=6, crit=0.01)) | |
head <- bind_rows(head,data.frame(name="Netherwind Crown",spi=7,int=26,mp5=4,sp=32,T2=1)) | |
trinket <- bind_rows(trinket,data.frame(name="Shard of the Scale",mp5=16)) | |
#MOLTEN CORE | |
chest <- bind_rows(chest,data.frame(name="Arcanist Robes",spi=10,int=25,sp=23,T1=1)) | |
chest <- bind_rows(chest,data.frame(name="Robe of Volatile Power",int=15,spi=10,crit=0.02,sp=23)) | |
##chest <- bind_rows(chest,data.frame(name="Flarecore Robe",sp=23)) | |
##cloak <- bind_rows(cloak,data.frame(name="Fireproof Cloak",int=9,spi=8)) | |
feet <- bind_rows(feet,data.frame(name="Arcanist Boots",spi=11,int=14,T1=1,sp=11,crit=0.01)) | |
finger <- bind_rows(finger,data.frame(name="Seal of the Archmagus", int=11, spi=11, mp5=3)) | |
finger <- bind_rows(finger,data.frame(name="Band of Sulfuras", int=23,spi=10)) | |
finger <- bind_rows(finger,data.frame(name = "Ring of Spell Power", sp=33)) | |
##finger <- bind_rows(finger,data.frame(name="Cauterizing Band", int=12)) | |
hands <- bind_rows(hands,data.frame(name="Arcanist Gloves",T1=1,spi=10,int=15,sp=14,mp5=4)) | |
hands <- bind_rows(hands,data.frame(name="Gloves of the Hypnotic Flame",int=19,spi=8,firesp=23,sp=9)) | |
##hands <- bind_rows(hands,data.frame(name="Flarecore Gloves",int=14)) | |
head <- bind_rows(head,data.frame(name="Arcanist Crown",int=27,spi=10,T1=1,sp=20,hit=0.01)) | |
legs <- bind_rows(legs,data.frame(name="Arcanist Leggings",T1=1,spi=10,int=23,crit=0.01,sp=20)) | |
legs <- bind_rows(legs,data.frame(name="Manastorm Leggings",int=14,mp5=14)) | |
legs <- bind_rows(legs,data.frame(name="Netherwind Pants",T2=1,spi=5,int=27,sp=30,crit=0.01)) | |
neck <- bind_rows(neck,data.frame(name ="Choker of Enlightenment",int=10,spi=10,sp=18)) | |
neck <- bind_rows(neck,data.frame(name="Choker of the Fire Lord",int=7,sp=34)) | |
##ranged <- bind_rows(ranged,data.frame(name="Crimson Shocker",int=10)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Arcanist Mantle",T1=1,spi=5,int=21,mp5=4,sp=14)) | |
##shoulder <- bind_rows(shoulder,data.frame(name="Flarecore Mantle",spi=10,int=10)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Talisman of Ephemeral Power",cooldown=90,duration=15)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Staff of Dominance",int=37,spi=14,crit=0.01,sp=40)) | |
waist <- bind_rows(waist,data.frame(name ="Arcanist Belt",T1=1,int=20,spi=10,sp=14)) | |
waist <- bind_rows(waist,data.frame(name="Mana Igniting Cord",int=16,sp=25,crit=0.01)) | |
wrist <- bind_rows(wrist,data.frame(name ="Arcanist Bindings",T1=1,int=15,spi=6,sp=12,mp5=3)) | |
wrist <- bind_rows(wrist,data.frame(name="Flarecore Wraps",int=8,mp5=9)) | |
#BLACKWING LAIR | |
chest <- bind_rows(chest,data.frame(name="Netherwind Robes",spi=8,int=26,sp=32,crit=0.01,T2=1)) | |
##chest <- bind_rows(chest,data.frame(name="Black Ash Robe",int=22,spi=17)) | |
cloak <- bind_rows(cloak,data.frame(name="Cloak of the Brood Lord",int=14,sp=26)) | |
##cloak <- bind_rows(cloak,data.frame(name="Shroud of Pure Thought",int=11,mp5=6)) | |
feet <- bind_rows(feet,data.frame(name="Netherwind Boots", spi=10, int=16, sp=27,T2=1)) | |
feet <- bind_rows(feet,data.frame(name = "Ringo's Blizzard Boots", int=12, hit=0.01, frostsp=40)) | |
feet <- bind_rows(feet,data.frame(name="Shimmering Geta",int=17,mp5=12)) | |
##feet <- bind_rows(feet,data.frame(name="Boots of Pure Thought",int=12,spi=12)) | |
finger <- bind_rows(finger,data.frame(name="Ring of Blackrock", sp=19, mp5=9)) | |
finger <- bind_rows(finger,data.frame(name="Band of Forced Concentration", sp=21,int=12,hit=0.01)) | |
##finger <- bind_rows(finger,data.frame(name="Pure Elementium Band", int=10,spi=10)) | |
##finger <- bind_rows(finger,data.frame(name="Band of Dark Dominion", int=6)) | |
hands <- bind_rows(hands,data.frame(name="Netherwind Gloves",T2=1,int=16,spi=6,sp=20,crit=0.01)) | |
hands <- bind_rows(hands,data.frame(name="Gloves of Rapid Evolution",int=12,spi=32)) | |
##hands <- bind_rows(hands,data.frame(name="Ebony Flame Gloves",int=12)) | |
head <- bind_rows(head,data.frame(name = "Mish'undare, Circlet of the Mind Flayer",int=24,spi=9,sp=35,crit=0.02)) | |
legs <- bind_rows(legs,data.frame(name="Empowered Leggings",int=12,spi=24,crit=0.01)) | |
neck <- bind_rows(neck,data.frame(name="Pendant of the Fallen Dragon",int=12,mp5=9)) | |
ranged <- bind_rows(ranged,data.frame(name="Essence Gatherer",int=7,mp5=5)) | |
ranged <- bind_rows(ranged,data.frame(name="Dragon's Touch",int=12,sp=6)) | |
shoulder <- bind_rows(shoulder,data.frame(name ="Netherwind Mantle",T2=1,mp5=4,int=13,spi=12,sp=21)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Mantle of the Blackwing Cabal",int=16,sp=34)) | |
trinket <- bind_rows(trinket,data.frame(name="Neltharion's Tear",sp=44,hit=0.02)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name ="Mind Quickening Gem",cooldown=5*60,duration=20)) | |
##trinket <- bind_rows(trinket,data.frame(name="Rejuvenating Gem",mp5=9)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Shadow Wing Focus Staff",int=40,spi=17,sp=56)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Staff of the Shadow Flame",int=29,spi=18,crit=0.02,sp=84)) | |
waist <- bind_rows(waist,data.frame(name="Netherwind Belt",T2=1,spi=13,int=20,sp=23)) | |
waist <- bind_rows(waist,data.frame(name="Angelista's Grasp",spi=13,int=20,hit=0.02)) | |
wrist <- bind_rows(wrist,data.frame(name="Netherwind Bindings",T2=1,spi=8,int=15,sp=19,mp5=4)) | |
wrist <- bind_rows(wrist,data.frame(name="Bracers of Arcane Accuracy",int=12,hit=0.01,sp=21)) | |
#ZUL'GURUB | |
chest <- bind_rows(chest,data.frame(name="Zandalar Illusionist's Robe",int=24,sp=27,crit=0.01,ZG=1)) | |
chest <- bind_rows(chest,data.frame(name="Flowing Ritual Robes",int=23,spi=24,sp=22)) | |
##cloak <- bind_rows(cloak,data.frame(name="Cloak of Consumption",int=10,sp=23,hit=0.01)) | |
feet <- bind_rows(feet,data.frame(name="Betrayer's Boots",int=12,spi=12,sp=30)) | |
##finger <- bind_rows(finger,data.frame(name="Band of Servitude", sp=23,int=9)) | |
neck <- bind_rows(neck,data.frame(name="Jewel of Kajaro",spi=8,int=13,sp=9,ZG=1)) | |
neck <- bind_rows(neck,data.frame(name="Soul Corrupter's Necklace",spi=8,int=16,hit=0.01)) | |
##neck <- bind_rows(neck,data.frame(name="Jin'Do Evil Eye",spi=6,int=11)) | |
ranged <- bind_rows(ranged,data.frame(name="Mar'li's Touch",int=11,spi=6)) | |
ranged <- bind_rows(ranged,data.frame(name="Touch of Chaos",sp=18)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Zandalar Illusionist's Mantle",ZG=1,int=21,spi=10,sp=12)) | |
trinket <- bind_rows(trinket,data.frame(name="Hazza'rah Charm of Magic",ZG=1)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Mar'li's Eye",cooldown=3*60,duration=30)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Zandalarian Hero Charm",cooldown=2*60,duration=20)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Jin'Do's Judgement",int=10,mp5=14,sp=27,hit=0.01)) | |
twohanded <- bind_rows(twohanded,data.frame(name ="Will of Arlokk",spi=35,int=19)) | |
waist <- bind_rows(waist,data.frame(name="Firemaw's Clutch",int=12,sp=35,mp5=5)) | |
wrist <- bind_rows(wrist,data.frame(name="Zandalar Illusionist's Wraps",ZG=1,spi=9,int=11,sp=14)) | |
#RUINS OF AHN'QUIRAJ | |
chest <- bind_rows(chest,data.frame(name="Vestments of the Shifting Sands",int=14,spi=8,sp=32,crit=0.01)) | |
cloak <- bind_rows(cloak,data.frame(name="Drape of Vaulted Secrets",int=9,spi=6,AQ=1,sp=18)) | |
finger <- bind_rows(finger,data.frame(name="Band of Vaulted Secrets", sp=18, crit=0.01, AQ=1)) | |
hands <- bind_rows(hands,data.frame(name="Gloves of Dark Wisdom",int=20,mp5=5)) | |
head <- bind_rows(head,data.frame(name="Dustwind Turban",int=29,spi=15,crit=0.01)) | |
legs <- bind_rows(legs,data.frame(name ="Leggings of the Black Blizzard",int=16,spi=8,sp=41,crit=0.01)) | |
neck <- bind_rows(neck,data.frame(name="Charm of the Shifting Sands",int=12,sp=25)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Eye of Moam",cooldown=3*60,duration=30)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Staff of the Ruins",int=23,spi=14,sp=60,crit=0.01,hit=0.01)) | |
##wrist <- bind_rows(wrist,data.frame(name="Shackles of the Unscarred",int=12,sp=21)) | |
#TEMPLE OF AHN'QUIRAJ | |
chest <- bind_rows(chest,data.frame(name="Enigma Robes",sp=39,int=26,spi=8,crit=0.01,T2_5=1)) | |
chest <- bind_rows(chest,data.frame(name="Robes of the Guardian Saint",int=22,mp5=7)) | |
chest <- bind_rows(chest,data.frame(name="Robes of the Triumvirate",int=22,mp5=7)) | |
chest <- bind_rows(chest,data.frame(name="Garb of Royal Ascension",sp=30,hit=0.02)) | |
##chest <- bind_rows(chest,data.frame(name="Robes of the Battleguard",int=17,spi=8,sp=36)) | |
cloak <- bind_rows(cloak,data.frame(name="Cloak of Clarity",int=12,spi=7,mp5=8)) | |
cloak <- bind_rows(cloak,data.frame(name="Cloak of the Devoured",int=10,sp=30,hit=0.01)) | |
##cloak <- bind_rows(cloak,data.frame(name="Cape of the Trinity",int=12,sp=21)) | |
feet <- bind_rows(feet,data.frame(name="Enigma Boots",int=15,spi=6,sp=28,hit=0.01,mp5=4,T2_5=1)) | |
feet <- bind_rows(feet,data.frame(name="Boots of Epiphany",int=19,sp=34)) | |
##feet <- bind_rows(feet,data.frame(name="Recomposed Boots",int=13,sp=20)) | |
finger <- bind_rows(finger,data.frame(name="Signet Ring of the Bronze Dragonflight", sp=28,int=9, mp5=5)) | |
finger <- bind_rows(finger,data.frame(name="Ring of the Fallen God", sp=37,int=6,hit=0.01)) | |
finger <- bind_rows(finger,data.frame(name="Ritssyn's Ring of Chaos", sp=25,crit=0.01)) | |
##finger <- bind_rows(finger,data.frame(name="Ring of Swarming Thought", sp=26)) | |
##finger <- bind_rows(finger,data.frame(name="Ring of the Devoured", mp5=8)) | |
##finger <- bind_rows(finger,data.frame(name="Ring of the Martyr", mp5=5)) | |
hands <- bind_rows(hands,data.frame(name="Dark Storm Gauntlets",int=15,sp=37,hit=0.01)) | |
hands <- bind_rows(hands,data.frame(name="Gloves of the Messiah",int=17,mp5=10)) | |
##hands <- bind_rows(hands,data.frame(name="Gloves of the Immortal",int=16)) | |
head <- bind_rows(head,data.frame(name="Enigma Circlet",int=24,spi=12,sp=33,crit=0.01,hit=0.01,T2_5=1)) | |
head <- bind_rows(head,data.frame(name="Don Rigoberto's Lost Hat",int=24,mp5=11)) | |
legs <- bind_rows(legs,data.frame(name="Enigma Leggings",int=26,spi=8,sp=34,crit=0.01,mp5=5,T2_5=1)) | |
legs <- bind_rows(legs,data.frame(name="Leggings of the Festering Swarm",int=23,firesp=57)) | |
neck <- bind_rows(neck,data.frame(name="Amulet of Vek'Nilash",int=5,sp=27,crit=0.01)) | |
##neck <- bind_rows(neck,data.frame(name="Angelista's Charm",int=14,mp5=6)) | |
##neck <- bind_rows(neck,data.frame(name="Necklace of Purity",int=13,sp=8)) | |
##neck <- bind_rows(neck,data.frame(name="Amulet of the Fallen God",mp5=6)) | |
ranged <- bind_rows(ranged,data.frame(name="Wand of Qiraji Nobilty",sp=19)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Enigma Shoulderpads",int=12,spi=4,sp=30,mp5=5,T2_5=1)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Ternary Mantle",int=17,spi=20)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Mantle of Phrenic Power",int=20,firesp=33)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Blessed Qiraji Acolyte Staff",int=33,sp=76,hit=0.02,crit=0.01)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Blessed Qiraji Augur Staff",int=24,mp5=15)) | |
##twohanded <- bind_rows(twohanded,data.frame(name="Staff of the Qiraji Prophets",int=26,spi=8,sp=56)) | |
waist <- bind_rows(waist,data.frame(name="Eyestalk Waist Cord",int=9,crit=0.01,sp=41)) | |
wrist <- bind_rows(wrist,data.frame(name="Bracelets of Royal Redemption",int=10,spi=9)) | |
wrist <- bind_rows(wrist,data.frame(name="Burrower Bracers",int=13,sp=28)) | |
#NAXXRAMAS | |
chest <- bind_rows(chest,data.frame(name="Frostfire Robe",int=27,sp=47,hit=0.01,crit=0.01,T3=1)) | |
chest <- bind_rows(chest,data.frame(name="Crystal Webbed Robe",int=19,sp=53)) | |
##chest <- bind_rows(chest,data.frame(name="Necro-Knight's Garb",sp=37)) | |
##chest <- bind_rows(chest,data.frame(name="Glacial Vest",sp=21)) | |
cloak <- bind_rows(cloak,data.frame(name = "Cloak of the Necropolis",int = 12,sp = 26,crit=0.01,hit=0.01 )) | |
cloak <- bind_rows(cloak,data.frame(name="Cloak of Suturing",int=12,spi=12,mp5=5)) | |
cloak <- bind_rows(cloak,data.frame(name="Veil of Eclipse",int=10,sp=28)) | |
feet <- bind_rows(feet,data.frame(name="Frostfire Sandals",int=18,spi=10,crit=0.01,sp=28,T3=1)) | |
finger <- bind_rows(finger,data.frame(name="Frostfire Ring",sp=30,int=10, crit=0.01,T3=1)) | |
finger <- bind_rows(finger,data.frame(name="Ring of the Eternal Flame", int=10, firesp=34,crit=0.01)) | |
finger <- bind_rows(finger,data.frame(name="Ring of Spiritual Fervor", int=14, mp5=10)) | |
hands <- bind_rows(hands,data.frame(name="Frostfire Gloves",int=19,spi=10,sp=36,T3=1)) | |
head <- bind_rows(head,data.frame(name="Frostfire Circlet",int=23,sp=35,hit=0.01,crit=0.02,T3=1)) | |
head <- bind_rows(head,data.frame(name="Preceptor's Hat",int=24,sp=51)) | |
##head <- bind_rows(head,data.frame(name="Glacial Headdress",int=21,sp=18)) | |
legs <- bind_rows(legs,data.frame(name="Frostfire Leggings",int=26,spi=10,hit=0.01,sp=48,T3=1)) | |
legs <- bind_rows(legs,data.frame(name="Leggings of Polarity",int=14,sp=44,crit=0.02)) | |
neck <- bind_rows(neck,data.frame(name="Pendant of Forgotten Names",int=18,spi=18,mp5=7)) | |
neck <- bind_rows(neck,data.frame(name="Gem of Trapped Innocents",int=7,sp=15,crit=0.02)) | |
neck <- bind_rows(neck,data.frame(name="Malice Stone Pendant",int=8,sp=28)) | |
##neck <- bind_rows(neck,data.frame(name="Necklace of Necropsy",int=11,spi=10)) | |
ranged <- bind_rows(ranged,data.frame(name ="Doomfinger",sp=16,crit=0.01)) | |
ranged <- bind_rows(ranged,data.frame(name="Wand of the Whispering Dead",int=10,spi=9)) | |
ranged <- bind_rows(ranged,data.frame(name="Wand of Fates",int=7,sp=12,hit=0.01)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Frostfire Shoulderpads",int=18,spi=9,sp=36,T3=1)) | |
shoulder <- bind_rows(shoulder,data.frame(name="Rime Covered Mantle",int=12,sp=39,crit=0.01)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="The Restrained Essence of Sapphiron",sp=40,cooldown=2*60,duration=20)) | |
trinket <- bind_rows(trinket,data.frame(name="Mark of the Champion",sp=85)) | |
trinket_active <- bind_rows(trinket_active,data.frame(name="Warmth of Forgiveness",mp5=10,cooldown=3*60)) | |
trinket <- bind_rows(trinket,data.frame(name="Eye of Diminution",crit=0.02)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Spire of Twilight",int=38,mp5=10)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Soulseeker",int=31,sp=126,crit=0.02)) | |
twohanded <- bind_rows(twohanded,data.frame(name="Brimstone Staff",int=30,hit=0.02,sp=113,crit=0.01)) | |
waist <- bind_rows(waist,data.frame(name="Frostfire Belt",int=21,spi=10,sp=28,hit=0.01,T3=1)) | |
wrist <- bind_rows(wrist,data.frame(name="Frostfire Bindings",int=15,sp=27,T3=1)) | |
wrist <- bind_rows(wrist,data.frame(name="The Soul Harvester's Bindings",int=11,crit=0.01,sp=21)) | |
##wrist <- bind_rows(wrist,data.frame(name="Glacial Wrists",sp=12)) | |
setDT(finger) | |
slots[[1]] <- finger | |
setDT(trinket) | |
setDT(trinket_active) | |
slots[[2]] <- trinket | |
setDT(chest) | |
slots[[3]] <- chest | |
setDT(cloak) | |
slots[[4]] <- cloak | |
setDT(feet) | |
slots[[5]] <- feet | |
setDT(hands) | |
slots[[6]] <- hands | |
setDT(head) | |
slots[[7]] <- head | |
setDT(legs) | |
slots[[8]] <- legs | |
setDT(neck) | |
slots[[9]] <- neck | |
setDT(ranged) | |
slots[[10]] <- ranged | |
setDT(shoulder) | |
slots[[11]] <- shoulder | |
setDT(twohanded) | |
slots[[12]] <- twohanded | |
setDT(waist) | |
slots[[13]] <- waist | |
setDT(wrist) | |
slots[[14]] <- wrist | |
ench_chest <- data.frame(name="Enchant Chest Greater Stats",spi=4,int=4) | |
ench_chest <- bind_rows(ench_chest,data.frame(name="Enchant Chest Major Mana",mana=100)) | |
setDT(ench_chest) | |
slots[[15]] <- ench_chest | |
ench_hands <- data.frame(name="Enchant Gloves Frost Power",frostsp=20) | |
ench_hands <- bind_rows(ench_hands,data.frame(name="Enchant Gloves Fire Power",firesp=20)) | |
setDT(ench_hands) | |
slots[[16]] <- ench_hands | |
ench_head <- data.frame(name="Lesser Arcanum of Rumination",mana=150) | |
ench_head <- bind_rows(ench_head,data.frame(name="Lesser Arcanum of Voracity Spirit",spi=8)) | |
ench_head <- bind_rows(ench_head,data.frame(name="Lesser Arcanum of Voracity Intellect",int=8)) | |
ench_head <- bind_rows(ench_head,data.frame(name="Presence of Sight",sp=18,hit=0.01)) | |
##ench_head <- bind_rows(ench_head,data.frame(name="Arcanum of Focus",sp=8)) | |
setDT(ench_head) | |
slots[[17]] <- ench_head | |
#ench_feet <- data.frame(name="Enchant Boots Spirit",spi=5) | |
#setDT(ench_feet) | |
ench_legs <- data.frame(name="Lesser Arcanum of Rumination",mana=150) | |
ench_legs <- bind_rows(ench_legs,data.frame(name="Lesser Arcanum of Voracity Spirit",spi=8)) | |
ench_legs <- bind_rows(ench_legs,data.frame(name="Lesser Arcanum of Voracity Intellect",int=8)) | |
ench_legs <- bind_rows(ench_legs,data.frame(name="Presence of Sight",sp=18,hit=0.01)) | |
##ench_legs <- bind_rows(ench_legs,data.frame(name="Arcanum of Focus",sp=8)) | |
setDT(ench_legs) | |
slots[[18]] <- ench_legs | |
ench_shoulder <- data.frame(name="Zandalar Signet of Mojo",sp=18) | |
ench_shoulder <- bind_rows(ench_shoulder,data.frame(name="Resilience of the Scourge",mp5=5)) | |
ench_shoulder <- bind_rows(ench_shoulder,data.frame(name="Power of the Scourge",sp=15,crit=0.01)) | |
setDT(ench_shoulder) | |
slots[[19]] <- ench_shoulder | |
ench_weapon <- data.frame(name="Enchant Weapon Migthy Spirit",spi=20) | |
ench_weapon <- bind_rows(ench_weapon,data.frame(name="Enchant Weapon Mighty Intellect",int=22)) | |
ench_weapon <- bind_rows(ench_weapon,data.frame(name="Enchant Weapon Spell Power",sp=30)) | |
##ench_weapon <- bind_rows(ench_weapon,data.frame(name="Enchant Weapon Winter's Might",frostsp=7)) | |
##ench_weapon <- bind_rows(ench_weapon,data.frame(name="Enchant Weapon Major Intellect",int=9)) | |
setDT(ench_weapon) | |
slots[[20]] <- ench_weapon | |
ench_wrist <- data.frame(name="Enchant Bracer Mana Regeneration",mp5=4) | |
ench_wrist <- bind_rows(ench_wrist,data.frame(name="Enchant Bracer Greater Intellect",int=7)) | |
ench_wrist <- bind_rows(ench_wrist,data.frame(name="Enchant Bracer Superior Spirit",spi=9)) | |
setDT(ench_wrist) | |
slots[[21]] <- ench_wrist | |
trinket_comb <- combn(1:length(trinket),2) | |
finger_comb <- combn(1:length(finger),2) | |
slot_names <- c("finger","trinket","chest","cloak","feet","hands","head","legs","neck","ranged","shoulder","twohanded","waist","wrist","enchant chest","enchant hands","enchant head","enchant legs","enchant shoulder","enchant weapon","enchant wrist") | |
names(slots) <- slot_names | |
firemage <- setRefClass("firemage",fields=list( | |
arcane_meditation_2 = "numeric", | |
arcaneconcentration_prob = "numeric", | |
base_hit = "numeric", | |
base_int = "numeric", | |
base_mana = "numeric", | |
base_spi = "numeric", | |
casting_fireball = "logical", | |
casting_scorch = "logical", | |
clearcast = "logical", | |
clearcast_cooldown = "numeric", | |
clearcast_duration = "numeric", | |
clearcast_timer = "numeric", | |
clearcastcd_timer = "numeric", | |
combustion = "logical", | |
combustion_cooldown = "numeric", | |
combustion_stacks = "numeric", | |
combustion_timer = "numeric", | |
combustioncritperstack = "numeric", | |
crit_counter = "numeric", | |
crit_fire = "numeric", | |
critical_mass_crit = "numeric", | |
current_mana = "numeric", | |
damage = "numeric", | |
elemental_precision = "numeric", | |
evocate_cooldown = "numeric", | |
evocatechannel_timer = "numeric", | |
evocatecd_timer = "numeric", | |
evocating = "logical", | |
evocation_duration = "numeric", | |
fire_power_coeff = "numeric", | |
fireball_cast = "numeric", | |
fireball_coeff = "numeric", | |
fireball_cost = "numeric", | |
fireball_dot = "numeric", | |
fireball_max = "numeric", | |
fireball_min = "numeric", | |
fireball_timer = "numeric", | |
fireballdot_duration = "numeric", | |
fireballdot_timer = "numeric", | |
fireballtick_timer = "numeric", | |
gcd = "numeric", | |
hit_mult = "numeric", | |
idle = "logical", | |
ignite_coeff = "numeric", | |
ignite_damage = "numeric", | |
ignite_duration = "numeric", | |
ignite_stacks = "numeric", | |
ignite_timer = "numeric", | |
ignitemaxstacks = "numeric", | |
ignitetick_timer = "numeric", | |
improved_fireball = "numeric", | |
mage_armour = "numeric", | |
mana = "numeric", | |
mana_tick = "numeric", | |
mana_timer = "numeric", | |
master_of_elements_coeff = "numeric", | |
mp5rule_timer = "numeric", | |
scorch_cast = "numeric", | |
scorch_coeff = "numeric", | |
scorch_cost = "numeric", | |
scorch_max = "numeric", | |
scorch_min = "numeric", | |
scorch_stacks = "numeric", | |
scorch_timer = "numeric", | |
scorchdebuff_duration = "numeric", | |
scorchmaxstacks = "numeric", | |
scorchstackcoeff = "numeric", | |
scorchstacks_timer = "numeric", | |
spirit_reg = "numeric", | |
statistics = "numeric", | |
time_tick = "numeric", | |
total_crit = "numeric", | |
total_firesp = "numeric", | |
total_int = "numeric", | |
total_mana = "numeric", | |
total_mp5 = "numeric", | |
total_spi = "numeric", | |
total_time = "numeric" | |
), | |
methods=list( | |
initialize = function(statistics){ | |
arcane_meditation_2 <<- 2*0.05 | |
arcaneconcentration_prob <<- 0.1 | |
#vs lv 63 | |
base_hit <<- 0.84 | |
base_int <<- 18+3 | |
base_mana <<- 1213 | |
base_spi <<- 25+2 | |
casting_fireball <<- FALSE | |
casting_scorch <<- FALSE | |
clearcast <<- FALSE | |
clearcast_cooldown <<- 1 | |
clearcast_duration <<- 15 | |
combustion <<- FALSE | |
combustion_cooldown <<- 3*60 | |
combustion_stacks <<- 0 | |
combustioncritperstack <<- 0.1 | |
crit_counter <<- 0 | |
critical_mass_crit <<- 0.06 | |
damage <<- 0 | |
elemental_precision <<- 0.06 | |
evocate_cooldown <<- 8*60 | |
evocating <<- FALSE | |
evocation_duration <<- 8 | |
fire_power_coeff <<- 0.1 | |
fireball_coeff <<- 1 | |
fireball_cost <<- 410 | |
fireball_dot <<- 19 | |
fireball_max <<- 760 | |
fireball_min <<- 596 | |
fireball_timer <<- 20 | |
fireballdot_duration <<- 8 | |
gcd <<- 1.5 | |
idle <<- TRUE | |
ignite_coeff <<- 0.4 | |
ignite_damage <<- 0 | |
ignite_duration <<- 4 | |
ignite_stacks <<- 0 | |
ignitemaxstacks <<- 5 | |
improved_fireball <<- 0.5 | |
mage_armour <<- 0.3 | |
mana_timer <<- 0 | |
master_of_elements_coeff <<- 0.3 | |
mp5rule_timer <<- 0 | |
scorch_cast <<- 1.5 | |
scorch_coeff <<- 0.429 | |
scorch_cost <<- 150 | |
scorch_max <<- 280 | |
scorch_min <<- 237 | |
scorch_stacks <<- 0 | |
scorchdebuff_duration <<- 30 | |
scorchmaxstacks <<- 5 | |
scorchstackcoeff <<- 0.03 | |
time_tick <<- 0.5 | |
total_time <<- 0 | |
clearcast_timer <<- clearcast_duration +1 | |
clearcastcd_timer <<- clearcast_cooldown +1 | |
combustion_timer <<- combustion_cooldown +1 | |
evocatechannel_timer <<- evocation_duration +1 | |
evocatecd_timer <<- evocate_cooldown +1 | |
fireballdot_timer <<- fireballdot_duration +1 | |
fireballtick_timer <<- 3 | |
ignite_timer <<- ignite_duration +1 | |
scorch_timer <<- scorch_cast + 1 | |
scorchstacks_timer <<- scorchdebuff_duration +1 | |
fireball_cast <<- 3.5 - improved_fireball | |
total_mp5 <<- statistics[["mp5"]] | |
total_int <<- statistics[["int"]] + 31 + base_int | |
total_spi <<- statistics[["spi"]] + base_spi | |
total_crit <<- statistics[["crit"]] + 0.01*total_int/54 | |
# total_frostsp <<- statistics[["frostsp"]] + statistics[["sp"]] | |
total_firesp <<- statistics[["firesp"]] + statistics[["sp"]] | |
mana <<- 20 + 15*(total_int - 20) + base_mana + statistics[["mana"]] | |
spirit_reg <<- (12.5 + total_spi/4)/2 | |
# mps_cast_frost <<- total_mp5/5 + 0.45*spirit_reg | |
# crit_mult_frost <<- (0.2+total_crit)*2 + 1-(0.2+total_crit) | |
crit_fire <<- total_crit + critical_mass_crit | |
current_mana <<- mana | |
hit_mult <<- min(0.99,base_hit+elemental_precision+statistics[["hit"]]) | |
}, | |
#custom probability distribution lv 63 (24 resistance) | |
mypdist = function(){ | |
return(sample(c(0,0.25,0.5,0.75),1,prob=c(0.82,0.13,0.04,0.01))) | |
}, | |
gain_mana = function(m){ | |
current_mana <<- min(mana,current_mana + m) | |
}, | |
spend_mana = function(cost){ | |
if(clearcast){ | |
m <-0 | |
clearcast <<- FALSE | |
}else{ | |
m <- cost | |
} | |
#can mana go negative? | |
current_mana <<- current_mana - m | |
}, | |
check_cost = function(cost){ | |
if(clearcast){ | |
m <-0 | |
}else{ | |
m <- cost | |
} | |
if(m <= current_mana){ | |
return(TRUE) | |
}else{ | |
return(FALSE) | |
} | |
}, | |
get_crit = function(){ | |
return(min(1,crit_fire + combustioncritperstack * combustion_stacks)) | |
}, | |
# get_sp = function(){ | |
# | |
# }, | |
dodamage = function(mind,maxd,hit,crit,periodic){ | |
critted <- FALSE | |
#check if hit | |
if(hit >= runif(1)){ | |
#"5/5 fire power" talent and "improved scorch" | |
mult <- (1+fire_power_coeff) * (1 + scorch_stacks * scorchstackcoeff) * (1-mypdist()) | |
#random damage between min and max | |
dmg <- runif(1,mind*mult,maxd*mult) | |
if(!periodic){ | |
#periodic spells can't crit | |
if(crit >= runif(1)){ | |
#crit is 1.5 times (for fire) | |
dmg <- dmg * 1.5 | |
critted <- TRUE | |
#crit will proc ignite "5/5 ignite" talent | |
refresh_ignite(dmg) | |
} | |
#"5/5 arcane Concentration" | |
if(arcaneconcentration_prob >= runif(1) & clearcastcd_timer > clearcast_cooldown){ | |
clearcast <<- TRUE | |
clearcast_timer <<- 0 | |
clearcastcd_timer <<- 0 | |
} | |
if(combustion){combustion_stacks <<- combustion_stacks + 1} | |
} | |
damage <<- damage + dmg | |
}else { | |
dmg <- 0 | |
} | |
return(critted) | |
}, | |
refresh_ignite = function(d){ | |
ignite_timer <<- 0 | |
if(ignite_stacks >= 1){ | |
if (ignite_stacks < ignitemaxstacks){ | |
ignite_stacks <<- ignite_stacks + 1 | |
ignite_damage <<- ignite_damage + ignite_coeff*d | |
} | |
}else{ | |
ignitetick_timer <<- 0 | |
ignite_stacks <<- 1 | |
ignite_damage <<- ignite_coeff*d | |
} | |
}, | |
state_machine = function(){ | |
while(check_cost(fireball_cost) | evocatecd_timer >= evocate_cooldown){ | |
if(mp5rule_timer >=5){ | |
if(evocating){ | |
evo_coeff <- 1.6 | |
}else{ | |
evo_coeff <- 1 | |
} | |
mana_tick <<- 2*(total_mp5/5 + spirit_reg*evo_coeff) | |
}else{ | |
mana_tick <<- 2*(total_mp5/5 + (arcane_meditation_2+mage_armour)*spirit_reg) | |
} | |
if(mana_timer >= 2){ | |
gain_mana(mana_tick) | |
mana_timer <<- 0 | |
} | |
if(idle){ | |
#refresh scorch debuff 3s before expiration | |
if ((scorch_stacks < scorchmaxstacks) | (scorch_stacks == scorchmaxstacks & (scorchdebuff_duration - scorchstacks_timer) <= 3)){ | |
if (check_cost(scorch_cost)){ | |
casting_scorch <<- TRUE | |
idle <<- FALSE | |
scorch_timer <<- 0 | |
} | |
}else{ | |
#combustion available | |
if(!combustion & combustion_timer >= combustion_cooldown){ | |
combustion <<- TRUE | |
combustion_stacks <<- 1 | |
crit_counter <<- 0 | |
} | |
if (check_cost(fireball_cost)){ | |
casting_fireball <<- TRUE | |
idle <<- FALSE | |
fireball_timer <<- 0 | |
}else{ | |
#no mana, time to evocate | |
if(evocatecd_timer >= evocate_cooldown){ | |
evocating <<- TRUE | |
evocatecd_timer <<- 0 | |
idle <<- FALSE | |
#evocation will force you out of mp5 rule | |
mp5rule_timer <<- 6 | |
evocatechannel_timer <<- 0 | |
} | |
} | |
} | |
} | |
if(casting_scorch){ | |
if(scorch_timer >= scorch_cast){ | |
idle <<- TRUE | |
spend_mana(scorch_cost) | |
mp5rule_timer <<- 0 | |
min_dmg <- scorch_min + scorch_coeff * total_firesp | |
max_dmg <- scorch_max + scorch_coeff * total_firesp | |
scorch_critted <- dodamage(min_dmg,max_dmg,hit_mult,get_crit(),FALSE) | |
if(scorch_critted){ | |
#recover mana on crit "3/3 masters of elements" talent | |
gain_mana(master_of_elements_coeff*scorch_cost) | |
if(combustion){crit_counter <<- crit_counter +1} | |
} | |
#"3/3" improved scorch talent | |
#debuff can be hit separatedly from the damage component | |
if(hit_mult >= runif(1)){ | |
scorch_stacks <<- min(scorchmaxstacks,scorch_stacks + 1) | |
scorchstacks_timer <<- 0 | |
} | |
} | |
} | |
if(casting_fireball){ | |
if(fireball_timer >= fireball_cast){ | |
idle <<- TRUE | |
spend_mana(fireball_cost) | |
mp5rule_timer <<- 0 | |
min_dmg <- fireball_min + fireball_coeff * total_firesp | |
max_dmg <- fireball_max + fireball_coeff * total_firesp | |
fireball_critted <- dodamage(min_dmg,max_dmg,hit_mult,get_crit(),FALSE) | |
fireballdot_timer <<- 0 | |
if(fireball_critted){ | |
#recover mana on crit "3/3 masters of elements" talent | |
gain_mana(master_of_elements_coeff*fireball_cost) | |
if(combustion){crit_counter <<- crit_counter +1} | |
} | |
} | |
} | |
if(fireballdot_timer <= fireballdot_duration){ | |
if(fireballtick_timer >= 2){ | |
fireballtick_timer <<- 0 | |
nothing_critted <- dodamage(fireball_dot,fireball_dot,hit_mult,0,TRUE) | |
} | |
} | |
if(scorch_stacks >= 1) {if(scorchstacks_timer > scorchdebuff_duration){scorch_stacks <<- 0}} | |
if(ignite_stacks >= 1) { | |
if(ignite_timer > ignite_duration){ignite_stacks <<- 0} | |
if(ignitetick_timer >= 2){ | |
ignitetick_timer <<- 0 | |
#ignite can't crit also doesn't benefit from hit | |
ignite_critted <- dodamage(ignite_damage/2,ignite_damage/2,base_hit,0,TRUE) | |
} | |
} | |
if(clearcast) {if(clearcast_timer > clearcast_duration){clearcast <<- FALSE}} | |
if(evocating){ | |
if(evocatechannel_timer > evocation_duration){ | |
evocating <<- FALSE | |
idle <<- TRUE | |
} | |
} | |
if(crit_counter >= 3){ | |
crit_counter <<- 0 | |
combustion_stacks <<- 0 | |
combustion <<- FALSE | |
combustion_timer <<- 0 | |
} | |
#update timers | |
if(ignite_stacks >= 1) { | |
ignite_timer <<- ignite_timer + time_tick | |
ignitetick_timer <<- ignitetick_timer + time_tick | |
} | |
if(scorch_stacks >= 1) {scorchstacks_timer <<- scorchstacks_timer + time_tick} | |
if(clearcast) { clearcast_timer <<- clearcast_timer + time_tick} | |
fireballdot_timer <<- fireballdot_timer + time_tick | |
mana_timer <<- mana_timer + time_tick | |
mp5rule_timer <<- mp5rule_timer + time_tick | |
scorch_timer <<- scorch_timer + time_tick | |
fireball_timer <<- fireball_timer + time_tick | |
combustion_timer <<- combustion_timer + time_tick | |
evocatecd_timer <<- evocatecd_timer + time_tick | |
clearcastcd_timer <<- clearcastcd_timer + time_tick | |
if(evocating){evocatechannel_timer <<- evocatechannel_timer + time_tick} | |
total_time <<- total_time + time_tick | |
} | |
} | |
) | |
) | |
#frostbolt_cast <- 3 - 0.5 | |
#frostbolt_min <- 515 | |
#frostbolt_max <- 555 | |
#frostbolt_coeff <- 0.814 | |
#frostbolt_cost <- 290 | |
#frostbolt_avg <- (frostbolt_min+frostbolt_max)/2 | |
#blizzard <- 149 | |
#best <- 0 | |
nbits <- 0 | |
n_list <- vector(mode='list', length=21) | |
b_list <- vector(mode='list', length=21) | |
l_list <- vector(mode='list', length=21) | |
n_list[[1]] <- length(finger_comb[1,]) | |
b_list[[1]] <- decimal2binary(n_list[[1]] -1) | |
l_list[[1]] <- length(b_list[[1]]) | |
nbits <- nbits + l_list[[1]] | |
n_list[[2]] <- length(trinket_comb[2,]) | |
b_list[[2]] <- decimal2binary(n_list[[2]] -1) | |
l_list[[2]] <- length(b_list[[2]]) | |
nbits <- nbits + l_list[[2]] | |
for (i in 3:21){ | |
n_list[[i]] <- nrow(slots[[i]]) | |
b_list[[i]] <- decimal2binary(n_list[[i]] -1) | |
l_list[[i]] <- length(b_list[[i]]) | |
nbits <- nbits + l_list[[i]] | |
} | |
names(n_list) <- paste0("n",slot_names) | |
names(b_list) <- paste0("b",slot_names) | |
names(l_list) <- paste0("l",slot_names) | |
names1 <- function(x){ | |
names <- vector(mode='list', length=23) | |
names[[1]] <- slots[[1]]$name[x[[1]]] | |
names[[2]] <- slots[[1]]$name[x[[2]]] | |
names[[3]] <- slots[[2]]$name[x[[3]]] | |
names[[4]] <- slots[[2]]$name[x[[4]]] | |
for (i in 5:23) { | |
j <- i-2 | |
names[[i]] <- slots[[j]]$name[x[[i]]] | |
} | |
out <- structure(names,names=c("finger1","finger2","trinket1","trinket2",slot_names[3:21])) | |
return(out) | |
} | |
decode1 <- function(y){ | |
x <- gray2binary(y) | |
a <- 1 | |
b <- l_list[[1]] | |
item_indexes <- vector(mode='list', length=23) | |
fingers_index <- min(binary2decimal(x[a:b]) , (n_list[[1]] -1))+1 | |
item_indexes[[1]] <- finger_comb[[1,fingers_index]] | |
item_indexes[[2]] <- finger_comb[[2,fingers_index]] | |
a <- a + l_list[[1]] | |
b <- b + l_list[[2]] | |
trinkets_index <- min(binary2decimal(x[a:b]) , (n_list[[2]] -1))+1 | |
item_indexes[[3]] <- finger_comb[[1,trinkets_index]] | |
item_indexes[[4]] <- finger_comb[[2,trinkets_index]] | |
for (i in 3:21) { | |
a <- a + l_list[[i-1]] | |
b <- b + l_list[[i]] | |
item_indexes[[i+2]] <- min(binary2decimal(x[a:b]) , ( n_list[[i]]-1) )+1 | |
} | |
return(item_indexes) | |
} | |
stats_from_items <- function(par){ | |
total_int <- 0 | |
total_sp <- 0 | |
total_frostsp <- 0 | |
total_firesp <- 0 | |
total_spi <- 0 | |
total_mp5 <- 0 | |
total_crit <- 0 | |
total_hit <- 0 | |
total_PVP <- 0 | |
total_ZG <- 0 | |
total_T0 <- 0 | |
total_T0_5 <- 0 | |
total_T1 <- 0 | |
total_T2 <-0 | |
total_T3 <- 0 | |
total_mana <- 0 | |
i <- 1 | |
for (j in c(1,1,2,2)){ | |
total_int <- sum(total_int,slots[[j]]$int[par[[i]]],na.rm=TRUE) | |
total_sp <- sum(total_sp,slots[[j]]$sp[par[[i]]],na.rm=TRUE) | |
total_frostsp <- sum(total_frostsp,slots[[j]]$frostsp[par[[i]]],na.rm=TRUE) | |
total_firesp <- sum(total_firesp,slots[[j]]$firesp[par[[i]]],na.rm=TRUE) | |
total_spi <- sum(total_spi,slots[[j]]$spi[par[[i]]],na.rm=TRUE) | |
total_mp5 <- sum(total_mp5,slots[[j]]$mp5[par[[i]]],na.rm=TRUE) | |
total_crit <- sum(total_crit,slots[[j]]$crit[par[[i]]],na.rm=TRUE) | |
total_hit <- sum(total_hit,slots[[j]]$hit[par[[i]]],na.rm=TRUE) | |
total_PVP <- sum(total_PVP,slots[[j]]$PVP[par[[i]]],na.rm=TRUE) | |
total_ZG <- sum(total_ZG,slots[[j]]$ZG[par[[i]]],na.rm=TRUE) | |
total_T0 <- sum(total_T0,slots[[j]]$T0[par[[i]]],na.rm=TRUE) | |
total_T0_5 <- sum(total_T0_5,slots[[j]]$T0_5[par[[i]]],na.rm=TRUE) | |
total_T1 <- sum(total_T1,slots[[j]]$T1[par[[i]]],na.rm=TRUE) | |
total_T2 <- sum(total_T2,slots[[j]]$T2[par[[i]]],na.rm=TRUE) | |
total_T3 <- sum(total_T3,slots[[j]]$T3[par[[i]]],na.rm=TRUE) | |
total_mana <- sum(total_mana,slots[[j]]$mana[par[[i]]],na.rm=TRUE) | |
i <- i+1 | |
} | |
for (i in 5:23){ | |
j <- i-2 | |
total_int <- sum(total_int,slots[[j]]$int[par[[i]]],na.rm=TRUE) | |
total_sp <- sum(total_sp,slots[[j]]$sp[par[[i]]],na.rm=TRUE) | |
total_frostsp <- sum(total_frostsp,slots[[j]]$frostsp[par[[i]]],na.rm=TRUE) | |
total_firesp <- sum(total_firesp,slots[[j]]$firesp[par[[i]]],na.rm=TRUE) | |
total_spi <- sum(total_spi,slots[[j]]$spi[par[[i]]],na.rm=TRUE) | |
total_mp5 <- sum(total_mp5,slots[[j]]$mp5[par[[i]]],na.rm=TRUE) | |
total_crit <- sum(total_crit,slots[[j]]$crit[par[[i]]],na.rm=TRUE) | |
total_hit <- sum(total_hit,slots[[j]]$hit[par[[i]]],na.rm=TRUE) | |
total_PVP <- sum(total_PVP,slots[[j]]$PVP[par[[i]]],na.rm=TRUE) | |
total_ZG <- sum(total_ZG,slots[[j]]$ZG[par[[i]]],na.rm=TRUE) | |
total_T0 <- sum(total_T0,slots[[j]]$T0[par[[i]]],na.rm=TRUE) | |
total_T0_5 <- sum(total_T0_5,slots[[j]]$T0_5[par[[i]]],na.rm=TRUE) | |
total_T1 <- sum(total_T1,slots[[j]]$T1[par[[i]]],na.rm=TRUE) | |
total_T2 <- sum(total_T2,slots[[j]]$T2[par[[i]]],na.rm=TRUE) | |
total_T3 <- sum(total_T3,slots[[j]]$T3[par[[i]]],na.rm=TRUE) | |
total_mana <- sum(total_mana,slots[[j]]$mana[par[[i]]],na.rm=TRUE) | |
} | |
if (total_PVP >= 6) { | |
total_sp <- total_sp + 23 | |
print("PVP") | |
} | |
if (total_ZG >= 2) { | |
total_sp <- total_sp + 12 | |
# print("ZG") | |
} | |
if (total_T0 >= 4) { | |
total_sp <- total_sp + 23 | |
} | |
if (total_T0_5 >= 6) { | |
total_sp <- total_sp + 23 | |
} | |
if (total_T1 >= 3) { | |
total_sp <- total_sp + 18 | |
# print("T1") | |
} | |
if (total_T2 >= 8) { | |
frostbolt_cast <- frostbolt_cast * 0.9 + 1.5 * 0.1 | |
} | |
T3extra <- 0 | |
if (total_T3 >= 6) { | |
T3extra <- 200*0.2 | |
} | |
# if (sum(chest$T2_5[ch],feet$T2_5[fe],head$T2_5[he],legs$T2_5[le],shoulder$T2_5[sh],na.rm=TRUE) >= 5{ | |
# } | |
return( | |
structure( | |
c(total_int ,total_sp ,total_frostsp ,total_firesp ,total_spi ,total_mp5 ,total_crit ,total_hit ,total_PVP ,total_ZG ,total_T0 ,total_T0_5 ,total_T1 ,total_T2,total_T3 ,total_mana ), | |
names=c("int","sp","frostsp","firesp","spi","mp5","crit","hit","PVP","ZG","T0","T0_5","T1","T2","T3","mana") | |
) | |
) | |
} | |
fitness1 <- function(x){ | |
stats <- stats_from_items(decode1(x)) | |
#MANA REGEN | |
# mps <- total_mp5/5 + spirit_reg | |
#BLIZZARD SPAM LV<63 | |
# t <- mana / (-mps_cast_frost + 0.9*0.85*1400/8) | |
# damage <- t*1.06*(blizzard + 0.042*total_frostsp) | |
#FROSTBOLT SPAM LV<63 | |
# t <- mana / (-mps_cast_frost + 0.9*0.85*frostbolt_cost/frostbolt_cast) | |
# dps <- 1.06*(crit_mult_frost*(frostbolt_avg+frostbolt_coeff * total_frostsp) + T3extra)/frostbolt_cast | |
# damage <- t*dps | |
#FROSTBOLT SPAM LV=63 | |
# t <- mana / (-mps_cast_frost + 0.9*0.85*frostbolt_cost/frostbolt_cast) | |
# dps <- 1.06*hit_mult*(crit_mult_frost*(frostbolt_avg+frostbolt_coeff * total_frostsp) + T3extra)/frostbolt_cast | |
# damage <- t*dps | |
# #FIRE LV=63 | |
d <- vector("numeric",100) | |
t <- vector("numeric",100) | |
for(i in 1:100){ | |
mage <- new("firemage",statistics=stats) | |
mage$state_machine() | |
d[i] <- mage$damage | |
t[i] <- mage$total_time | |
} | |
dps <- sum(d)/sum(t) | |
return(dps) | |
# return(matrix(c(-damage,-dps),nrow=1)) | |
# return(matrix(c(-mps,-mana),nrow=1)) | |
} | |
#debug(fitness1) | |
GA1 <- ga(type="binary",fitness=fitness1, | |
nBits=nbits, | |
popSize=200,maxiter=3000,run=100,parallel=TRUE | |
) | |
#GA1 <- rmoo(type="binary",fitness=fitness1,strategy = "NSGA-II",nObj=2,monitor=FALSE, | |
# nBits=nbits, | |
# popSize=200,maxiter=1000,run=200 | |
#) | |
summary(GA1) | |
names1(decode1(GA1@solution)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment