RikuSS4

openbeeAE

Oct 9th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 89.77 KB | None | 0 0
  1. ------ Second_Fry's openbee modular fork (v2.0.0)
  2. ------ Original idea and code by Forte40 @ GitHub (forked at v2.2.1)
  3. --- Default configuration
  4. --- All sides are used for peripheral.wrap calls. Can be proxied (check OpenPeripheral Proxy).
  5. local configDefault = {
  6.   ['storageProvider'] = 'openbee/StorageAE.lua', -- allows different storage backends
  7.   ['breederProvider'] = 'openbee/BreederApiary.lua', -- allows different breeder backends
  8.   ["analyzerDir"] = "west", -- direction from storage to analyzer
  9.   ["storageDir"] = "south", -- direction from breeder to storage
  10.   ["productDir"] = "down", -- direction from breeder to product storage
  11.   ["breederDir"] = "north", -- direction from storage to breeder
  12.  
  13.   -- StorageAE block
  14.   ['AE2MEInterfaceProbe'] = true, -- automatic probe for AE2 ME Interface
  15.   -- ['AE2MEInterfaceSide'] = 'north', -- set here to skip probing and setup
  16.  
  17.   -- BreederApiary block
  18.   ['apiaryProbe'] = true, -- automatic probe for Apiary
  19.   -- ['apiarySide'] = 'north', -- set here to skip probing and setup
  20.  
  21.   -- Trait priorities block
  22.   -- You probably down want to edit this, just supply them at runtime. Check README.md
  23.   ["traitPriority"] = {
  24.     "speciesChance",
  25.     "speed",
  26.     "fertility",
  27.     "nocturnal",
  28.     "tolerantFlyer",
  29.     "temperatureTolerance",
  30.     "humidityTolerance",
  31.     "caveDwelling",
  32.     "effect",
  33.     "flowering",
  34.     "flowerProvider",
  35.     "territory"
  36.   },
  37.  
  38.   -- FIXME old stuff, rewrite and remove
  39.   ["ignoreSpecies"] = {
  40.     "Leporine"
  41.   },
  42.   ["useAnalyzer"] = true,
  43.   ["useReferenceBees"] = true -- try to keep 1 pure princess and 1 pure drone
  44. }
  45.  
  46. --- Forte40 code with rewrites
  47. -- All comments in this block below are original
  48. Forte40 = {}
  49. -- utility functions ------------------
  50. function Forte40.choose(list1, list2)
  51.   local newList = {}
  52.   if list2 then
  53.     for i = 1, #list2 do
  54.       for j = 1, #list1 do
  55.         if list1[j] ~= list2[i] then
  56.           table.insert(newList, {list1[j], list2[i]})
  57.         end
  58.       end
  59.     end
  60.   else
  61.     for i = 1, #list1 do
  62.       for j = i, #list1 do
  63.         if list1[i] ~= list1[j] then
  64.           table.insert(newList, {list1[i], list1[j]})
  65.         end
  66.       end
  67.     end
  68.   end
  69.   return newList
  70. end
  71. Forte40.nameFix = {}
  72. -- fix for some versions returning bees.species.*
  73. function Forte40.fixName(name)
  74.   if type(name) == "table" then
  75.     name = name.name
  76.   end
  77.   local newName = name:gsub("bees%.species%.",""):gsub("^.", string.upper)
  78.   if name ~= newName then
  79.     Forte40.nameFix[newName] = name
  80.   end
  81.   return newName
  82. end
  83. function Forte40.fixBee(bee)
  84.   if bee.individual ~= nil then
  85.     bee.individual.displayName = Forte40.fixName(bee.individual.displayName)
  86.     if bee.individual.isAnalyzed then
  87.       bee.individual.active.species.name = Forte40.fixName(bee.individual.active.species.name)
  88.       bee.individual.inactive.species.name = Forte40.fixName(bee.individual.inactive.species.name)
  89.     end
  90.   end
  91.   return bee
  92. end
  93. function Forte40.fixParents(parents)
  94.   parents.allele1 = Forte40.fixName(parents.allele1)
  95.   parents.allele2 = Forte40.fixName(parents.allele2)
  96.   if parents.result then
  97.     parents.result = Forte40.fixName(parents.result)
  98.   end
  99.   return parents
  100. end
  101. function Forte40.beeName(bee)
  102.   if bee.individual.active then
  103.     return bee.individual.active.species.name:sub(1,3) .. "-" ..
  104.         bee.individual.inactive.species.name:sub(1,3)
  105.   else
  106.     return bee.individual.displayName:sub(1,3)
  107.   end
  108. end
  109. -- mutations and scoring --------------
  110. -- build mutation graph
  111.  
  112. -- mutations and scoring --------------
  113.  
  114. function getBeeBreedingDataTemp()
  115.   breedingTable = {}
  116.   breedingTable[0] = {
  117.     ['allele1'] = "Common",
  118.     ['specialConditions'] = {},
  119.     ['allele2'] = "Forest",
  120.     ['result'] = "Cultivated",
  121.     ['chance'] = 12
  122.    }
  123.   breedingTable[1] = {
  124.      ['allele1'] = "Blizzy",
  125.      ['specialConditions'] = {},
  126.      ['allele2'] = "Icy",
  127.      ['result'] = "Gelid",
  128.      ['chance'] = 8
  129.     }
  130.   breedingTable[2] = {
  131.      ['allele1'] = "Platinum",
  132.      ['specialConditions'] = {},
  133.      ['allele2'] = "Oblivion",
  134.      ['result'] = "Winsome",
  135.      ['chance'] = 12
  136.     }
  137.   breedingTable[3] = {
  138.      ['allele1'] = "Winsome",
  139.      ['specialConditions'] = {[1] = "Requires a foundation of Enderium Block"},
  140.      ['allele2'] = "Carbon",
  141.      ['result'] = "Endearing",
  142.      ['chance'] = 8
  143.     }
  144.   breedingTable[4] = {
  145.      ['allele1'] = "Energetic",
  146.      ['specialConditions'] = {},
  147.      ['allele2'] = "Silicon",
  148.      ['result'] = "Infinity",
  149.      ['chance'] = 2
  150.     }
  151.   breedingTable[5] = {
  152.      ['allele1'] = "Excited",
  153.      ['specialConditions'] = {},
  154.      ['allele2'] = "Lapis",
  155.      ['result'] = "Electrotine",
  156.      ['chance'] = 2
  157.     }
  158.   breedingTable[6] = {
  159.      ['allele1'] = "Skystone",
  160.      ['specialConditions'] = {},
  161.      ['allele2'] = "Ferrous",
  162.      ['result'] = "Silicon",
  163.      ['chance'] = 17
  164.     }
  165.   breedingTable[7] = {
  166.      ['allele1'] = "Earthen",
  167.      ['specialConditions'] = {},
  168.      ['allele2'] = "Windy",
  169.      ['result'] = "Skystone",
  170.      ['chance'] = 2
  171.     }
  172.   return breedingTable
  173. end
  174. function getBeeBreedingData()
  175.   breedingTable = {}
  176.   breedingTable[1] = {
  177.     ['allele1'] = "Forest",
  178.     ['specialConditions'] = {},
  179.     ['allele2'] = "Meadows",
  180.     ['result'] = "Common",
  181.     ['chance'] = 15
  182.   }
  183.   breedingTable[2] = {
  184.     ['allele1'] = "Modest",
  185.     ['specialConditions'] = {},
  186.     ['allele2'] = "Forest",
  187.     ['result'] = "Common",
  188.     ['chance'] = 15
  189.   }
  190.   breedingTable[3] = {
  191.     ['allele1'] = "Modest",
  192.     ['specialConditions'] = {},
  193.     ['allele2'] = "Meadows",
  194.     ['result'] = "Common",
  195.     ['chance'] = 15
  196.   }
  197.   breedingTable[4] = {
  198.     ['allele1'] = "Wintry",
  199.     ['specialConditions'] = {},
  200.     ['allele2'] = "Forest",
  201.     ['result'] = "Common",
  202.     ['chance'] = 15
  203.   }
  204.   breedingTable[5] = {
  205.     ['allele1'] = "Wintry",
  206.     ['specialConditions'] = {},
  207.     ['allele2'] = "Meadows",
  208.     ['result'] = "Common",
  209.     ['chance'] = 15
  210.   }
  211.   breedingTable[6] = {
  212.     ['allele1'] = "Wintry",
  213.     ['specialConditions'] = {},
  214.     ['allele2'] = "Modest",
  215.     ['result'] = "Common",
  216.     ['chance'] = 15
  217.   }
  218.   breedingTable[7] = {
  219.     ['allele1'] = "Tropical",
  220.     ['specialConditions'] = {},
  221.     ['allele2'] = "Forest",
  222.     ['result'] = "Common",
  223.     ['chance'] = 15
  224.   }
  225.   breedingTable[8] = {
  226.     ['allele1'] = "Tropical",
  227.     ['specialConditions'] = {},
  228.     ['allele2'] = "Meadows",
  229.     ['result'] = "Common",
  230.     ['chance'] = 15
  231.   }
  232.   breedingTable[9] = {
  233.     ['allele1'] = "Tropical",
  234.     ['specialConditions'] = {},
  235.     ['allele2'] = "Modest",
  236.     ['result'] = "Common",
  237.     ['chance'] = 15
  238.   }
  239.   breedingTable[10] = {
  240.     ['allele1'] = "Tropical",
  241.     ['specialConditions'] = {},
  242.     ['allele2'] = "Wintry",
  243.     ['result'] = "Common",
  244.     ['chance'] = 15
  245.    }
  246.   breedingTable[11] = {
  247.     ['allele1'] = "Marshy",
  248.     ['specialConditions'] = {},
  249.     ['allele2'] = "Forest",
  250.     ['result'] = "Common",
  251.     ['chance'] = 15
  252.    }
  253.   breedingTable[12] = {
  254.     ['allele1'] = "Marshy",
  255.     ['specialConditions'] = {},
  256.     ['allele2'] = "Meadows",
  257.     ['result'] = "Common",
  258.     ['chance'] = 15
  259.    }
  260.   breedingTable[13] = {
  261.     ['allele1'] = "Marshy",
  262.     ['specialConditions'] = {},
  263.     ['allele2'] = "Modest",
  264.     ['result'] = "Common",
  265.     ['chance'] = 15
  266.    }
  267.   breedingTable[14] = {
  268.     ['allele1'] = "Marshy",
  269.     ['specialConditions'] = {},
  270.     ['allele2'] = "Wintry",
  271.     ['result'] = "Common",
  272.     ['chance'] = 15
  273.    }
  274.   breedingTable[15] = {
  275.     ['allele1'] = "Marshy",
  276.     ['specialConditions'] = {},
  277.     ['allele2'] = "Tropical",
  278.     ['result'] = "Common",
  279.     ['chance'] = 15
  280.    }
  281.   breedingTable[16] = {
  282.     ['allele1'] = "Common",
  283.     ['specialConditions'] = {},
  284.     ['allele2'] = "Forest",
  285.     ['result'] = "Cultivated",
  286.     ['chance'] = 12
  287.    }
  288.   breedingTable[17] = {
  289.     ['allele1'] = "Common",
  290.     ['specialConditions'] = {},
  291.     ['allele2'] = "Meadows",
  292.     ['result'] = "Cultivated",
  293.     ['chance'] = 12
  294.    }
  295.   breedingTable[18] = {
  296.     ['allele1'] = "Common",
  297.     ['specialConditions'] = {},
  298.     ['allele2'] = "Modest",
  299.     ['result'] = "Cultivated",
  300.     ['chance'] = 12
  301.    }
  302.   breedingTable[19] = {
  303.     ['allele1'] = "Common",
  304.     ['specialConditions'] = {},
  305.     ['allele2'] = "Wintry",
  306.     ['result'] = "Cultivated",
  307.     ['chance'] = 12
  308.    }
  309.   breedingTable[20] = {
  310.     ['allele1'] = "Common",
  311.     ['specialConditions'] = {},
  312.     ['allele2'] = "Tropical",
  313.     ['result'] = "Cultivated",
  314.     ['chance'] = 12
  315.    }
  316.   breedingTable[21] = {
  317.     ['allele1'] = "Common",
  318.     ['specialConditions'] = {},
  319.     ['allele2'] = "Marshy",
  320.     ['result'] = "Cultivated",
  321.     ['chance'] = 12
  322.    }
  323.   breedingTable[22] = {
  324.     ['allele1'] = "Common",
  325.     ['specialConditions'] = {},
  326.     ['allele2'] = "Cultivated",
  327.     ['result'] = "Noble",
  328.     ['chance'] = 10
  329.    }
  330.   breedingTable[23] = {
  331.     ['allele1'] = "Noble",
  332.     ['specialConditions'] = {},
  333.     ['allele2'] = "Cultivated",
  334.     ['result'] = "Majestic",
  335.     ['chance'] = 8
  336.    }
  337.   breedingTable[24] = {
  338.     ['allele1'] = "Noble",
  339.     ['specialConditions'] = {},
  340.     ['allele2'] = "Majestic",
  341.     ['result'] = "Imperial",
  342.     ['chance'] = 8
  343.    }
  344.   breedingTable[25] = {
  345.     ['allele1'] = "Common",
  346.     ['specialConditions'] = {},
  347.     ['allele2'] = "Cultivated",
  348.     ['result'] = "Diligent",
  349.     ['chance'] = 10
  350.    }
  351.   breedingTable[26] = {
  352.     ['allele1'] = "Diligent",
  353.     ['specialConditions'] = {},
  354.     ['allele2'] = "Cultivated",
  355.     ['result'] = "Unweary",
  356.     ['chance'] = 8
  357.    }
  358.   breedingTable[27] = {
  359.     ['allele1'] = "Diligent",
  360.     ['specialConditions'] = {},
  361.     ['allele2'] = "Unweary",
  362.     ['result'] = "Industrious",
  363.     ['chance'] = 8
  364.    }
  365.   breedingTable[28] = {
  366.     ['allele1'] = "Steadfast",
  367.     ['specialConditions'] = {[1] = "Is restricted to FOREST-like environments."},
  368.     ['allele2'] = "Valiant",
  369.     ['result'] = "Heroic",
  370.     ['chance'] = 6
  371.    }
  372.   breedingTable[29] = {
  373.     ['allele1'] = "Modest",
  374.     ['specialConditions'] = {[1] = "Is restricted to NETHER-like environments."},
  375.     ['allele2'] = "Cultivated",
  376.     ['result'] = "Sinister",
  377.     ['chance'] = 60
  378.    }
  379.   breedingTable[30] = {
  380.     ['allele1'] = "Tropical",
  381.     ['specialConditions'] = {},
  382.     ['allele2'] = "Cultivated",
  383.     ['result'] = "Sinister",
  384.     ['chance'] = 60
  385.    }
  386.   breedingTable[31] = {
  387.     ['allele1'] = "Sinister",
  388.     ['specialConditions'] = {},
  389.     ['allele2'] = "Cultivated",
  390.     ['result'] = "Fiendish",
  391.     ['chance'] = 40
  392.    }
  393.   breedingTable[32] = {
  394.     ['allele1'] = "Sinister",
  395.     ['specialConditions'] = {},
  396.     ['allele2'] = "Modest",
  397.     ['result'] = "Fiendish",
  398.     ['chance'] = 40
  399.    }
  400.   breedingTable[33] = {
  401.     ['allele1'] = "Sinister",
  402.     ['specialConditions'] = {},
  403.     ['allele2'] = "Tropical",
  404.     ['result'] = "Fiendish",
  405.     ['chance'] = 40
  406.    }
  407.   breedingTable[34] = {
  408.     ['allele1'] = "Sinister",
  409.     ['specialConditions'] = {},
  410.     ['allele2'] = "Fiendish",
  411.     ['result'] = "Demonic",
  412.     ['chance'] = 25
  413.    }
  414.   breedingTable[35] = {
  415.     ['allele1'] = "Modest",
  416.     ['specialConditions'] = {
  417.       [1] = "Temperature between WARM and HOT.",
  418.       [2] = "Humidity ARID required.",
  419.       },
  420.     ['allele2'] = "Sinister",
  421.     ['result'] = "Frugal",
  422.     ['chance'] = 16
  423.    }
  424.   breedingTable[36] = {
  425.     ['allele1'] = "Modest",
  426.     ['specialConditions'] = {},
  427.     ['allele2'] = "Fiendish",
  428.     ['result'] = "Frugal",
  429.     ['chance'] = 10
  430.    }
  431.   breedingTable[37] = {
  432.     ['allele1'] = "Modest",
  433.     ['specialConditions'] = {},
  434.     ['allele2'] = "Frugal",
  435.     ['result'] = "Austere",
  436.     ['chance'] = 8
  437.    }
  438.   breedingTable[38] = {
  439.     ['allele1'] = "Austere",
  440.     ['specialConditions'] = {},
  441.     ['allele2'] = "Tropical",
  442.     ['result'] = "Exotic",
  443.     ['chance'] = 12
  444.    }
  445.   breedingTable[39] = {
  446.     ['allele1'] = "Exotic",
  447.     ['specialConditions'] = {},
  448.     ['allele2'] = "Tropical",
  449.     ['result'] = "Edenic",
  450.     ['chance'] = 8
  451.    }
  452.   breedingTable[40] = {
  453.     ['allele1'] = "Industrious",
  454.     ['specialConditions'] = {[1] = "Temperature between ICY and COLD."},
  455.     ['allele2'] = "Wintry",
  456.     ['result'] = "Icy",
  457.     ['chance'] = 12
  458.    }
  459.   breedingTable[41] = {
  460.     ['allele1'] = "Icy",
  461.     ['specialConditions'] = {},
  462.     ['allele2'] = "Wintry",
  463.     ['result'] = "Glacial",
  464.     ['chance'] = 8
  465.    }
  466.   breedingTable[42] = {
  467.     ['allele1'] = "Meadows",
  468.     ['specialConditions'] = {},
  469.     ['allele2'] = "Forest",
  470.     ['result'] = "Leporine",
  471.     ['chance'] = 10
  472.    }
  473.   breedingTable[43] = {
  474.     ['allele1'] = "Wintry",
  475.     ['specialConditions'] = {},
  476.     ['allele2'] = "Forest",
  477.     ['result'] = "Merry",
  478.     ['chance'] = 10
  479.    }
  480.   breedingTable[44] = {
  481.     ['allele1'] = "Wintry",
  482.     ['specialConditions'] = {},
  483.     ['allele2'] = "Meadows",
  484.     ['result'] = "Tipsy",
  485.     ['chance'] = 10
  486.    }
  487.   breedingTable[45] = {
  488.     ['allele1'] = "Sinister",
  489.     ['specialConditions'] = {},
  490.     ['allele2'] = "Common",
  491.     ['result'] = "Tricky",
  492.     ['chance'] = 10
  493.    }
  494.   breedingTable[46] = {
  495.     ['allele1'] = "Meadows",
  496.     ['specialConditions'] = {[1] = "Is restricted to PLAINS-like environments."},
  497.     ['allele2'] = "Diligent",
  498.     ['result'] = "Rural",
  499.     ['chance'] = 12
  500.    }
  501.   breedingTable[47] = {
  502.     ['allele1'] = "Monastic",
  503.     ['specialConditions'] = {},
  504.     ['allele2'] = "Austere",
  505.     ['result'] = "Secluded",
  506.     ['chance'] = 12
  507.    }
  508.   breedingTable[48] = {
  509.     ['allele1'] = "Monastic",
  510.     ['specialConditions'] = {},
  511.     ['allele2'] = "Secluded",
  512.     ['result'] = "Hermitic",
  513.     ['chance'] = 8
  514.    }
  515.   breedingTable[49] = {
  516.     ['allele1'] = "Hermitic",
  517.     ['specialConditions'] = {},
  518.     ['allele2'] = "Ender",
  519.     ['result'] = "Spectral",
  520.     ['chance'] = 4
  521.    }
  522.   breedingTable[50] = {
  523.     ['allele1'] = "Spectral",
  524.     ['specialConditions'] = {},
  525.     ['allele2'] = "Ender",
  526.     ['result'] = "Phantasmal",
  527.     ['chance'] = 2
  528.    }
  529.   breedingTable[51] = {
  530.     ['allele1'] = "Monastic",
  531.     ['specialConditions'] = {},
  532.     ['allele2'] = "Demonic",
  533.     ['result'] = "Vindictive",
  534.     ['chance'] = 4
  535.    }
  536.   breedingTable[52] = {
  537.     ['allele1'] = "Demonic",
  538.     ['specialConditions'] = {},
  539.     ['allele2'] = "Vindictive",
  540.     ['result'] = "Vengeful",
  541.     ['chance'] = 8
  542.    }
  543.   breedingTable[53] = {
  544.     ['allele1'] = "Monastic",
  545.     ['specialConditions'] = {},
  546.     ['allele2'] = "Vindictive",
  547.     ['result'] = "Vengeful",
  548.     ['chance'] = 8
  549.    }
  550.   breedingTable[54] = {
  551.     ['allele1'] = "Vengeful",
  552.     ['specialConditions'] = {},
  553.     ['allele2'] = "Vindictive",
  554.     ['result'] = "Avenging",
  555.     ['chance'] = 4
  556.    }
  557.   breedingTable[55] = {
  558.     ['allele1'] = "Meadows",
  559.     ['specialConditions'] = {},
  560.     ['allele2'] = "Modest",
  561.     ['result'] = "Arid",
  562.     ['chance'] = 10
  563.    }
  564.   breedingTable[56] = {
  565.     ['allele1'] = "Arid",
  566.     ['specialConditions'] = {},
  567.     ['allele2'] = "Common",
  568.     ['result'] = "Barren",
  569.     ['chance'] = 8
  570.    }
  571.   breedingTable[57] = {
  572.     ['allele1'] = "Arid",
  573.     ['specialConditions'] = {},
  574.     ['allele2'] = "Barren",
  575.     ['result'] = "Desolate",
  576.     ['chance'] = 8
  577.    }
  578.   breedingTable[58] = {
  579.     ['allele1'] = "Barren",
  580.     ['specialConditions'] = {},
  581.     ['allele2'] = "Forest",
  582.     ['result'] = "Gnawing",
  583.     ['chance'] = 15
  584.    }
  585.   breedingTable[59] = {
  586.     ['allele1'] = "Desolate",
  587.     ['specialConditions'] = {},
  588.     ['allele2'] = "Modest",
  589.     ['result'] = "Decaying",
  590.     ['chance'] = 15
  591.    }
  592.   breedingTable[60] = {
  593.     ['allele1'] = "Desolate",
  594.     ['specialConditions'] = {},
  595.     ['allele2'] = "Frugal",
  596.     ['result'] = "Skeletal",
  597.     ['chance'] = 15
  598.    }
  599.   breedingTable[61] = {
  600.     ['allele1'] = "Desolate",
  601.     ['specialConditions'] = {},
  602.     ['allele2'] = "Austere",
  603.     ['result'] = "Creepy",
  604.     ['chance'] = 15
  605.    }
  606.   breedingTable[62] = {
  607.     ['allele1'] = "Gnawing",
  608.     ['specialConditions'] = {},
  609.     ['allele2'] = "Common",
  610.     ['result'] = "Decomposing",
  611.     ['chance'] = 15
  612.    }
  613.   breedingTable[63] = {
  614.     ['allele1'] = "Rocky",
  615.     ['specialConditions'] = {},
  616.     ['allele2'] = "Diligent",
  617.     ['result'] = "Tolerant",
  618.     ['chance'] = 15
  619.    }
  620.   breedingTable[64] = {
  621.     ['allele1'] = "Rocky",
  622.     ['specialConditions'] = {},
  623.     ['allele2'] = "Tolerant",
  624.     ['result'] = "Robust",
  625.     ['chance'] = 15
  626.    }
  627.   breedingTable[65] = {
  628.     ['allele1'] = "Imperial",
  629.     ['specialConditions'] = {},
  630.     ['allele2'] = "Robust",
  631.     ['result'] = "Resilient",
  632.     ['chance'] = 15
  633.    }
  634.   breedingTable[66] = {
  635.     ['allele1'] = "Resilient",
  636.     ['specialConditions'] = {},
  637.     ['allele2'] = "Meadows",
  638.     ['result'] = "Rusty",
  639.     ['chance'] = 5
  640.    }
  641.   breedingTable[67] = {
  642.     ['allele1'] = "Resilient",
  643.     ['specialConditions'] = {},
  644.     ['allele2'] = "Forest",
  645.     ['result'] = "Corroded",
  646.     ['chance'] = 5
  647.    }
  648.   breedingTable[68] = {
  649.     ['allele1'] = "Resilient",
  650.     ['specialConditions'] = {},
  651.     ['allele2'] = "Marshy",
  652.     ['result'] = "Tarnished",
  653.     ['chance'] = 5
  654.    }
  655.   breedingTable[69] = {
  656.     ['allele1'] = "Resilient",
  657.     ['specialConditions'] = {},
  658.     ['allele2'] = "Unweary",
  659.     ['result'] = "Leaden",
  660.     ['chance'] = 5
  661.    }
  662.   breedingTable[70] = {
  663.     ['allele1'] = "Resilient",
  664.     ['specialConditions'] = {},
  665.     ['allele2'] = "Unweary",
  666.     ['result'] = "Lustered",
  667.     ['chance'] = 10
  668.    }
  669.   breedingTable[71] = {
  670.     ['allele1'] = "Rusty",
  671.     ['specialConditions'] = {},
  672.     ['allele2'] = "Imperial",
  673.     ['result'] = "Shining",
  674.     ['chance'] = 2
  675.    }
  676.   breedingTable[72] = {
  677.     ['allele1'] = "Corroded",
  678.     ['specialConditions'] = {},
  679.     ['allele2'] = "Imperial",
  680.     ['result'] = "Glittering",
  681.     ['chance'] = 2
  682.    }
  683.   breedingTable[73] = {
  684.     ['allele1'] = "Glittering",
  685.     ['specialConditions'] = {},
  686.     ['allele2'] = "Shining",
  687.     ['result'] = "Valuable",
  688.     ['chance'] = 2
  689.    }
  690.   breedingTable[74] = {
  691.     ['allele1'] = "Resilient",
  692.     ['specialConditions'] = {},
  693.     ['allele2'] = "Water",
  694.     ['result'] = "Lapis",
  695.     ['chance'] = 5
  696.    }
  697.   breedingTable[75] = {
  698.     ['allele1'] = "Lapis",
  699.     ['specialConditions'] = {},
  700.     ['allele2'] = "Noble",
  701.     ['result'] = "Emerald",
  702.     ['chance'] = 5
  703.    }
  704.   breedingTable[76] = {
  705.     ['allele1'] = "Emerald",
  706.     ['specialConditions'] = {},
  707.     ['allele2'] = "Austere",
  708.     ['result'] = "Ruby",
  709.     ['chance'] = 5
  710.    }
  711.   breedingTable[77] = {
  712.     ['allele1'] = "Emerald",
  713.     ['specialConditions'] = {},
  714.     ['allele2'] = "Ocean",
  715.     ['result'] = "Sapphire",
  716.     ['chance'] = 5
  717.    }
  718.   breedingTable[78] = {
  719.     ['allele1'] = "Lapis",
  720.     ['specialConditions'] = {},
  721.     ['allele2'] = "Imperial",
  722.     ['result'] = "Diamond",
  723.     ['chance'] = 5
  724.    }
  725.   breedingTable[79] = {
  726.     ['allele1'] = "Austere",
  727.     ['specialConditions'] = {},
  728.     ['allele2'] = "Rocky",
  729.     ['result'] = "Unstable",
  730.     ['chance'] = 5
  731.    }
  732.   breedingTable[80] = {
  733.     ['allele1'] = "Unstable",
  734.     ['specialConditions'] = {},
  735.     ['allele2'] = "Rusty",
  736.     ['result'] = "Nuclear",
  737.     ['chance'] = 5
  738.    }
  739.   breedingTable[81] = {
  740.     ['allele1'] = "Nuclear",
  741.     ['specialConditions'] = {},
  742.     ['allele2'] = "Glittering",
  743.     ['result'] = "Radioactive",
  744.     ['chance'] = 5
  745.    }
  746.   breedingTable[82] = {
  747.     ['allele1'] = "Noble",
  748.     ['specialConditions'] = {},
  749.     ['allele2'] = "Diligent",
  750.     ['result'] = "Ancient",
  751.     ['chance'] = 10
  752.    }
  753.   breedingTable[83] = {
  754.     ['allele1'] = "Ancient",
  755.     ['specialConditions'] = {},
  756.     ['allele2'] = "Noble",
  757.     ['result'] = "Primeval",
  758.     ['chance'] = 8
  759.    }
  760.   breedingTable[84] = {
  761.     ['allele1'] = "Primeval",
  762.     ['specialConditions'] = {},
  763.     ['allele2'] = "Majestic",
  764.     ['result'] = "Prehistoric",
  765.     ['chance'] = 8
  766.    }
  767.   breedingTable[85] = {
  768.     ['allele1'] = "Prehistoric",
  769.     ['specialConditions'] = {},
  770.     ['allele2'] = "Imperial",
  771.     ['result'] = "Relic",
  772.     ['chance'] = 8
  773.    }
  774.   breedingTable[86] = {
  775.     ['allele1'] = "Primeval",
  776.     ['specialConditions'] = {},
  777.     ['allele2'] = "Growing",
  778.     ['result'] = "Fossilised",
  779.     ['chance'] = 8
  780.    }
  781.   breedingTable[87] = {
  782.     ['allele1'] = "Primeval",
  783.     ['specialConditions'] = {},
  784.     ['allele2'] = "Fungal",
  785.     ['result'] = "Resinous",
  786.     ['chance'] = 8
  787.    }
  788.   breedingTable[88] = {
  789.     ['allele1'] = "Primeval",
  790.     ['specialConditions'] = {},
  791.     ['allele2'] = "Ocean",
  792.     ['result'] = "Oily",
  793.     ['chance'] = 8
  794.    }
  795.   breedingTable[89] = {
  796.     ['allele1'] = "Primeval",
  797.     ['specialConditions'] = {},
  798.     ['allele2'] = "Boggy",
  799.     ['result'] = "Preserved",
  800.     ['chance'] = 8
  801.    }
  802.   breedingTable[90] = {
  803.     ['allele1'] = "Oily",
  804.     ['specialConditions'] = {},
  805.     ['allele2'] = "Industrious",
  806.     ['result'] = "Distilled",
  807.     ['chance'] = 8
  808.    }
  809.   breedingTable[91] = {
  810.     ['allele1'] = "Oily",
  811.     ['specialConditions'] = {},
  812.     ['allele2'] = "Distilled",
  813.     ['result'] = "Refined",
  814.     ['chance'] = 8
  815.    }
  816.   breedingTable[92] = {
  817.     ['allele1'] = "Refined",
  818.     ['specialConditions'] = {},
  819.     ['allele2'] = "Fossilised",
  820.     ['result'] = "Tarry",
  821.     ['chance'] = 8
  822.    }
  823.   breedingTable[93] = {
  824.     ['allele1'] = "Refined",
  825.     ['specialConditions'] = {},
  826.     ['allele2'] = "Resinous",
  827.     ['result'] = "Elastic",
  828.     ['chance'] = 8
  829.    }
  830.   breedingTable[94] = {
  831.     ['allele1'] = "Water",
  832.     ['specialConditions'] = {},
  833.     ['allele2'] = "Common",
  834.     ['result'] = "River",
  835.     ['chance'] = 10
  836.    }
  837.   breedingTable[95] = {
  838.     ['allele1'] = "Water",
  839.     ['specialConditions'] = {
  840. [1] = "Hive needs to be in Ocean",
  841.                             },
  842.     ['allele2'] = "Diligent",
  843.     ['result'] = "Ocean",
  844.     ['chance'] = 10
  845.    }
  846.   breedingTable[96] = {
  847.     ['allele1'] = "Ebony",
  848.     ['specialConditions'] = {},
  849.     ['allele2'] = "Ocean",
  850.     ['result'] = "Stained",
  851.     ['chance'] = 8
  852.    }
  853.   breedingTable[97] = {
  854.     ['allele1'] = "Diligent",
  855.     ['specialConditions'] = {},
  856.     ['allele2'] = "Forest",
  857.     ['result'] = "Growing",
  858.     ['chance'] = 10
  859.    }
  860.   breedingTable[98] = {
  861.     ['allele1'] = "Growing",
  862.     ['specialConditions'] = {},
  863.     ['allele2'] = "Rural",
  864.     ['result'] = "Thriving",
  865.     ['chance'] = 10
  866.    }
  867.   breedingTable[99] = {
  868.     ['allele1'] = "Thriving",
  869.     ['specialConditions'] = {},
  870.     ['allele2'] = "Growing",
  871.     ['result'] = "Blooming",
  872.     ['chance'] = 8
  873.    }
  874.   breedingTable[100] = {
  875.      ['allele1'] = "Valiant",
  876.      ['specialConditions'] = {},
  877.      ['allele2'] = "Diligent",
  878.      ['result'] = "Sweetened",
  879.      ['chance'] = 15
  880.     }
  881.   breedingTable[101] = {
  882.      ['allele1'] = "Sweetened",
  883.      ['specialConditions'] = {},
  884.      ['allele2'] = "Diligent",
  885.      ['result'] = "Sugary",
  886.      ['chance'] = 15
  887.     }
  888.   breedingTable[102] = {
  889.      ['allele1'] = "Sugary",
  890.      ['specialConditions'] = {},
  891.      ['allele2'] = "Forest",
  892.      ['result'] = "Ripening",
  893.      ['chance'] = 5
  894.     }
  895.   breedingTable[103] = {
  896.      ['allele1'] = "Ripening",
  897.      ['specialConditions'] = {},
  898.      ['allele2'] = "Rural",
  899.      ['result'] = "Fruity",
  900.      ['chance'] = 5
  901.     }
  902.   breedingTable[104] = {
  903.      ['allele1'] = "Cultivated",
  904.      ['specialConditions'] = {},
  905.      ['allele2'] = "Rural",
  906.      ['result'] = "Farmed",
  907.      ['chance'] = 10
  908.     }
  909.   breedingTable[105] = {
  910.      ['allele1'] = "Rural",
  911.      ['specialConditions'] = {},
  912.      ['allele2'] = "Water",
  913.      ['result'] = "Bovine",
  914.      ['chance'] = 10
  915.     }
  916.   breedingTable[106] = {
  917.      ['allele1'] = "Tropical",
  918.      ['specialConditions'] = {},
  919.      ['allele2'] = "Rural",
  920.      ['result'] = "Caffeinated",
  921.      ['chance'] = 10
  922.     }
  923.   breedingTable[107] = {
  924.      ['allele1'] = "Common",
  925.      ['specialConditions'] = {},
  926.      ['allele2'] = "Marshy",
  927.      ['result'] = "Damp",
  928.      ['chance'] = 10
  929.     }
  930.   breedingTable[108] = {
  931.      ['allele1'] = "Damp",
  932.      ['specialConditions'] = {},
  933.      ['allele2'] = "Marshy",
  934.      ['result'] = "Boggy",
  935.      ['chance'] = 8
  936.     }
  937.   breedingTable[109] = {
  938.      ['allele1'] = "Boggy",
  939.      ['specialConditions'] = {},
  940.      ['allele2'] = "Damp",
  941.      ['result'] = "Fungal",
  942.      ['chance'] = 8
  943.     }
  944.   breedingTable[110] = {
  945.      ['allele1'] = "Water",
  946.      ['specialConditions'] = {},
  947.      ['allele2'] = "Forest",
  948.      ['result'] = "Common",
  949.      ['chance'] = 15
  950.     }
  951.   breedingTable[111] = {
  952.      ['allele1'] = "Water",
  953.      ['specialConditions'] = {},
  954.      ['allele2'] = "Meadows",
  955.      ['result'] = "Common",
  956.      ['chance'] = 15
  957.     }
  958.   breedingTable[112] = {
  959.      ['allele1'] = "Water",
  960.      ['specialConditions'] = {},
  961.      ['allele2'] = "Modest",
  962.      ['result'] = "Common",
  963.      ['chance'] = 15
  964.     }
  965.   breedingTable[113] = {
  966.      ['allele1'] = "Water",
  967.      ['specialConditions'] = {},
  968.      ['allele2'] = "Tropical",
  969.      ['result'] = "Common",
  970.      ['chance'] = 15
  971.     }
  972.   breedingTable[114] = {
  973.      ['allele1'] = "Water",
  974.      ['specialConditions'] = {},
  975.      ['allele2'] = "Marshy",
  976.      ['result'] = "Common",
  977.      ['chance'] = 15
  978.     }
  979.   breedingTable[115] = {
  980.      ['allele1'] = "Water",
  981.      ['specialConditions'] = {},
  982.      ['allele2'] = "Wintry",
  983.      ['result'] = "Common",
  984.      ['chance'] = 15
  985.     }
  986.   breedingTable[116] = {
  987.      ['allele1'] = "Water",
  988.      ['specialConditions'] = {},
  989.      ['allele2'] = "Rocky",
  990.      ['result'] = "Common",
  991.      ['chance'] = 15
  992.     }
  993.   breedingTable[117] = {
  994.      ['allele1'] = "Water",
  995.      ['specialConditions'] = {},
  996.      ['allele2'] = "Embittered",
  997.      ['result'] = "Common",
  998.      ['chance'] = 15
  999.     }
  1000.   breedingTable[118] = {
  1001.      ['allele1'] = "Rocky",
  1002.      ['specialConditions'] = {},
  1003.      ['allele2'] = "Forest",
  1004.      ['result'] = "Common",
  1005.      ['chance'] = 15
  1006.     }
  1007.   breedingTable[119] = {
  1008.      ['allele1'] = "Rocky",
  1009.      ['specialConditions'] = {},
  1010.      ['allele2'] = "Meadows",
  1011.      ['result'] = "Common",
  1012.      ['chance'] = 15
  1013.     }
  1014.   breedingTable[120] = {
  1015.      ['allele1'] = "Rocky",
  1016.      ['specialConditions'] = {},
  1017.      ['allele2'] = "Modest",
  1018.      ['result'] = "Common",
  1019.      ['chance'] = 15
  1020.     }
  1021.   breedingTable[121] = {
  1022.      ['allele1'] = "Rocky",
  1023.      ['specialConditions'] = {},
  1024.      ['allele2'] = "Tropical",
  1025.      ['result'] = "Common",
  1026.      ['chance'] = 15
  1027.     }
  1028.   breedingTable[122] = {
  1029.      ['allele1'] = "Rocky",
  1030.      ['specialConditions'] = {},
  1031.      ['allele2'] = "Marshy",
  1032.      ['result'] = "Common",
  1033.      ['chance'] = 15
  1034.     }
  1035.   breedingTable[123] = {
  1036.      ['allele1'] = "Rocky",
  1037.      ['specialConditions'] = {},
  1038.      ['allele2'] = "Wintry",
  1039.      ['result'] = "Common",
  1040.      ['chance'] = 15
  1041.     }
  1042.   breedingTable[124] = {
  1043.      ['allele1'] = "Rocky",
  1044.      ['specialConditions'] = {},
  1045.      ['allele2'] = "Embittered",
  1046.      ['result'] = "Common",
  1047.      ['chance'] = 15
  1048.     }
  1049.   breedingTable[125] = {
  1050.      ['allele1'] = "Water",
  1051.      ['specialConditions'] = {},
  1052.      ['allele2'] = "Common",
  1053.      ['result'] = "Cultivated",
  1054.      ['chance'] = 12
  1055.     }
  1056.   breedingTable[126] = {
  1057.      ['allele1'] = "Rocky",
  1058.      ['specialConditions'] = {},
  1059.      ['allele2'] = "Common",
  1060.      ['result'] = "Cultivated",
  1061.      ['chance'] = 12
  1062.     }
  1063.   breedingTable[127] = {
  1064.      ['allele1'] = "Embittered",
  1065.      ['specialConditions'] = {},
  1066.      ['allele2'] = "Sinister",
  1067.      ['result'] = "Furious",
  1068.      ['chance'] = 10
  1069.     }
  1070.   breedingTable[128] = {
  1071.      ['allele1'] = "Embittered",
  1072.      ['specialConditions'] = {},
  1073.      ['allele2'] = "Furious",
  1074.      ['result'] = "Volcanic",
  1075.      ['chance'] = 6
  1076.     }
  1077.   breedingTable[129] = {
  1078.      ['allele1'] = "Sinister",
  1079.      ['specialConditions'] = {},
  1080.      ['allele2'] = "Tropical",
  1081.      ['result'] = "Malicious",
  1082.      ['chance'] = 10
  1083.     }
  1084.   breedingTable[130] = {
  1085.      ['allele1'] = "Malicious",
  1086.      ['specialConditions'] = {},
  1087.      ['allele2'] = "Tropical",
  1088.      ['result'] = "Infectious",
  1089.      ['chance'] = 8
  1090.     }
  1091.   breedingTable[131] = {
  1092.      ['allele1'] = "Malicious",
  1093.      ['specialConditions'] = {},
  1094.      ['allele2'] = "Infectious",
  1095.      ['result'] = "Virulent",
  1096.      ['chance'] = 8
  1097.     }
  1098.   breedingTable[132] = {
  1099.      ['allele1'] = "Water",
  1100.      ['specialConditions'] = {},
  1101.      ['allele2'] = "Exotic",
  1102.      ['result'] = "Viscous",
  1103.      ['chance'] = 10
  1104.     }
  1105.   breedingTable[133] = {
  1106.      ['allele1'] = "Viscous",
  1107.      ['specialConditions'] = {},
  1108.      ['allele2'] = "Exotic",
  1109.      ['result'] = "Glutinous",
  1110.      ['chance'] = 8
  1111.     }
  1112.   breedingTable[134] = {
  1113.      ['allele1'] = "Viscous",
  1114.      ['specialConditions'] = {},
  1115.      ['allele2'] = "Glutinous",
  1116.      ['result'] = "Sticky",
  1117.      ['chance'] = 8
  1118.     }
  1119.   breedingTable[135] = {
  1120.      ['allele1'] = "Virulent",
  1121.      ['specialConditions'] = {},
  1122.      ['allele2'] = "Sticky",
  1123.      ['result'] = "Corrosive",
  1124.      ['chance'] = 10
  1125.     }
  1126.   breedingTable[136] = {
  1127.      ['allele1'] = "Corrosive",
  1128.      ['specialConditions'] = {},
  1129.      ['allele2'] = "Fiendish",
  1130.      ['result'] = "Caustic",
  1131.      ['chance'] = 8
  1132.     }
  1133.   breedingTable[137] = {
  1134.      ['allele1'] = "Corrosive",
  1135.      ['specialConditions'] = {},
  1136.      ['allele2'] = "Caustic",
  1137.      ['result'] = "Acidic",
  1138.      ['chance'] = 4
  1139.     }
  1140.   breedingTable[138] = {
  1141.      ['allele1'] = "Cultivated",
  1142.      ['specialConditions'] = {},
  1143.      ['allele2'] = "Valiant",
  1144.      ['result'] = "Excited",
  1145.      ['chance'] = 10
  1146.     }
  1147.   breedingTable[139] = {
  1148.      ['allele1'] = "Excited",
  1149.      ['specialConditions'] = {},
  1150.      ['allele2'] = "Valiant",
  1151.      ['result'] = "Energetic",
  1152.      ['chance'] = 8
  1153.     }
  1154.   breedingTable[140] = {
  1155.      ['allele1'] = "Wintry",
  1156.      ['specialConditions'] = {},
  1157.      ['allele2'] = "Diligent",
  1158.      ['result'] = "Frigid",
  1159.      ['chance'] = 10
  1160.     }
  1161.   breedingTable[141] = {
  1162.      ['allele1'] = "Ocean",
  1163.      ['specialConditions'] = {},
  1164.      ['allele2'] = "Frigid",
  1165.      ['result'] = "Absolute",
  1166.      ['chance'] = 10
  1167.     }
  1168.   breedingTable[142] = {
  1169.      ['allele1'] = "Tolerant",
  1170.      ['specialConditions'] = {},
  1171.      ['allele2'] = "Sinister",
  1172.      ['result'] = "Shadowed",
  1173.      ['chance'] = 10
  1174.     }
  1175.   breedingTable[143] = {
  1176.      ['allele1'] = "Shadowed",
  1177.      ['specialConditions'] = {},
  1178.      ['allele2'] = "Embittered",
  1179.      ['result'] = "Darkened",
  1180.      ['chance'] = 8
  1181.     }
  1182.   breedingTable[144] = {
  1183.      ['allele1'] = "Shadowed",
  1184.      ['specialConditions'] = {},
  1185.      ['allele2'] = "Darkened",
  1186.      ['result'] = "Abyssal",
  1187.      ['chance'] = 8
  1188.     }
  1189.   breedingTable[145] = {
  1190.      ['allele1'] = "Forest",
  1191.      ['specialConditions'] = {},
  1192.      ['allele2'] = "Valiant",
  1193.      ['result'] = "Maroon",
  1194.      ['chance'] = 5
  1195.     }
  1196.   breedingTable[146] = {
  1197.      ['allele1'] = "Meadows",
  1198.      ['specialConditions'] = {},
  1199.      ['allele2'] = "Valiant",
  1200.      ['result'] = "Saffron",
  1201.      ['chance'] = 5
  1202.     }
  1203.   breedingTable[147] = {
  1204.      ['allele1'] = "Water",
  1205.      ['specialConditions'] = {},
  1206.      ['allele2'] = "Valiant",
  1207.      ['result'] = "Prussian",
  1208.      ['chance'] = 5
  1209.     }
  1210.   breedingTable[148] = {
  1211.      ['allele1'] = "Tropical",
  1212.      ['specialConditions'] = {},
  1213.      ['allele2'] = "Valiant",
  1214.      ['result'] = "Natural",
  1215.      ['chance'] = 5
  1216.     }
  1217.   breedingTable[149] = {
  1218.      ['allele1'] = "Rocky",
  1219.      ['specialConditions'] = {},
  1220.      ['allele2'] = "Valiant",
  1221.      ['result'] = "Ebony",
  1222.      ['chance'] = 5
  1223.     }
  1224.   breedingTable[150] = {
  1225.      ['allele1'] = "Wintry",
  1226.      ['specialConditions'] = {},
  1227.      ['allele2'] = "Valiant",
  1228.      ['result'] = "Bleached",
  1229.      ['chance'] = 5
  1230.     }
  1231.   breedingTable[151] = {
  1232.      ['allele1'] = "Marshy",
  1233.      ['specialConditions'] = {},
  1234.      ['allele2'] = "Valiant",
  1235.      ['result'] = "Sepia",
  1236.      ['chance'] = 5
  1237.     }
  1238.   breedingTable[152] = {
  1239.      ['allele1'] = "Maroon",
  1240.      ['specialConditions'] = {},
  1241.      ['allele2'] = "Saffron",
  1242.      ['result'] = "Amber",
  1243.      ['chance'] = 5
  1244.     }
  1245.   breedingTable[153] = {
  1246.      ['allele1'] = "Natural",
  1247.      ['specialConditions'] = {},
  1248.      ['allele2'] = "Prussian",
  1249.      ['result'] = "Turquoise",
  1250.      ['chance'] = 5
  1251.     }
  1252.   breedingTable[154] = {
  1253.      ['allele1'] = "Maroon",
  1254.      ['specialConditions'] = {},
  1255.      ['allele2'] = "Prussian",
  1256.      ['result'] = "Indigo",
  1257.      ['chance'] = 5
  1258.     }
  1259.   breedingTable[155] = {
  1260.      ['allele1'] = "Ebony",
  1261.      ['specialConditions'] = {},
  1262.      ['allele2'] = "Bleached",
  1263.      ['result'] = "Slate",
  1264.      ['chance'] = 5
  1265.     }
  1266.   breedingTable[156] = {
  1267.      ['allele1'] = "Prussian",
  1268.      ['specialConditions'] = {},
  1269.      ['allele2'] = "Bleached",
  1270.      ['result'] = "Azure",
  1271.      ['chance'] = 5
  1272.     }
  1273.   breedingTable[157] = {
  1274.      ['allele1'] = "Maroon",
  1275.      ['specialConditions'] = {},
  1276.      ['allele2'] = "Bleached",
  1277.      ['result'] = "Lavender",
  1278.      ['chance'] = 5
  1279.     }
  1280.   breedingTable[158] = {
  1281.      ['allele1'] = "Natural",
  1282.      ['specialConditions'] = {},
  1283.      ['allele2'] = "Bleached",
  1284.      ['result'] = "Lime",
  1285.      ['chance'] = 5
  1286.     }
  1287.   breedingTable[159] = {
  1288.      ['allele1'] = "Indigo",
  1289.      ['specialConditions'] = {},
  1290.      ['allele2'] = "Lavender",
  1291.      ['result'] = "Fuchsia",
  1292.      ['chance'] = 5
  1293.     }
  1294.   breedingTable[160] = {
  1295.      ['allele1'] = "Slate",
  1296.      ['specialConditions'] = {},
  1297.      ['allele2'] = "Bleached",
  1298.      ['result'] = "Ashen",
  1299.      ['chance'] = 5
  1300.     }
  1301.   breedingTable[161] = {
  1302.      ['allele1'] = "Furious",
  1303.      ['specialConditions'] = {},
  1304.      ['allele2'] = "Excited",
  1305.      ['result'] = "Glowering",
  1306.      ['chance'] = 5
  1307.     }
  1308.   breedingTable[162] = {
  1309.      ['allele1'] = "Austere",
  1310.      ['specialConditions'] = {},
  1311.      ['allele2'] = "Desolate",
  1312.      ['result'] = "Hazardous",
  1313.      ['chance'] = 5
  1314.     }
  1315.   breedingTable[163] = {
  1316.      ['allele1'] = "Ender",
  1317.      ['specialConditions'] = {},
  1318.      ['allele2'] = "Relic",
  1319.      ['result'] = "Jaded",
  1320.      ['chance'] = 2
  1321.     }
  1322.   breedingTable[164] = {
  1323.      ['allele1'] = "Austere",
  1324.      ['specialConditions'] = {},
  1325.      ['allele2'] = "Excited",
  1326.      ['result'] = "Celebratory",
  1327.      ['chance'] = 5
  1328.     }
  1329.   breedingTable[165] = {
  1330.      ['allele1'] = "Secluded",
  1331.      ['specialConditions'] = {},
  1332.      ['allele2'] = "Ender",
  1333.      ['result'] = "Abnormal",
  1334.      ['chance'] = 5
  1335.     }
  1336.   breedingTable[166] = {
  1337.      ['allele1'] = "Abnormal",
  1338.      ['specialConditions'] = {},
  1339.      ['allele2'] = "Hermitic",
  1340.      ['result'] = "Spatial",
  1341.      ['chance'] = 5
  1342.     }
  1343.   breedingTable[167] = {
  1344.      ['allele1'] = "Spatial",
  1345.      ['specialConditions'] = {},
  1346.      ['allele2'] = "Spectral",
  1347.      ['result'] = "Quantum",
  1348.      ['chance'] = 5
  1349.     }
  1350.   breedingTable[168] = {
  1351.      ['allele1'] = "Mystical",
  1352.      ['specialConditions'] = {},
  1353.      ['allele2'] = "Forest",
  1354.      ['result'] = "Common",
  1355.      ['chance'] = 15
  1356.     }
  1357.   breedingTable[169] = {
  1358.      ['allele1'] = "Mystical",
  1359.      ['specialConditions'] = {},
  1360.      ['allele2'] = "Meadows",
  1361.      ['result'] = "Common",
  1362.      ['chance'] = 15
  1363.     }
  1364.   breedingTable[170] = {
  1365.      ['allele1'] = "Mystical",
  1366.      ['specialConditions'] = {},
  1367.      ['allele2'] = "Modest",
  1368.      ['result'] = "Common",
  1369.      ['chance'] = 15
  1370.     }
  1371.   breedingTable[171] = {
  1372.      ['allele1'] = "Mystical",
  1373.      ['specialConditions'] = {},
  1374.      ['allele2'] = "Wintry",
  1375.      ['result'] = "Common",
  1376.      ['chance'] = 15
  1377.     }
  1378.   breedingTable[172] = {
  1379.      ['allele1'] = "Mystical",
  1380.      ['specialConditions'] = {},
  1381.      ['allele2'] = "Tropical",
  1382.      ['result'] = "Common",
  1383.      ['chance'] = 15
  1384.     }
  1385.   breedingTable[173] = {
  1386.      ['allele1'] = "Mystical",
  1387.      ['specialConditions'] = {},
  1388.      ['allele2'] = "Marshy",
  1389.      ['result'] = "Common",
  1390.      ['chance'] = 15
  1391.     }
  1392.   breedingTable[174] = {
  1393.      ['allele1'] = "Mystical",
  1394.      ['specialConditions'] = {},
  1395.      ['allele2'] = "Rocky",
  1396.      ['result'] = "Common",
  1397.      ['chance'] = 15
  1398.     }
  1399.   breedingTable[175] = {
  1400.      ['allele1'] = "Mystical",
  1401.      ['specialConditions'] = {},
  1402.      ['allele2'] = "Water",
  1403.      ['result'] = "Common",
  1404.      ['chance'] = 15
  1405.     }
  1406.   breedingTable[176] = {
  1407.      ['allele1'] = "Mystical",
  1408.      ['specialConditions'] = {},
  1409.      ['allele2'] = "Embittered",
  1410.      ['result'] = "Common",
  1411.      ['chance'] = 15
  1412.     }
  1413.   breedingTable[177] = {
  1414.      ['allele1'] = "Mystical",
  1415.      ['specialConditions'] = {},
  1416.      ['allele2'] = "Common",
  1417.      ['result'] = "Cultivated",
  1418.      ['chance'] = 12
  1419.     }
  1420.   breedingTable[178] = {
  1421.      ['allele1'] = "Mystical",
  1422.      ['specialConditions'] = {},
  1423.      ['allele2'] = "Cultivated",
  1424.      ['result'] = "Eldritch",
  1425.      ['chance'] = 12
  1426.     }
  1427.   breedingTable[179] = {
  1428.      ['allele1'] = "Sorcerous",
  1429.      ['specialConditions'] = {},
  1430.      ['allele2'] = "Forest",
  1431.      ['result'] = "Common",
  1432.      ['chance'] = 15
  1433.     }
  1434.   breedingTable[180] = {
  1435.      ['allele1'] = "Sorcerous",
  1436.      ['specialConditions'] = {},
  1437.      ['allele2'] = "Meadows",
  1438.      ['result'] = "Common",
  1439.      ['chance'] = 15
  1440.     }
  1441.   breedingTable[181] = {
  1442.      ['allele1'] = "Sorcerous",
  1443.      ['specialConditions'] = {},
  1444.      ['allele2'] = "Modest",
  1445.      ['result'] = "Common",
  1446.      ['chance'] = 15
  1447.     }
  1448.   breedingTable[182] = {
  1449.      ['allele1'] = "Sorcerous",
  1450.      ['specialConditions'] = {},
  1451.      ['allele2'] = "Wintry",
  1452.      ['result'] = "Common",
  1453.      ['chance'] = 15
  1454.     }
  1455.   breedingTable[183] = {
  1456.      ['allele1'] = "Sorcerous",
  1457.      ['specialConditions'] = {},
  1458.      ['allele2'] = "Tropical",
  1459.      ['result'] = "Common",
  1460.      ['chance'] = 15
  1461.     }
  1462.   breedingTable[184] = {
  1463.      ['allele1'] = "Sorcerous",
  1464.      ['specialConditions'] = {},
  1465.      ['allele2'] = "Marshy",
  1466.      ['result'] = "Common",
  1467.      ['chance'] = 15
  1468.     }
  1469.   breedingTable[185] = {
  1470.      ['allele1'] = "Sorcerous",
  1471.      ['specialConditions'] = {},
  1472.      ['allele2'] = "Rocky",
  1473.      ['result'] = "Common",
  1474.      ['chance'] = 15
  1475.     }
  1476.   breedingTable[186] = {
  1477.      ['allele1'] = "Sorcerous",
  1478.      ['specialConditions'] = {},
  1479.      ['allele2'] = "Water",
  1480.      ['result'] = "Common",
  1481.      ['chance'] = 15
  1482.     }
  1483.   breedingTable[187] = {
  1484.      ['allele1'] = "Sorcerous",
  1485.      ['specialConditions'] = {},
  1486.      ['allele2'] = "Embittered",
  1487.      ['result'] = "Common",
  1488.      ['chance'] = 15
  1489.     }
  1490.   breedingTable[188] = {
  1491.      ['allele1'] = "Sorcerous",
  1492.      ['specialConditions'] = {},
  1493.      ['allele2'] = "Common",
  1494.      ['result'] = "Cultivated",
  1495.      ['chance'] = 12
  1496.     }
  1497.   breedingTable[189] = {
  1498.      ['allele1'] = "Sorcerous",
  1499.      ['specialConditions'] = {},
  1500.      ['allele2'] = "Cultivated",
  1501.      ['result'] = "Eldritch",
  1502.      ['chance'] = 12
  1503.     }
  1504.   breedingTable[190] = {
  1505.      ['allele1'] = "Unusual",
  1506.      ['specialConditions'] = {},
  1507.      ['allele2'] = "Forest",
  1508.      ['result'] = "Common",
  1509.      ['chance'] = 15
  1510.     }
  1511.   breedingTable[191] = {
  1512.      ['allele1'] = "Unusual",
  1513.      ['specialConditions'] = {},
  1514.      ['allele2'] = "Meadows",
  1515.      ['result'] = "Common",
  1516.      ['chance'] = 15
  1517.     }
  1518.   breedingTable[192] = {
  1519.      ['allele1'] = "Unusual",
  1520.      ['specialConditions'] = {},
  1521.      ['allele2'] = "Modest",
  1522.      ['result'] = "Common",
  1523.      ['chance'] = 15
  1524.     }
  1525.   breedingTable[193] = {
  1526.      ['allele1'] = "Unusual",
  1527.      ['specialConditions'] = {},
  1528.      ['allele2'] = "Wintry",
  1529.      ['result'] = "Common",
  1530.      ['chance'] = 15
  1531.     }
  1532.   breedingTable[194] = {
  1533.      ['allele1'] = "Unusual",
  1534.      ['specialConditions'] = {},
  1535.      ['allele2'] = "Tropical",
  1536.      ['result'] = "Common",
  1537.      ['chance'] = 15
  1538.     }
  1539.   breedingTable[195] = {
  1540.      ['allele1'] = "Unusual",
  1541.      ['specialConditions'] = {},
  1542.      ['allele2'] = "Marshy",
  1543.      ['result'] = "Common",
  1544.      ['chance'] = 15
  1545.     }
  1546.   breedingTable[196] = {
  1547.      ['allele1'] = "Unusual",
  1548.      ['specialConditions'] = {},
  1549.      ['allele2'] = "Rocky",
  1550.      ['result'] = "Common",
  1551.      ['chance'] = 15
  1552.     }
  1553.   breedingTable[197] = {
  1554.      ['allele1'] = "Unusual",
  1555.      ['specialConditions'] = {},
  1556.      ['allele2'] = "Water",
  1557.      ['result'] = "Common",
  1558.      ['chance'] = 15
  1559.     }
  1560.   breedingTable[198] = {
  1561.      ['allele1'] = "Unusual",
  1562.      ['specialConditions'] = {},
  1563.      ['allele2'] = "Embittered",
  1564.      ['result'] = "Common",
  1565.      ['chance'] = 15
  1566.     }
  1567.   breedingTable[199] = {
  1568.      ['allele1'] = "Unusual",
  1569.      ['specialConditions'] = {},
  1570.      ['allele2'] = "Common",
  1571.      ['result'] = "Cultivated",
  1572.      ['chance'] = 12
  1573.     }
  1574.   breedingTable[200] = {
  1575.      ['allele1'] = "Unusual",
  1576.      ['specialConditions'] = {},
  1577.      ['allele2'] = "Cultivated",
  1578.      ['result'] = "Eldritch",
  1579.      ['chance'] = 12
  1580.     }
  1581.   breedingTable[201] = {
  1582.      ['allele1'] = "Attuned",
  1583.      ['specialConditions'] = {},
  1584.      ['allele2'] = "Forest",
  1585.      ['result'] = "Common",
  1586.      ['chance'] = 15
  1587.     }
  1588.   breedingTable[202] = {
  1589.      ['allele1'] = "Attuned",
  1590.      ['specialConditions'] = {},
  1591.      ['allele2'] = "Meadows",
  1592.      ['result'] = "Common",
  1593.      ['chance'] = 15
  1594.     }
  1595.   breedingTable[203] = {
  1596.      ['allele1'] = "Attuned",
  1597.      ['specialConditions'] = {},
  1598.      ['allele2'] = "Modest",
  1599.      ['result'] = "Common",
  1600.      ['chance'] = 15
  1601.     }
  1602.   breedingTable[204] = {
  1603.      ['allele1'] = "Attuned",
  1604.      ['specialConditions'] = {},
  1605.      ['allele2'] = "Wintry",
  1606.      ['result'] = "Common",
  1607.      ['chance'] = 15
  1608.     }
  1609.   breedingTable[205] = {
  1610.      ['allele1'] = "Attuned",
  1611.      ['specialConditions'] = {},
  1612.      ['allele2'] = "Tropical",
  1613.      ['result'] = "Common",
  1614.      ['chance'] = 15
  1615.     }
  1616.   breedingTable[206] = {
  1617.      ['allele1'] = "Attuned",
  1618.      ['specialConditions'] = {},
  1619.      ['allele2'] = "Marshy",
  1620.      ['result'] = "Common",
  1621.      ['chance'] = 15
  1622.     }
  1623.   breedingTable[207] = {
  1624.      ['allele1'] = "Attuned",
  1625.      ['specialConditions'] = {},
  1626.      ['allele2'] = "Rocky",
  1627.      ['result'] = "Common",
  1628.      ['chance'] = 15
  1629.     }
  1630.   breedingTable[208] = {
  1631.      ['allele1'] = "Attuned",
  1632.      ['specialConditions'] = {},
  1633.      ['allele2'] = "Water",
  1634.      ['result'] = "Common",
  1635.      ['chance'] = 15
  1636.     }
  1637.   breedingTable[209] = {
  1638.      ['allele1'] = "Attuned",
  1639.      ['specialConditions'] = {},
  1640.      ['allele2'] = "Embittered",
  1641.      ['result'] = "Common",
  1642.      ['chance'] = 15
  1643.     }
  1644.   breedingTable[210] = {
  1645.      ['allele1'] = "Attuned",
  1646.      ['specialConditions'] = {},
  1647.      ['allele2'] = "Common",
  1648.      ['result'] = "Cultivated",
  1649.      ['chance'] = 12
  1650.     }
  1651.   breedingTable[211] = {
  1652.      ['allele1'] = "Attuned",
  1653.      ['specialConditions'] = {},
  1654.      ['allele2'] = "Cultivated",
  1655.      ['result'] = "Eldritch",
  1656.      ['chance'] = 12
  1657.     }
  1658.   breedingTable[212] = {
  1659.      ['allele1'] = "Cultivated",
  1660.      ['specialConditions'] = {},
  1661.      ['allele2'] = "Eldritch",
  1662.      ['result'] = "Esoteric",
  1663.      ['chance'] = 10
  1664.     }
  1665.   breedingTable[213] = {
  1666.      ['allele1'] = "Eldritch",
  1667.      ['specialConditions'] = {},
  1668.      ['allele2'] = "Esoteric",
  1669.      ['result'] = "Mysterious",
  1670.      ['chance'] = 8
  1671.     }
  1672.   breedingTable[214] = {
  1673.      ['allele1'] = "Esoteric",
  1674.      ['specialConditions'] = {},
  1675.      ['allele2'] = "Mysterious",
  1676.      ['result'] = "Arcane",
  1677.      ['chance'] = 8
  1678.     }
  1679.   breedingTable[215] = {
  1680.      ['allele1'] = "Cultivated",
  1681.      ['specialConditions'] = {},
  1682.      ['allele2'] = "Eldritch",
  1683.      ['result'] = "Charmed",
  1684.      ['chance'] = 10
  1685.     }
  1686.   breedingTable[216] = {
  1687.      ['allele1'] = "Eldritch",
  1688.      ['specialConditions'] = {},
  1689.      ['allele2'] = "Charmed",
  1690.      ['result'] = "Enchanted",
  1691.      ['chance'] = 8
  1692.     }
  1693.   breedingTable[217] = {
  1694.      ['allele1'] = "Charmed",
  1695.      ['specialConditions'] = {},
  1696.      ['allele2'] = "Enchanted",
  1697.      ['result'] = "Supernatural",
  1698.      ['chance'] = 8
  1699.     }
  1700.   breedingTable[218] = {
  1701.      ['allele1'] = "Arcane",
  1702.      ['specialConditions'] = {},
  1703.      ['allele2'] = "Supernatural",
  1704.      ['result'] = "Ethereal",
  1705.      ['chance'] = 7
  1706.     }
  1707.   breedingTable[219] = {
  1708.      ['allele1'] = "Supernatural",
  1709.      ['specialConditions'] = {[1] = "Requires a foundation of Oak Leaves"},
  1710.      ['allele2'] = "Ethereal",
  1711.      ['result'] = "Windy",
  1712.      ['chance'] = 14
  1713.     }
  1714.   breedingTable[220] = {
  1715.      ['allele1'] = "Supernatural",
  1716.      ['specialConditions'] = {[1] = "Requires a foundation of Water"},
  1717.      ['allele2'] = "Ethereal",
  1718.      ['result'] = "Watery",
  1719.      ['chance'] = 14
  1720.     }
  1721.   breedingTable[221] = {
  1722.      ['allele1'] = "Supernatural",
  1723.      ['specialConditions'] = {[1] = "Requires a foundation of Bricks"},
  1724.      ['allele2'] = "Ethereal",
  1725.      ['result'] = "Earthen",
  1726.      ['chance'] = 100
  1727.     }
  1728.   breedingTable[222] = {
  1729.      ['allele1'] = "Supernatural",
  1730.      ['specialConditions'] = {[1] = "Requires a foundation of Lava"},
  1731.      ['allele2'] = "Ethereal",
  1732.      ['result'] = "Firey",
  1733.      ['chance'] = 14
  1734.     }
  1735.   breedingTable[223] = {
  1736.      ['allele1'] = "Ethereal",
  1737.      ['specialConditions'] = {},
  1738.      ['allele2'] = "Attuned",
  1739.      ['result'] = "Aware",
  1740.      ['chance'] = 10
  1741.     }
  1742.   breedingTable[224] = {
  1743.      ['allele1'] = "Ethereal",
  1744.      ['specialConditions'] = {},
  1745.      ['allele2'] = "Aware",
  1746.      ['result'] = "Spirit",
  1747.      ['chance'] = 8
  1748.     }
  1749.   breedingTable[225] = {
  1750.      ['allele1'] = "Attuned",
  1751.      ['specialConditions'] = {},
  1752.      ['allele2'] = "Aware",
  1753.      ['result'] = "Spirit",
  1754.      ['chance'] = 8
  1755.     }
  1756.   breedingTable[226] = {
  1757.      ['allele1'] = "Aware",
  1758.      ['specialConditions'] = {},
  1759.      ['allele2'] = "Spirit",
  1760.      ['result'] = "Soul",
  1761.      ['chance'] = 7
  1762.     }
  1763.   breedingTable[227] = {
  1764.      ['allele1'] = "Monastic",
  1765.      ['specialConditions'] = {},
  1766.      ['allele2'] = "Arcane",
  1767.      ['result'] = "Pupil",
  1768.      ['chance'] = 10
  1769.     }
  1770.   breedingTable[228] = {
  1771.      ['allele1'] = "Arcane",
  1772.      ['specialConditions'] = {},
  1773.      ['allele2'] = "Pupil",
  1774.      ['result'] = "Scholarly",
  1775.      ['chance'] = 8
  1776.     }
  1777.   breedingTable[229] = {
  1778.      ['allele1'] = "Pupil",
  1779.      ['specialConditions'] = {},
  1780.      ['allele2'] = "Scholarly",
  1781.      ['result'] = "Savant",
  1782.      ['chance'] = 6
  1783.     }
  1784.   breedingTable[230] = {
  1785.      ['allele1'] = "Imperial",
  1786.      ['specialConditions'] = {},
  1787.      ['allele2'] = "Ethereal",
  1788.      ['result'] = "Timely",
  1789.      ['chance'] = 8
  1790.     }
  1791.   breedingTable[231] = {
  1792.      ['allele1'] = "Imperial",
  1793.      ['specialConditions'] = {},
  1794.      ['allele2'] = "Timely",
  1795.      ['result'] = "Lordly",
  1796.      ['chance'] = 8
  1797.     }
  1798.   breedingTable[232] = {
  1799.      ['allele1'] = "Timely",
  1800.      ['specialConditions'] = {},
  1801.      ['allele2'] = "Lordly",
  1802.      ['result'] = "Doctoral",
  1803.      ['chance'] = 7
  1804.     }
  1805.   breedingTable[233] = {
  1806.      ['allele1'] = "Infernal",
  1807.      ['specialConditions'] = {[1] = "Occurs within a Nether biome"},
  1808.      ['allele2'] = "Eldritch",
  1809.      ['result'] = "Hateful",
  1810.      ['chance'] = 9
  1811.     }
  1812.   breedingTable[234] = {
  1813.      ['allele1'] = "Infernal",
  1814.      ['specialConditions'] = {},
  1815.      ['allele2'] = "Hateful",
  1816.      ['result'] = "Spiteful",
  1817.      ['chance'] = 7
  1818.     }
  1819.   breedingTable[235] = {
  1820.      ['allele1'] = "Demonic",
  1821.      ['specialConditions'] = {},
  1822.      ['allele2'] = "Spiteful",
  1823.      ['result'] = "Withering",
  1824.      ['chance'] = 6
  1825.     }
  1826.   breedingTable[236] = {
  1827.      ['allele1'] = "Modest",
  1828.      ['specialConditions'] = {},
  1829.      ['allele2'] = "Eldritch",
  1830.      ['result'] = "Skulking",
  1831.      ['chance'] = 12
  1832.     }
  1833.   breedingTable[237] = {
  1834.      ['allele1'] = "Tropical",
  1835.      ['specialConditions'] = {},
  1836.      ['allele2'] = "Skulking",
  1837.      ['result'] = "Spidery",
  1838.      ['chance'] = 10
  1839.     }
  1840.   breedingTable[238] = {
  1841.      ['allele1'] = "Skulking",
  1842.      ['specialConditions'] = {},
  1843.      ['allele2'] = "Ethereal",
  1844.      ['result'] = "Ghastly",
  1845.      ['chance'] = 9
  1846.     }
  1847.   breedingTable[239] = {
  1848.      ['allele1'] = "Skulking",
  1849.      ['specialConditions'] = {},
  1850.      ['allele2'] = "Hateful",
  1851.      ['result'] = "Smouldering",
  1852.      ['chance'] = 7
  1853.     }
  1854.   breedingTable[240] = {
  1855.      ['allele1'] = "Ethereal",
  1856.      ['specialConditions'] = {},
  1857.      ['allele2'] = "Oblivion",
  1858.      ['result'] = "Nameless",
  1859.      ['chance'] = 10
  1860.     }
  1861.   breedingTable[241] = {
  1862.      ['allele1'] = "Oblivion",
  1863.      ['specialConditions'] = {},
  1864.      ['allele2'] = "Nameless",
  1865.      ['result'] = "Abandoned",
  1866.      ['chance'] = 8
  1867.     }
  1868.   breedingTable[242] = {
  1869.      ['allele1'] = "Nameless",
  1870.      ['specialConditions'] = {},
  1871.      ['allele2'] = "Abandoned",
  1872.      ['result'] = "Forlorn",
  1873.      ['chance'] = 6
  1874.     }
  1875.   breedingTable[243] = {
  1876.      ['allele1'] = "Imperial",
  1877.      ['specialConditions'] = {[1] = "Occurs within a End biome"},
  1878.      ['allele2'] = "Abandoned",
  1879.      ['result'] = "Draconic",
  1880.      ['chance'] = 6
  1881.     }
  1882.   breedingTable[244] = {
  1883.      ['allele1'] = "Unusual",
  1884.      ['specialConditions'] = {},
  1885.      ['allele2'] = "Eldritch",
  1886.      ['result'] = "Mutable",
  1887.      ['chance'] = 12
  1888.     }
  1889.   breedingTable[245] = {
  1890.      ['allele1'] = "Unusual",
  1891.      ['specialConditions'] = {},
  1892.      ['allele2'] = "Mutable",
  1893.      ['result'] = "Transmuting",
  1894.      ['chance'] = 9
  1895.     }
  1896.   breedingTable[246] = {
  1897.      ['allele1'] = "Unusual",
  1898.      ['specialConditions'] = {},
  1899.      ['allele2'] = "Mutable",
  1900.      ['result'] = "Crumbling",
  1901.      ['chance'] = 9
  1902.     }
  1903.   breedingTable[247] = {
  1904.      ['allele1'] = "Mystical",
  1905.      ['specialConditions'] = {},
  1906.      ['allele2'] = "Mutable",
  1907.      ['result'] = "Invisible",
  1908.      ['chance'] = 15
  1909.     }
  1910.   breedingTable[248] = {
  1911.      ['allele1'] = "Industrious",
  1912.      ['specialConditions'] = {[1] = "Requires a foundation of Copper Block"},
  1913.      ['allele2'] = "Meadows",
  1914.      ['result'] = "Cuprum",
  1915.      ['chance'] = 12
  1916.     }
  1917.   breedingTable[249] = {
  1918.      ['allele1'] = "Industrious",
  1919.      ['specialConditions'] = {[1] = "Requires a foundation of Tin Block"},
  1920.      ['allele2'] = "Forest",
  1921.      ['result'] = "Stannum",
  1922.      ['chance'] = 12
  1923.     }
  1924.   breedingTable[250] = {
  1925.      ['allele1'] = "Common",
  1926.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Iron"},
  1927.      ['allele2'] = "Industrious",
  1928.      ['result'] = "Ferrous",
  1929.      ['chance'] = 12
  1930.     }
  1931.   breedingTable[251] = {
  1932.      ['allele1'] = "Stannum",
  1933.      ['specialConditions'] = {[1] = "Requires a foundation of Lead Block"},
  1934.      ['allele2'] = "Common",
  1935.      ['result'] = "Plumbum",
  1936.      ['chance'] = 10
  1937.     }
  1938.   breedingTable[252] = {
  1939.      ['allele1'] = "Imperial",
  1940.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Silver"},
  1941.      ['allele2'] = "Modest",
  1942.      ['result'] = "Argentum",
  1943.      ['chance'] = 8
  1944.     }
  1945.   breedingTable[253] = {
  1946.      ['allele1'] = "Imperial",
  1947.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Gold"},
  1948.      ['allele2'] = "Plumbum",
  1949.      ['result'] = "Auric",
  1950.      ['chance'] = 8
  1951.     }
  1952.   breedingTable[254] = {
  1953.      ['allele1'] = "Industrious",
  1954.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Ardite"},
  1955.      ['allele2'] = "Infernal",
  1956.      ['result'] = "Ardite",
  1957.      ['chance'] = 9
  1958.     }
  1959.   breedingTable[255] = {
  1960.      ['allele1'] = "Imperial",
  1961.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Cobalt"},
  1962.      ['allele2'] = "Infernal",
  1963.      ['result'] = "Cobalt",
  1964.      ['chance'] = 9
  1965.     }
  1966.   breedingTable[256] = {
  1967.      ['allele1'] = "Ardite",
  1968.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Manyullyn"},
  1969.      ['allele2'] = "Cobalt",
  1970.      ['result'] = "Manyullyn",
  1971.      ['chance'] = 9
  1972.     }
  1973.   breedingTable[257] = {
  1974.      ['allele1'] = "Austere",
  1975.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Diamond"},
  1976.      ['allele2'] = "Auric",
  1977.      ['result'] = "Diamandi",
  1978.      ['chance'] = 7
  1979.     }
  1980.   breedingTable[258] = {
  1981.      ['allele1'] = "Austere",
  1982.      ['specialConditions'] = {[1] = "Requires a foundation of Block of Emerald"},
  1983.      ['allele2'] = "Argentum",
  1984.      ['result'] = "Esmeraldi",
  1985.      ['chance'] = 6
  1986.     }
  1987.   breedingTable[259] = {
  1988.      ['allele1'] = "Rural",
  1989.      ['specialConditions'] = {[1] = "Requires a foundation of Apatite Ore"},
  1990.      ['allele2'] = "Cuprum",
  1991.      ['result'] = "Apatine",
  1992.      ['chance'] = 12
  1993.     }
  1994.   breedingTable[260] = {
  1995.      ['allele1'] = "Windy",
  1996.      ['specialConditions'] = {[1] = "Requires a foundation of Air Crystal Cluster"},
  1997.      ['allele2'] = "Windy",
  1998.      ['result'] = "Aer",
  1999.      ['chance'] = 8
  2000.     }
  2001.   breedingTable[261] = {
  2002.      ['allele1'] = "Firey",
  2003.      ['specialConditions'] = {[1] = "Requires a foundation of Fire Crystal Cluster"},
  2004.      ['allele2'] = "Firey",
  2005.      ['result'] = "Ignis",
  2006.      ['chance'] = 8
  2007.     }
  2008.   breedingTable[262] = {
  2009.      ['allele1'] = "Watery",
  2010.      ['specialConditions'] = {[1] = "Requires a foundation of Water Crystal Cluster"},
  2011.      ['allele2'] = "Watery",
  2012.      ['result'] = "Aqua",
  2013.      ['chance'] = 8
  2014.     }
  2015.   breedingTable[263] = {
  2016.      ['allele1'] = "Earthen",
  2017.      ['specialConditions'] = {[1] = "Requires a foundation of Earth Crystal Cluster"},
  2018.      ['allele2'] = "Earthen",
  2019.      ['result'] = "Solum",
  2020.      ['chance'] = 8
  2021.     }
  2022.   breedingTable[264] = {
  2023.      ['allele1'] = "Ethereal",
  2024.      ['specialConditions'] = {[1] = "Requires a foundation of Order Crystal Cluster"},
  2025.      ['allele2'] = "Arcane",
  2026.      ['result'] = "Ordered",
  2027.      ['chance'] = 8
  2028.     }
  2029.   breedingTable[265] = {
  2030.      ['allele1'] = "Ethereal",
  2031.      ['specialConditions'] = {[1] = "Requires a foundation of Entropy Crystal Cluster"},
  2032.      ['allele2'] = "Supernatural",
  2033.      ['result'] = "Chaotic",
  2034.      ['chance'] = 8
  2035.     }
  2036.   breedingTable[266] = {
  2037.      ['allele1'] = "Skulking",
  2038.      ['specialConditions'] = {},
  2039.      ['allele2'] = "Windy",
  2040.      ['result'] = "Batty",
  2041.      ['chance'] = 9
  2042.     }
  2043.   breedingTable[267] = {
  2044.      ['allele1'] = "Skulking",
  2045.      ['specialConditions'] = {},
  2046.      ['allele2'] = "Pupil",
  2047.      ['result'] = "Brainy",
  2048.      ['chance'] = 9
  2049.     }
  2050.   breedingTable[268] = {
  2051.      ['allele1'] = "Common",
  2052.      ['specialConditions'] = {[1] = "Occurs within a Forest biome"},
  2053.      ['allele2'] = "Skulking",
  2054.      ['result'] = "Poultry",
  2055.      ['chance'] = 12
  2056.     }
  2057.   breedingTable[269] = {
  2058.      ['allele1'] = "Common",
  2059.      ['specialConditions'] = {[1] = "Occurs within a Plains biome"},
  2060.      ['allele2'] = "Skulking",
  2061.      ['result'] = "Beefy",
  2062.      ['chance'] = 12
  2063.     }
  2064.   breedingTable[270] = {
  2065.      ['allele1'] = "Common",
  2066.      ['specialConditions'] = {[1] = "Occurs within a Mountain biome"},
  2067.      ['allele2'] = "Skulking",
  2068.      ['result'] = "Porcine",
  2069.      ['chance'] = 12
  2070.     }
  2071.   breedingTable[271] = {
  2072.      ['allele1'] = "Arcane",
  2073.      ['specialConditions'] = {},
  2074.      ['allele2'] = "Ethereal",
  2075.      ['result'] = "Essence",
  2076.      ['chance'] = 10
  2077.     }
  2078.   breedingTable[272] = {
  2079.      ['allele1'] = "Arcane",
  2080.      ['specialConditions'] = {},
  2081.      ['allele2'] = "Essence",
  2082.      ['result'] = "Quintessential",
  2083.      ['chance'] = 7
  2084.     }
  2085.   breedingTable[273] = {
  2086.      ['allele1'] = "Essence",
  2087.      ['specialConditions'] = {},
  2088.      ['allele2'] = "Windy",
  2089.      ['result'] = "Luft",
  2090.      ['chance'] = 10
  2091.     }
  2092.   breedingTable[274] = {
  2093.      ['allele1'] = "Essence",
  2094.      ['specialConditions'] = {},
  2095.      ['allele2'] = "Earthen",
  2096.      ['result'] = "Erde",
  2097.      ['chance'] = 10
  2098.     }
  2099.   breedingTable[275] = {
  2100.      ['allele1'] = "Essence",
  2101.      ['specialConditions'] = {},
  2102.      ['allele2'] = "Firey",
  2103.      ['result'] = "Feuer",
  2104.      ['chance'] = 10
  2105.     }
  2106.   breedingTable[276] = {
  2107.      ['allele1'] = "Essence",
  2108.      ['specialConditions'] = {},
  2109.      ['allele2'] = "Watery",
  2110.      ['result'] = "Wasser",
  2111.      ['chance'] = 10
  2112.     }
  2113.   breedingTable[277] = {
  2114.      ['allele1'] = "Essence",
  2115.      ['specialConditions'] = {},
  2116.      ['allele2'] = "Ethereal",
  2117.      ['result'] = "Arkanen",
  2118.      ['chance'] = 10
  2119.     }
  2120.   breedingTable[278] = {
  2121.      ['allele1'] = "Windy",
  2122.      ['specialConditions'] = {},
  2123.      ['allele2'] = "Luft",
  2124.      ['result'] = "Blitz",
  2125.      ['chance'] = 8
  2126.     }
  2127.   breedingTable[279] = {
  2128.      ['allele1'] = "Earthen",
  2129.      ['specialConditions'] = {},
  2130.      ['allele2'] = "Erde",
  2131.      ['result'] = "Staude",
  2132.      ['chance'] = 8
  2133.     }
  2134.   breedingTable[280] = {
  2135.      ['allele1'] = "Watery",
  2136.      ['specialConditions'] = {},
  2137.      ['allele2'] = "Wasser",
  2138.      ['result'] = "Eis",
  2139.      ['chance'] = 8
  2140.     }
  2141.   breedingTable[281] = {
  2142.      ['allele1'] = "Skulking",
  2143.      ['specialConditions'] = {},
  2144.      ['allele2'] = "Essence",
  2145.      ['result'] = "Vortex",
  2146.      ['chance'] = 8
  2147.     }
  2148.   breedingTable[282] = {
  2149.      ['allele1'] = "Skulking",
  2150.      ['specialConditions'] = {},
  2151.      ['allele2'] = "Ghastly",
  2152.      ['result'] = "Wight",
  2153.      ['chance'] = 8
  2154.     }
  2155.   breedingTable[283] = {
  2156.      ['allele1'] = "Stannum",
  2157.      ['specialConditions'] = {[1] = "Requires a foundation of Bronze Block"},
  2158.      ['allele2'] = "Cuprum",
  2159.      ['result'] = "Tinker",
  2160.      ['chance'] = 12
  2161.     }
  2162.   breedingTable[284] = {
  2163.      ['allele1'] = "Auric",
  2164.      ['specialConditions'] = {[1] = "Requires a foundation of Electrum Block"},
  2165.      ['allele2'] = "Argentum",
  2166.      ['result'] = "Electrum",
  2167.      ['chance'] = 10
  2168.     }
  2169.   breedingTable[285] = {
  2170.      ['allele1'] = "Ferrous",
  2171.      ['specialConditions'] = {[1] = "Requires a foundation of Ferrous Block"},
  2172.      ['allele2'] = "Esoteric",
  2173.      ['result'] = "Nickel",
  2174.      ['chance'] = 14
  2175.     }
  2176.   breedingTable[286] = {
  2177.      ['allele1'] = "Ferrous",
  2178.      ['specialConditions'] = {[1] = "Requires a foundation of Invar Block"},
  2179.      ['allele2'] = "Nickel",
  2180.      ['result'] = "Invar",
  2181.      ['chance'] = 14
  2182.     }
  2183.   breedingTable[287] = {
  2184.      ['allele1'] = "Nickel",
  2185.      ['specialConditions'] = {[1] = "Requires a foundation of Shiny Block"},
  2186.      ['allele2'] = "Invar",
  2187.      ['result'] = "Platinum",
  2188.      ['chance'] = 10
  2189.     }
  2190.   breedingTable[288] = {
  2191.      ['allele1'] = "Spiteful",
  2192.      ['specialConditions'] = {[1] = "Requires a foundation of Coal Ore"},
  2193.      ['allele2'] = "Stannum",
  2194.      ['result'] = "Carbon",
  2195.      ['chance'] = 12
  2196.     }
  2197.   breedingTable[289] = {
  2198.      ['allele1'] = "Spiteful",
  2199.      ['specialConditions'] = {[1] = "Requires a foundation of Redstone Ore"},
  2200.      ['allele2'] = "Industrious",
  2201.      ['result'] = "Destabilized",
  2202.      ['chance'] = 12
  2203.     }
  2204.   breedingTable[290] = {
  2205.      ['allele1'] = "Smouldering",
  2206.      ['specialConditions'] = {[1] = "Requires a foundation of Glowstone"},
  2207.      ['allele2'] = "Infernal",
  2208.      ['result'] = "Lux",
  2209.      ['chance'] = 12
  2210.     }
  2211.   breedingTable[291] = {
  2212.      ['allele1'] = "Smouldering",
  2213.      ['specialConditions'] = {},
  2214.      ['allele2'] = "Austere",
  2215.      ['result'] = "Dante",
  2216.      ['chance'] = 12
  2217.     }
  2218.   breedingTable[292] = {
  2219.      ['allele1'] = "Dante",
  2220.      ['specialConditions'] = {},
  2221.      ['allele2'] = "Carbon",
  2222.      ['result'] = "Pyro",
  2223.      ['chance'] = 8
  2224.     }
  2225.   breedingTable[293] = {
  2226.      ['allele1'] = "Skulking",
  2227.      ['specialConditions'] = {},
  2228.      ['allele2'] = "Wintry",
  2229.      ['result'] = "Blizzy",
  2230.      ['chance'] = 12
  2231.     }
  2232.   breedingTable[294] = {
  2233.      ['allele1'] = "Blizzy",
  2234.      ['specialConditions'] = {},
  2235.      ['allele2'] = "Icy",
  2236.      ['result'] = "Gelid",
  2237.      ['chance'] = 8
  2238.     }
  2239.   breedingTable[295] = {
  2240.      ['allele1'] = "Platinum",
  2241.      ['specialConditions'] = {},
  2242.      ['allele2'] = "Oblivion",
  2243.      ['result'] = "Winsome",
  2244.      ['chance'] = 12
  2245.     }
  2246.   breedingTable[296] = {
  2247.      ['allele1'] = "Winsome",
  2248.      ['specialConditions'] = {[1] = "Requires a foundation of Enderium Block"},
  2249.      ['allele2'] = "Carbon",
  2250.      ['result'] = "Endearing",
  2251.      ['chance'] = 8
  2252.     }
  2253.   breedingTable[297] = {
  2254.      ['allele1'] = "Energetic",
  2255.      ['specialConditions'] = {},
  2256.      ['allele2'] = "Silicon",
  2257.      ['result'] = "Infinity",
  2258.      ['chance'] = 2
  2259.     }
  2260.   breedingTable[298] = {
  2261.      ['allele1'] = "Excited",
  2262.      ['specialConditions'] = {},
  2263.      ['allele2'] = "Lapis",
  2264.      ['result'] = "Electrotine",
  2265.      ['chance'] = 2
  2266.     }
  2267.   breedingTable[299] = {
  2268.      ['allele1'] = "Skystone",
  2269.      ['specialConditions'] = {},
  2270.      ['allele2'] = "Ferrous",
  2271.      ['result'] = "Silicon",
  2272.      ['chance'] = 17
  2273.     }
  2274.   breedingTable[300] = {
  2275.      ['allele1'] = "Earthen",
  2276.      ['specialConditions'] = {},
  2277.      ['allele2'] = "Windy",
  2278.      ['result'] = "Skystone",
  2279.      ['chance'] = 2
  2280.     }
  2281.   return breedingTable
  2282. end
  2283.  
  2284. function print_table(o, tabs)
  2285.     if o == 'nil' then return end
  2286.     if type(o) == 'table' then
  2287.         local s = tabs .. '{ '
  2288.         for k,v in pairs(o) do
  2289.             if type(k) ~= 'number' then k = '"'..k..'"' end
  2290.             if v ~= 'nil' then
  2291.                 s = s .. '['..k..'] = ' .. dump(v) .. ','
  2292.             else
  2293.                 s = '  '
  2294.             end
  2295.         end
  2296.         s = s .. '} '
  2297.     else
  2298.         s = tostring(tabs .. o)
  2299.     end
  2300.     print(s)
  2301.     return s
  2302. end
  2303. function print_table(o)
  2304.     if type(o) == 'table' then
  2305.         print_table(o, '')
  2306.     else
  2307.         print(tostring(o))
  2308.     end
  2309. end
  2310. function Forte40.buildMutationGraph(apiary)
  2311.   local mutations = {}
  2312.   function Forte40.addMutateTo(parent1, parent2, offspring, chance)
  2313.     if mutations[parent1] ~= nil then
  2314.       if mutations[parent1].mutateTo[offspring] ~= nil then
  2315.         mutations[parent1].mutateTo[offspring][parent2] = chance
  2316.       else
  2317.         mutations[parent1].mutateTo[offspring] = {[parent2] = chance}
  2318.       end
  2319.     else
  2320.       mutations[parent1] = {
  2321.         mutateTo = {[offspring]={[parent2] = chance}}
  2322.       }
  2323.     end
  2324.   end
  2325.   for _, parents in pairs(getBeeBreedingData()) do
  2326.         if debug then print_table(parents) end
  2327.         Forte40.fixParents(parents)
  2328.     Forte40.addMutateTo(parents.allele1, parents.allele2, parents.result, parents.chance)
  2329.     Forte40.addMutateTo(parents.allele2, parents.allele1, parents.result, parents.chance)
  2330.   end
  2331.   mutations.getBeeParents = function(name)
  2332.     return apiary.getBeeParents((Forte40.nameFix[name] or name))
  2333.   end
  2334.   return mutations
  2335. end
  2336. function Forte40.buildTargetSpeciesList(catalog, apiary)
  2337.   local targetSpeciesList = {}
  2338.   local parentss = apiary.peripheral.getBeeBreedingData()
  2339.   for _, parents in pairs(parentss) do
  2340.     local skip = false
  2341.     for i, ignoreSpecies in ipairs(config.registry.ignoreSpecies) do
  2342.       if parents.result == ignoreSpecies then
  2343.         skip = true
  2344.         break
  2345.       end
  2346.     end
  2347.     if not skip and
  2348.         (catalog.reference[parents.result] == nil or catalog.reference[parents.result].pair == nil) and  -- skip if reference pair exists
  2349.         catalog.reference[parents.allele1] ~= nil and catalog.reference[parents.allele2] ~= nil and
  2350.         ((catalog.reference[parents.allele1].princess ~= nil and catalog.reference[parents.allele2].drone ~= nil) or -- princess 1 and drone 2 available
  2351.         (catalog.reference[parents.allele2].princess ~= nil and catalog.reference[parents.allele1].drone ~= nil)) -- princess 2 and drone 1 available
  2352.     then
  2353.       table.insert(targetSpeciesList, parents.result)
  2354.     end
  2355.   end
  2356.   return targetSpeciesList
  2357. end
  2358. -- percent chance of 2 species turning into a target species
  2359. function Forte40.mutateSpeciesChance(mutations, species1, species2, targetSpecies)
  2360.   local chance = {}
  2361.   if species1 == species2 then
  2362.     chance[species1] = 100
  2363.   else
  2364.     chance[species1] = 50
  2365.     chance[species2] = 50
  2366.   end
  2367.   if mutations[species1] ~= nil then
  2368.     for species, mutates in pairs(mutations[species1].mutateTo) do
  2369.       local mutateChance = mutates[species2]
  2370.       if mutateChance ~= nil then
  2371.         chance[species] = mutateChance
  2372.         chance[species1] = chance[species1] - mutateChance / 2
  2373.         chance[species2] = chance[species2] - mutateChance / 2
  2374.       end
  2375.     end
  2376.   end
  2377.   return chance[targetSpecies] or 0.0
  2378. end
  2379. -- percent chance of 2 bees turning into target species
  2380. function Forte40.mutateBeeChance(mutations, princess, drone, targetSpecies)
  2381.   if princess.individual.isAnalyzed then
  2382.     if drone.individual.isAnalyzed then
  2383.       return (Forte40.mutateSpeciesChance(mutations, princess.individual.active.species.name, drone.individual.active.species.name, targetSpecies) / 4
  2384.           +Forte40.mutateSpeciesChance(mutations, princess.individual.inactive.species.name, drone.individual.active.species.name, targetSpecies) / 4
  2385.           +Forte40.mutateSpeciesChance(mutations, princess.individual.active.species.name, drone.individual.inactive.species.name, targetSpecies) / 4
  2386.           +Forte40.mutateSpeciesChance(mutations, princess.individual.inactive.species.name, drone.individual.inactive.species.name, targetSpecies) / 4)
  2387.     end
  2388.   elseif drone.individual.isAnalyzed then
  2389.   else
  2390.     return Forte40.mutateSpeciesChance(princess.individual.displayName, drone.individual.displayName, targetSpecies)
  2391.   end
  2392. end
  2393. function Forte40.buildScoring()
  2394.   local function makeNumberScorer(trait, default)
  2395.     local function scorer(bee)
  2396.       if bee.individual.isAnalyzed then
  2397.         return (bee.individual.active[trait] + bee.individual.inactive[trait]) / 2
  2398.       else
  2399.         return default
  2400.       end
  2401.     end
  2402.     return scorer
  2403.   end
  2404.  
  2405.   local function makeBooleanScorer(trait)
  2406.     local function scorer(bee)
  2407.       if bee.individual.isAnalyzed then
  2408.         return ((bee.individual.active[trait] and 1 or 0) + (bee.individual.inactive[trait] and 1 or 0)) / 2
  2409.       else
  2410.         return 0
  2411.       end
  2412.     end
  2413.     return scorer
  2414.   end
  2415.  
  2416.   local function makeTableScorer(trait, default, lookup)
  2417.     local function scorer(bee)
  2418.       if bee.individual.isAnalyzed then
  2419.         return ((lookup[bee.individual.active[trait]] or default) + (lookup[bee.individual.inactive[trait]] or default)) / 2
  2420.       else
  2421.         return default
  2422.       end
  2423.     end
  2424.     return scorer
  2425.   end
  2426.  
  2427.   local scoresTolerance = {
  2428.     ["None"]   = 0,
  2429.     ["Up 1"]   = 1,
  2430.     ["Up 2"]   = 2,
  2431.     ["Up 3"]   = 3,
  2432.     ["Up 4"]   = 4,
  2433.     ["Up 5"]   = 5,
  2434.     ["Down 1"] = 1,
  2435.     ["Down 2"] = 2,
  2436.     ["Down 3"] = 3,
  2437.     ["Down 4"] = 4,
  2438.     ["Down 5"] = 5,
  2439.     ["Both 1"] = 2,
  2440.     ["Both 2"] = 4,
  2441.     ["Both 3"] = 6,
  2442.     ["Both 4"] = 8,
  2443.     ["Both 5"] = 10
  2444.   }
  2445.  
  2446.   local scoresFlowerProvider = {
  2447.     ["None"] = 5,
  2448.     ["Rocks"] = 4,
  2449.     ["Flowers"] = 3,
  2450.     ["Mushroom"] = 2,
  2451.     ["Cacti"] = 1,
  2452.     ["Exotic Flowers"] = 0,
  2453.     ["Jungle"] = 0
  2454.   }
  2455.  
  2456.   return {
  2457.     ["fertility"] = makeNumberScorer("fertility", 1),
  2458.     ["flowering"] = makeNumberScorer("flowering", 1),
  2459.     ["speed"] = makeNumberScorer("speed", 1),
  2460.     ["lifespan"] = makeNumberScorer("lifespan", 1),
  2461.     ["nocturnal"] = makeBooleanScorer("nocturnal"),
  2462.     ["tolerantFlyer"] = makeBooleanScorer("tolerantFlyer"),
  2463.     ["caveDwelling"] = makeBooleanScorer("caveDwelling"),
  2464.     ["effect"] = makeBooleanScorer("effect"),
  2465.     ["temperatureTolerance"] = makeTableScorer("temperatureTolerance", 0, scoresTolerance),
  2466.     ["humidityTolerance"] = makeTableScorer("humidityTolerance", 0, scoresTolerance),
  2467.     ["flowerProvider"] = makeTableScorer("flowerProvider", 0, scoresFlowerProvider),
  2468.     ["territory"] = function(bee)
  2469.       if bee.individual.isAnalyzed then
  2470.         return ((bee.individual.active.territory[1] * bee.individual.active.territory[2] * bee.individual.active.territory[3]) +
  2471.             (bee.individual.inactive.territory[1] * bee.individual.inactive.territory[2] * bee.individual.inactive.territory[3])) / 2
  2472.       else
  2473.         return 0
  2474.       end
  2475.     end
  2476.   }
  2477. end
  2478. function Forte40.compareMates(a, b)
  2479.   for i, trait in ipairs(config.registry.traitPriority) do
  2480.     if a[trait] ~= b[trait] then
  2481.       return a[trait] > b[trait]
  2482.     end
  2483.   end
  2484.   return true
  2485. end
  2486. function Forte40.breedAllSpecies(mutations, interface, apiary, scorers, speciesList)
  2487.   if #speciesList == 0 then
  2488.     logger:log('< Forte40: Please add more bee species and press [Enter]')
  2489.     io.read("*l")
  2490.   else
  2491.     for i, targetSpecies in ipairs(speciesList) do
  2492.       Forte40.breedTargetSpecies(mutations, interface, apiary, scorers, targetSpecies)
  2493.     end
  2494.   end
  2495. end
  2496. function Forte40.breedBees(interface, apiary, princess, drone)
  2497.   apiary:clear()
  2498.   interface:putBee(princess.id, config.registry.breederDir, 1, 1)
  2499.   interface:putBee(drone.id, config.registry.breederDir, 1, 2)
  2500.   apiary:clear()
  2501. end
  2502. -- selects best pair for target species
  2503. --   or initiates breeding of lower species
  2504. function Forte40.selectPair(mutations, scorers, catalog, targetSpecies)
  2505.   logger:color(colors.gray):log('  Forte40: -> ' .. targetSpecies .. '\n'):color(colors.white)
  2506.   local baseChance = 0
  2507.   if #mutations.getBeeParents(targetSpecies) > 0 then
  2508.     local parents = mutations.getBeeParents(targetSpecies)[1]
  2509.     baseChance = parents.chance
  2510.         if type(parents.specialConditions) ~= 'table' then parents.specialConditions = {[1] = tostring(parents.specialConditions)} end
  2511.     if table.getn(parents.specialConditions) > 0 then
  2512.       logger:log('  Forte40: special conditions:\n' .. table.concat(parents.specialConditions, '\n') .. '\n')
  2513.     end
  2514.   end
  2515.   local mateCombos = Forte40.choose(catalog.princesses, catalog.drones)
  2516.   local mates = {}
  2517.   local haveReference =
  2518.     catalog.reference[targetSpecies] ~= nil and
  2519.     catalog.reference[targetSpecies].princess ~= nil and
  2520.     catalog.reference[targetSpecies].drone ~= nil
  2521.   for i, v in ipairs(mateCombos) do
  2522.     local chance = Forte40.mutateBeeChance(mutations, v[1], v[2], targetSpecies) or 0
  2523.     if (not haveReference and chance >= baseChance / 2) or
  2524.             (haveReference and chance > 25) then
  2525.       local newMates = {
  2526.         ["princess"] = v[1],
  2527.         ["drone"] = v[2],
  2528.         ["speciesChance"] = chance
  2529.       }
  2530.       for trait, scorer in pairs(scorers) do
  2531.         newMates[trait] = (scorer(v[1]) + scorer(v[2])) / 2
  2532.       end
  2533.       table.insert(mates, newMates)
  2534.     end
  2535.   end
  2536.   if #mates > 0 then
  2537.     table.sort(mates, Forte40.compareMates)
  2538.     for i = math.min(#mates, 5), 2, -1 do
  2539.       local parents = mates[i]
  2540.       logger:debug('  Forte40: ' ..
  2541.               Forte40.beeName(parents.princess) .. ' ' ..
  2542.               Forte40.beeName(parents.drone) .. ' ' ..
  2543.               parents.speciesChance .. ' ' ..
  2544.               parents.fertility .. ' ' ..
  2545.               parents.flowering .. ' ' ..
  2546.               parents.nocturnal .. ' ' ..
  2547.               parents.tolerantFlyer .. ' ' ..
  2548.               parents.caveDwelling .. ' ' ..
  2549.               parents.lifespan .. ' ' ..
  2550.               parents.temperatureTolerance .. ' ' ..
  2551.               parents.humidityTolerance .. '\n')
  2552.     end
  2553.     local parents = mates[1]
  2554.     logger:log('  Forte40: best combination:\n' ..
  2555.             Forte40.beeName(parents.princess) .. ' ' ..
  2556.             Forte40.beeName(parents.drone) .. ' ' ..
  2557.             parents.speciesChance .. ' ' ..
  2558.             parents.fertility .. ' ' ..
  2559.             parents.flowering .. ' ' ..
  2560.             parents.nocturnal .. ' ' ..
  2561.             parents.tolerantFlyer .. ' ' ..
  2562.             parents.caveDwelling .. ' ' ..
  2563.             parents.lifespan .. ' ' ..
  2564.             parents.temperatureTolerance .. ' ' ..
  2565.             parents.humidityTolerance .. '\n')
  2566.     return mates[1]
  2567.   else
  2568.     -- check for reference bees and breed if drone count is 1
  2569.     if catalog.reference[targetSpecies] ~= nil and
  2570.        catalog.reference[targetSpecies].princess ~= nil and
  2571.        catalog.reference[targetSpecies].drone ~= nil
  2572.     then
  2573.       logger:log('  Forte40: Breeding extra drone from reference bees\n')
  2574.       return {
  2575.         ["princess"] = catalog.referencePrincessesBySpecies[targetSpecies],
  2576.         ["drone"] = catalog.referenceDronesBySpecies[targetSpecies]
  2577.       }
  2578.     end
  2579.     -- attempt lower tier bee
  2580.     local parentss = mutations.getBeeParents(targetSpecies)
  2581.     if #parentss > 0 then
  2582.       table.sort(parentss, function(a, b) return a.chance > b.chance end)
  2583.       local trySpecies = {}
  2584.       for i, parents in ipairs(parentss) do
  2585.         Forte40.fixParents(parents)
  2586.         if (catalog.reference[parents.allele2] == nil or
  2587.             catalog.reference[parents.allele2].pair == nil or -- no reference bee pair
  2588.             catalog.reference[parents.allele2].droneCount < 2 or -- no extra reference drone
  2589.             catalog.reference[parents.allele2].princess == nil) -- no converted princess
  2590.             and trySpecies[parents.allele2] == nil then
  2591.           table.insert(trySpecies, parents.allele2)
  2592.           trySpecies[parents.allele2] = true
  2593.         end
  2594.         if (catalog.reference[parents.allele1] == nil or
  2595.             catalog.reference[parents.allele1].pair == nil or -- no reference bee pair
  2596.             catalog.reference[parents.allele1].droneCount < 2 or -- no extra reference drone
  2597.             catalog.reference[parents.allele1].princess == nil) -- no converted princess
  2598.             and trySpecies[parents.allele1] == nil then
  2599.           table.insert(trySpecies, parents.allele1)
  2600.           trySpecies[parents.allele1] = true
  2601.         end
  2602.       end
  2603.       for _, species in ipairs(trySpecies) do
  2604.         local mates = Forte40.selectPair(mutations, scorers, catalog, species)
  2605.         if mates ~= nil then
  2606.           return mates
  2607.         end
  2608.       end
  2609.     end
  2610.     return nil
  2611.   end
  2612. end
  2613. function Forte40.isPureBred(bee1, bee2, targetSpecies)
  2614.   if bee1.individual.isAnalyzed and bee2.individual.isAnalyzed then
  2615.     if bee1.individual.active.species.name == bee1.individual.inactive.species.name and
  2616.             bee2.individual.active.species.name == bee2.individual.inactive.species.name and
  2617.             bee1.individual.active.species.name == bee2.individual.active.species.name and
  2618.             (targetSpecies == nil or bee1.individual.active.species.name == targetSpecies) then
  2619.       return true
  2620.     end
  2621.   elseif bee1.individual.isAnalyzed == false and bee2.individual.isAnalyzed == false then
  2622.     if bee1.individual.displayName == bee2.individual.displayName then
  2623.       return true
  2624.     end
  2625.   end
  2626.   return false
  2627. end
  2628. function Forte40.breedTargetSpecies(mutations, inv, apiary, scorers, targetSpecies)
  2629.   while true do
  2630.     if application.catalog.princessesCount == 0 then
  2631.       logger:color(colors.yellow)
  2632.             :log('< Forte40: Please add more princesses and press [Enter]')
  2633.             :color(colors.white)
  2634.       io.read("*l")
  2635.       application.catalog:run(application.storage)
  2636.     elseif application.catalog.dronesCount == 0 then
  2637.       logger:color(colors.yellow)
  2638.             :log('< Forte40: Please add more drones and press [Enter]')
  2639.             :color(colors.white)
  2640.       io.read("*l")
  2641.       application.catalog:run(application.storage)
  2642.     else
  2643.       logger:log('  Forte40: targetting ' .. targetSpecies .. '\n')
  2644.       local mates = Forte40.selectPair(mutations, scorers, application.catalog:toForte40(), targetSpecies)
  2645.       if mates ~= nil then
  2646.         if Forte40.isPureBred(mates.princess, mates.drone, targetSpecies) then
  2647.           break
  2648.         else
  2649.           Forte40.breedBees(inv, apiary, mates.princess, mates.drone)
  2650.           application.catalog:run(application.storage)
  2651.         end
  2652.       else
  2653.         logger:color(colors.yellow)
  2654.               :log('< Forte40: Please add more bee species for ' .. targetSpecies .. ' and press [Enter]')
  2655.               :color(colors.white)
  2656.         io.read("*l")
  2657.         application.catalog:run(application.storage)
  2658.       end
  2659.     end
  2660.   end
  2661.   logger:log('< Forte40: Bees are purebred\n')
  2662. end
  2663.  
  2664. --- Create table-based classes
  2665. -- @author http://lua-users.org/wiki/ObjectOrientationTutorial
  2666. function Creator(...)
  2667.   -- "cls" is the new class
  2668.   local cls, bases = {}, {...}
  2669.   -- copy base class contents into the new class
  2670.   for i, base in ipairs(bases) do
  2671.     for k, v in pairs(base) do
  2672.       cls[k] = v
  2673.     end
  2674.   end
  2675.   -- set the class's __index, and start filling an "is_a" table that contains this class and all of its bases
  2676.   -- so you can do an "instance of" check using my_instance.is_a[MyClass]
  2677.   cls.__index, cls.is_a = cls, {[cls] = true}
  2678.   for i, base in ipairs(bases) do
  2679.     for c in pairs(base.is_a) do
  2680.       cls.is_a[c] = true
  2681.     end
  2682.     cls.is_a[base] = true
  2683.   end
  2684.   -- the class's __call metamethod
  2685.   setmetatable(cls, {__call = function (c, ...)
  2686.     local instance = setmetatable({}, c)
  2687.     -- run the init method if it's there
  2688.     local init = instance._init
  2689.     if init then init(instance, ...) end
  2690.     return instance
  2691.   end})
  2692.   -- return the new class table, that's ready to fill with methods
  2693.   return cls
  2694. end
  2695.  
  2696. --- Application class
  2697. -- WOW, many OOP, such API, much methods
  2698. local App = Creator()
  2699. --- Provides most of initialization
  2700. function App:_init(args)
  2701.   self.version = '2.0.0'
  2702.   logger:color(colors.green)
  2703.         :log('> Second_Fry\'s openbee modular fork (v' .. self.version .. ')\n')
  2704.         :log('> Thanks to Forte40 @ GitHub (forked on v2.2.1)\n')
  2705.         :color(colors.gray)
  2706.         :log('  Got arguments: ' .. table.concat(args, ', ') .. '\n')
  2707.         :color(colors.white)
  2708.   fs.makeDir('.openbee')
  2709.   self.args = args or {}
  2710.   self.storage = self:initStorage()
  2711.   self.breeder = self:initBreeder()
  2712.   self.traitPriority = config.registry.traitPriority
  2713.   self:initMutationGraph()
  2714.   self.catalog = Catalog()
  2715. end
  2716. --- Iterates over requested species and traits and setups priorities
  2717. function App:parseArgs()
  2718.   local priority = 1
  2719.   local isTrait = false
  2720.   for _, marg in ipairs(self.args) do
  2721.     isTrait = false
  2722.     for priorityConfig = 1, #self.traitPriority do
  2723.       if marg == self.traitPriority[priorityConfig] then
  2724.         isTrait = true
  2725.         table.remove(self.traitPriority, priorityConfig)
  2726.         table.insert(self.traitPriority, priority, marg)
  2727.         priority = priority + 1
  2728.         break
  2729.       end
  2730.     end
  2731.     if not isTrait then
  2732.       self.speciesRequested = marg
  2733.     end
  2734.   end
  2735. end
  2736. function App:initStorage()
  2737.   local path = config.registry.storageProvider
  2738.   local filename = string.sub(path, 9) -- remove openbee/
  2739.   os.loadAPI(path)
  2740.   return _G[filename]['StorageProvider'](Creator, IStorage, config, logger, ItemTypes)()
  2741. end
  2742. function App:initBreeder()
  2743.   local path = config.registry.breederProvider
  2744.   local filename = string.sub(path, 9) -- remove openbee/
  2745.   os.loadAPI(path)
  2746.   return _G[filename]['BreederProvider'](Creator, IStorage, config, logger, ItemTypes)()
  2747. end
  2748. function App:initMutationGraph()
  2749.   self.beeGraph = {}
  2750.   local beeGraph = getBeeBreedingData()
  2751.   for _, mutation in ipairs(beeGraph) do
  2752.     if self.beeGraph[mutation.result] == nil then self.beeGraph[mutation.result] = {} end
  2753.     table.insert(self.beeGraph[mutation.result], mutation)
  2754.     -- Somehow doesn't report Unusual as species via breeder.listAllSpecies()
  2755.     -- So using fix dirty fix
  2756.     BeeTypes[mutation.allele1] = true
  2757.     BeeTypes[mutation.allele2] = true
  2758.     BeeTypes[mutation.result] = true
  2759.   end
  2760. end
  2761. function App:analyzerClear()
  2762.   local beeID, beeTest, beeRet
  2763.   local residentSleeperTime = 0
  2764.   if not config.registry.useAnalyzer then return end
  2765.   self.storage:fetch()
  2766.   logger:log('    Analyzer: checking')
  2767.   while true do
  2768.     for slot = 9, 12 do self.storage.peripheral.pullItem(config.registry.analyzerDir, slot) end
  2769.     -- Check if Analyzer was operating
  2770.     -- This is not a cycle, runs once
  2771.     for id, bee in pairs(self.storage.bees) do
  2772.       if bee.individual.isAnalyzed then
  2773.         beeTest = bee
  2774.         beeID = id
  2775.       end
  2776.       break
  2777.     end
  2778.     if beeTest == nil then break else
  2779.       self.storage:putBee(beeID, config.registry.analyzerDir, 1, 8)
  2780.       sleep(1)
  2781.       residentSleeperTime = residentSleeperTime + 1
  2782.       beeRet = self.storage.peripheral.pullItem(config.registry.analyzerDir, 9)
  2783.       if beeRet > 0 then break else
  2784.         logger:clearLine():log('    Analyzer: waiting (' .. residentSleeperTime .. ' seconds)')
  2785.         sleep(5) -- Analyzer tick is 30 seconds
  2786.         residentSleeperTime = residentSleeperTime + 5
  2787.       end
  2788.     end
  2789.   end
  2790.   logger:clearLine():log('    Analyzer: done waiting (was ' .. residentSleeperTime .. ' seconds)\n')
  2791. end
  2792. function App:main()
  2793.   local doRestart = false
  2794.   logger:color(colors.lightBlue)
  2795.         :log('  Initial: clearing breeder\n')
  2796.         :color(colors.white)
  2797.   self.breeder:clear()
  2798.   logger:color(colors.lightBlue)
  2799.         :log('  Initial: clearing analyzer\n')
  2800.         :color(colors.white)
  2801.   self:analyzerClear()
  2802.   logger:color(colors.lightBlue)
  2803.         :log('  Initial: categorizing bees\n')
  2804.         :color(colors.white)
  2805.   self.catalog:run(self.storage)
  2806.   while self.catalog.queens ~= nil do
  2807.     logger:color(colors.lightBlue)
  2808.           :log('  Initial: clearing queens\n')
  2809.           :color(colors.white)
  2810.     for id, bee in pairs(self.catalog.queens) do
  2811.       self.storage:putBee(id, config.registry.breederDir)
  2812.       self.breeder:clear()
  2813.     end
  2814.     self.catalog:run(self.storage)
  2815.   end
  2816.   if self.speciesRequested ~= nil then
  2817.     self.speciesTarget = self.speciesRequested:sub(1,1):upper() .. self.speciesRequested:sub(2):lower()
  2818.     if BeeTypes[self.speciesTarget] ~= true then
  2819.       logger:color(colors.red)
  2820.             :log('! Species ' .. self.speciesTarget .. ' is not found!\n')
  2821.             :color(colors.white)
  2822.       return
  2823.     end
  2824.     Forte40.breedTargetSpecies(Forte40.buildMutationGraph(self.breeder.peripheral), self.storage, self.breeder, Forte40.buildScoring(), self.speciesTarget)
  2825.     -- FIXME use self:breedSpecies(self.speciesTarget)
  2826.   else -- FIXME implement self:breedAll()
  2827.     local mutations, scorers = Forte40.buildMutationGraph(self.breeder.peripheral), Forte40.buildScoring()
  2828.     while true do
  2829.       Forte40.breedAllSpecies(mutations, self.storage, self.breeder, scorers, Forte40.buildTargetSpeciesList(self.catalog, self.breeder))
  2830.       self.catalog:run(self.storage)
  2831.     end
  2832.   end
  2833. end
  2834. function App:analyze(id)
  2835.   local beeRet
  2836.   local residentSleeperTime = 32
  2837.   logger:log('    Analyze: some bee')
  2838.   self.storage:putBee(id, config.registry.analyzerDir, 64, 3) -- slot 3 is magic number
  2839.   sleep(32) -- Analyzer tick is 30 seconds
  2840.   while true do
  2841.     beeRet = 0
  2842.     for slot = 9, 12 do
  2843.       beeRet = beeRet + self.storage.peripheral.pullItem(config.registry.analyzerDir, slot)
  2844.     end
  2845.     if beeRet > 0 then break else
  2846.       logger:clearLine():log('    Analyze: waiting (' .. residentSleeperTime .. ' seconds)')
  2847.       sleep(5) -- Analyzer tick is 30 seconds
  2848.       residentSleeperTime = residentSleeperTime + 5
  2849.     end
  2850.   end
  2851.   logger:clearLine():log('    Analyze: done waiting (was ' .. residentSleeperTime .. ' seconds)\n')
  2852. end
  2853. function App:breedSpecies(species)
  2854.   logger:color(colors.lightBlue)
  2855.         :log('  Breeding: ' .. species .. '\n')
  2856.         :color(colors.white)
  2857.   while true do
  2858.     self.catalog:run(self.storage)
  2859.     if self.catalog.princesses == nil then
  2860.       logger:color(colors.yellow)
  2861.             :log('< Breeding: add more princesses?\n')
  2862.             :color(colors.white)
  2863.       io.read("*l")
  2864.     elseif self.catalog.drones == nil then
  2865.       logger:color(colors.yellow)
  2866.             :log('< Breeding: add more drones?\n')
  2867.             :color(colors.white)
  2868.       io.read("*l")
  2869.     else
  2870.       if self.beeGraph[species] ~= nil then
  2871.         self.parentBreedable = true
  2872.         -- TODO select parent line which exists (i.e. Common can be produced in tons of ways)
  2873.         for _, mutation in ipairs(self.beeGraph[species]) do
  2874.           for _, parent in ipairs({mutation.allele1, mutation.allele2}) do
  2875.             if self.catalog.reference[parent] == nil or
  2876.                self.catalog.reference[parent].drone == nil or
  2877.                self.catalog.reference[parent].droneCount < 2
  2878.             then
  2879.               logger:log('  Breeding: getting parent first\n')
  2880.               self:breedSpecies(parent)
  2881.             end
  2882.           end
  2883.         end
  2884.       else
  2885.         logger:color(colors.red)
  2886.               :log('  Breeder: can\'t breed prime species (' .. species .. ')')
  2887.               :color(colors.white)
  2888.         error('Prime ' .. species .. ' is not found.')
  2889.       end
  2890.       if table.getn(self.beeGraph[species].specialConditions) > 0 then
  2891.         logger:log('  Breeder: special conditions:\n' .. self.beeGraph[species].specialConditions:concat('\n'))
  2892.               :color(colors.yellow)
  2893.               :log('< Breeder: confirm that conditions met\n')
  2894.               :color(colors.white)
  2895.       end
  2896.       -- FIXME do some actual breeding
  2897.       break
  2898.     end
  2899.   end
  2900.   logger:log('  Breeding: untested done.\n')
  2901. end
  2902.  
  2903. --- Catalog class
  2904. Catalog = Creator()
  2905. function Catalog:run(storage)
  2906.   if config.registry.useAnalyzer == true then
  2907.     logger:color(colors.lightBlue)
  2908.           :log('  Catalog: analyzing bees\n')
  2909.           :color(colors.white)
  2910.     self:analyzeBees(storage)
  2911.   end
  2912.   logger:debug('  Catalog: creating\n')
  2913.   self:create(storage)
  2914.   logger:color(colors.lightBlue)
  2915.         :log('  Catalog: (TODO) building local mutation graph \n')
  2916.         :color(colors.white)
  2917.   self:buildMutationGraph(storage)
  2918. end
  2919. function Catalog:analyzeBees(storage)
  2920.   local analyzeCount = 0
  2921.   storage:fetch()
  2922.   for id, bee in pairs(storage.bees) do
  2923.     if not bee.individual.isAnalyzed then
  2924.       application:analyze(id)
  2925.       analyzeCount = analyzeCount + 1
  2926.     end
  2927.   end
  2928.   if analyzeCount > 0 then logger:log('    Catalog: analyzed ' .. analyzeCount .. ' new bees\n') end
  2929. end
  2930. function Catalog:create(storage)
  2931.   self.reference = {}
  2932.   self.drones = nil
  2933.   self.dronesCount = 0
  2934.   self.princesses = nil
  2935.   self.princessesCount = 0
  2936.   self.queens = nil
  2937.   storage:fetch()
  2938.   for id, bee in pairs(storage.bees) do
  2939.     local species = bee.individual.active.species.name
  2940.     if self.reference[species] == nil then self.reference[species] = {} end
  2941.     if ItemTypes[bee.id].isDrone then
  2942.       if self.reference[species].drone == nil then
  2943.         self.reference[species].drone = {}
  2944.         self.reference[species].droneCount = 0
  2945.       end
  2946.       if self.drones == nil then self.drones = {} end
  2947.       self.reference[species].drone[id] = bee
  2948.       self.reference[species].droneCount = self.reference[species].droneCount + bee.qty
  2949.       self.drones[id] = bee
  2950.       self.dronesCount = self.dronesCount + bee.qty
  2951.     end
  2952.     if ItemTypes[bee.id].isPrincess then
  2953.       if self.reference[species].princess == nil then
  2954.         self.reference[species].princess = {}
  2955.         self.reference[species].princessCount = 0
  2956.       end
  2957.       if self.princesses == nil then self.princesses = {} end
  2958.       self.reference[species].princess[id] = bee
  2959.       self.reference[species].princessCount = self.reference[species].princessCount + bee.qty
  2960.       self.princesses[id] = bee
  2961.       self.princessesCount = self.princessesCount + bee.qty
  2962.     end
  2963.     if ItemTypes[bee.id].isQueen then
  2964.       if self.queens == nil then self.queens = {} end
  2965.       self.queens[id] = bee
  2966.     end
  2967.     if self.reference[species].drone ~= nil and self.reference[species].princess ~= nil then
  2968.       self.reference[species].pair = true
  2969.     end
  2970.   end
  2971.   if table.getn(self.reference) > 0 then
  2972.     logger:log('    Catalog: have reference for:\n    ')
  2973.     for species, table in pairs(self.reference) do if table.pair == true then logger:log(species, ', ') end end
  2974.     logger:log('\n')
  2975.   end
  2976. end
  2977. function Catalog:buildMutationGraph()
  2978.   -- TODO implement local mutation graph using available bees
  2979. end
  2980. function Catalog:toForte40()
  2981.   local princessList, droneList = {}, {}
  2982.   if self.princesses ~= nil then for id, princess in pairs(self.princesses) do
  2983.     local proxy = princess
  2984.     proxy.id = id
  2985.     table.insert(princessList, proxy)
  2986.   end end
  2987.   if self.drones ~= nil then for id, drone in pairs(self.drones) do
  2988.     local proxy = drone
  2989.     proxy.id = id
  2990.     table.insert(droneList, proxy)
  2991.   end end
  2992.   return {
  2993.     ['princesses'] = princessList,
  2994.     ['drones'] = droneList,
  2995.     ['reference'] = self.reference
  2996.   }
  2997. end
  2998.  
  2999. --- Breeder classes interface
  3000. IBreeder = Creator()
  3001. --- Initalizes breeder
  3002. -- Stores wrapped peripheral in peripheral attribute
  3003. -- @return IBreeder instance for chaining
  3004. function IBreeder:_init()
  3005.   return self
  3006. end
  3007. --- Clears the breeder
  3008. -- Bees should land into storage system (doesn't matter if analyzed or not)
  3009. -- @return IBreeder instance for chaining
  3010. function IBreeder:clear()
  3011.   return self
  3012. end
  3013.  
  3014. --- Storage classes interface
  3015. IStorage = Creator()
  3016. --- Initalizes storage
  3017. -- Stores wrapped peripheral in peripheral attribute
  3018. -- @return IStorage instance for chaining
  3019. function IStorage:_init()
  3020.   return self
  3021. end
  3022. --- Gets all and only bees from storage
  3023. -- @return IStorage instance for chaining
  3024. function IStorage:fetch()
  3025.   return self
  3026. end
  3027. --- Returns all bess from storage
  3028. function IStorage:getBees()
  3029.   return IStorage:fetch().bees
  3030. end
  3031. --- Puts bee somewhere
  3032. -- @param id ID for bee
  3033. -- @param peripheralSide Side where to push
  3034. -- @return IStorage instance for chaining
  3035. function IStorage:putBee(id, peripheralSide)
  3036.   return self
  3037. end
  3038.  
  3039. --- Item ids for bees
  3040. ItemTypes = {
  3041.   ['Forestry:beeDroneGE'] = {
  3042.     ['isBee'] = true,
  3043.     ['isDrone'] = true
  3044.   },
  3045.   ['Forestry:beePrincessGE'] = {
  3046.     ['isBee'] = true,
  3047.     ['isPrincess'] = true
  3048.   },
  3049.   ['Forestry:beeQueenGE'] = {
  3050.     ['isBee'] = true,
  3051.     ['isQueen'] = true
  3052.   },
  3053. }
  3054. BeeTypes = {}
  3055.  
  3056. --- Configuration class
  3057. Config = Creator()
  3058. function Config:_init(filename)
  3059.   self.file = File(filename)
  3060.   self.registry = self.file:read()
  3061.   if self.registry == nil then
  3062.     self.registry = configDefault
  3063.     self.file:write(self.registry)
  3064.   end
  3065.   return self
  3066. end
  3067.  
  3068. --- Logging class
  3069. Log = Creator()
  3070. function Log:_init()
  3071.   fs.makeDir('.openbee/logs')
  3072.   local loglast = table.remove(natsort(fs.list('.openbee/logs')))
  3073.   if loglast == nil then
  3074.     self.lognum = 1
  3075.   else
  3076.     self.lognum = tonumber(string.sub(loglast, 5)) + 1
  3077.   end
  3078.   self.logname = '.openbee/logs/log-' .. string.format("%03d", self.lognum)
  3079.   self.logfile = File(self.logname)
  3080.   self.logfile:open('w')
  3081. end
  3082. function Log:log(...)
  3083.   self:debug(arg)
  3084.   for _, marg in ipairs(arg) do
  3085.     if type(marg) == "table" then
  3086.       io.write(table.concat(marg, ' '))
  3087.     else
  3088.       io.write(marg)
  3089.     end
  3090.   end
  3091.   return self
  3092. end
  3093. function Log:debug(...)
  3094.   for _, marg in ipairs(arg) do
  3095.     if type(marg) == "table" then
  3096.       self.logfile:append(table.concat(marg, ' '))
  3097.     else
  3098.       self.logfile:append(marg)
  3099.     end
  3100.   end
  3101.   return self
  3102. end
  3103. function Log:color(color)
  3104.   term.setTextColor(color)
  3105.   return self
  3106. end
  3107. function Log:clearLine()
  3108.   local x, y = term.getCursorPos()
  3109.   term.clearLine()
  3110.   term.setCursorPos(1, y)
  3111.   return self
  3112. end
  3113. function Log:finish()
  3114.   self:color(colors.green)
  3115.       :log('> Successful finish (' .. self.logname .. ')\n')
  3116.   self.logfile:close()
  3117. end
  3118.  
  3119. --- File class
  3120. File = Creator()
  3121. function File:_init(filename)
  3122.   self.filename = filename
  3123.   return self
  3124. end
  3125. function File:open(mode)
  3126.   self.file = fs.open(self.filename, mode)
  3127.   return self
  3128. end
  3129. function File:read()
  3130.   self:open('r')
  3131.   if self.file ~= nil then
  3132.     local data = self.file.readAll()
  3133.     self:close()
  3134.     return textutils.unserialize(data)
  3135.   end
  3136. end
  3137. function File:write(data)
  3138.   self:open('w').file.write(textutils.serialize(data))
  3139.   self:close()
  3140. end
  3141. function File:append(data)
  3142.   self.file.write(data)
  3143. end
  3144. function File:close()
  3145.   self.file.close()
  3146. end
  3147.  
  3148. --- natsort
  3149. function natsort(o)
  3150.   local function padnum(d) return ("%012d"):format(d) end
  3151.   table.sort(o, function(a,b)
  3152.     return tostring(a):gsub("%d+",padnum) < tostring(b):gsub("%d+",padnum) end)
  3153.   return o
  3154. end
  3155.  
  3156. logger = Log()
  3157. config = Config('.openbee/config')
  3158. application = App({...})
  3159. application:parseArgs()
  3160. application:main()
  3161. logger:finish()
Advertisement
Add Comment
Please, Sign In to add comment