/* * ReWild - Replacement for Wildfire. * Copyright (c) 2016, 2018, 2020 HarJIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * The origin of this software must not be misrepresented; you must not claim that you wrote the original * software. If you use this software in a product, an acknowledgement in the product documentation would be * appreciated but is not required. * * Altered versions of the Software shall not be misrepresented as being the original Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * --- * * As an alternative to the above, you may redistribute and/or modify the Software under the following terms: * * rewild.js is free software: you can redistribute it and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * Additionally, rewild.js shall be subject to the following Section 7(c) permitted restrictions: * * The origin of this software must not be misrepresented; you must not claim that you wrote the original * software. If you use this software in a product, an acknowledgement in the product documentation would be * appreciated but is not required. * * Altered versions of the Software shall not be misrepresented as being the original Software. * */ /* * Directions: Include in a script tag (either sourced from external file or else included in the .html), after a *
tag. Include Chart.js first if you want it (otherwise it will report in CSV). * * Don't transclude from Gist itself (it will fail in Chrome due to MIME mismatch). * * Avoiding older IE compatibility modes so as to use HTML5 features (sliders) is nice, hence you may wish to * (or later compatibility strings) * */ /* * Included as the conditional of an empty if-statement so as to be reliably parsed as a called anonymous defn * rather than borked on. * Done like that in the first place so as not to clutter the global namespace, thus facilitating embedding. * */ // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later if(function(main_div){ var reset_params = function(){ /* Width in pixels. */ WIDTH=300; /* Height in pixels. */ HEIGHT=200; /* A number of individuals, expensive (makes app slow when too large). */ POPULATION=300; /* Contagion during incubation period, between 0 and 1 */ CONTAG_IN=0.7; /* Contagion when ill, between 0 and 1 */ CONTAG_CS=0.3; /* Probability of death from one infection, between 0 and 1 */ FATALITY=0.7; /* Can gain immunity: 1 (yes) or 0 (no) */ IMMUNISES=1; /* Probability of genetic immunity, between 0 and 1 */ IMMUN_GENE=0.02; /* Duration of incubation period, in frames. */ INCUBATION=80; /* Duration of illness, in frames. */ COURSE=20; /* Distance needed for infection, in pixels across and down, very expensive. */ PROXIMITY=5; /* Minimum duration between exposures (set to zero to disable). */ REFRACTORY=10; /* * For reference, in the original Wildfire: * * Flu: Immunity, involuntary exposure, range 20 out of 50, infection on contact 30%, duration 7 days, * mortality 1%. * Measles: Immunity, involuntary exposure, range 10 out of 50, infection on contact 30%, duration 10 days, * mortality 1%. * Smallpox: Immunity, involuntary exposure, range 20 out of 50, infection on contact 20%, duration 10 days, * mortality 30%. * Satan bug: No immunity, involuntary exposure, range 40 out of 50, infection on contact 80%, duration 2 days, * mortality 80%. * AIDS: No immunity, voluntary exposure, 7 days between exposures, infection on contact 5%, duration 1000 days, * mortality 99%. * */ HEALTHY_C="#6200FF"; INCUBATION_C="#FF9F00"; EXPRESS_INCUBATION_C="#FF9F00"; SICK_C="#FC002A"; IMMUNE_C="#00D4B7"; DEAD_C="#000"; SIZE=PROXIMITY; /* * There is not need for the typical user to change anything below this line. * */ }; var WIDTH;var HEIGHT;var POPULATION;var CONTAG_IN; var CONTAG_CS;var FATALITY;var IMMUNISES;var IMMUN_GENE; var INCUBATION;var COURSE;var PROXIMITY;var REFRACTORY; var HEALTHY_C;var INCUBATION_C;var SICK_C;var IMMUNE_C; var DEAD_C;var SIZE;var EXPRESS_INCUBATION_C; /* Names used by WF itself (only it lists Immune after healthy) var HEALTHY_LABEL="Healthy"; var INCUBATION_LABEL="Infected"; var SICK_LABEL="Sick"; var IMMUNE_LABEL="Immune"; var DEAD_LABEL="Dead"; */ var HEALTHY_LABEL="Unaffected"; var INCUBATION_LABEL="Incubating"; var SICK_LABEL="Sick"; var IMMUNE_LABEL="Immune"; var DEAD_LABEL="Dead"; var FRAMES_LABEL_TITLE="Days: "; var FRAMES_LABEL_UNIT=" days"; var FRAMES_LABEL_SINGULAR="Day "; var USE_SVG=(typeof SVGRectElement != "undefined"); reset_params(); var myRemove = function(arra,item){ for(var i=0;i