-
Notifications
You must be signed in to change notification settings - Fork 0
/
chilcalc.html
211 lines (191 loc) · 6.76 KB
/
chilcalc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Child Birth Simulation</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 20px;
background-color: #f9f9f9;
border-radius: 8px;
}
h1 {
color: #333;
}
form {
margin-bottom: 20px;
}
input[type="number"] {
margin-bottom: 10px;
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
background-color: #28a745;
color: white;
padding: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #218838;
}
#results {
margin-top: 20px;
padding: 10px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>
</head>
<body>
<h1>Child Birth Simulation</h1>
<form id="simulationForm">
<label for="first_child_age">First Child Age:</label>
<input type="number" id="first_child_age" required>
<label for="last_child_age">Last Child Age:</label>
<input type="number" id="last_child_age" required>
<label for="intervalm">Minimum Interval:</label>
<input type="number" id="intervalm" required>
<label for="interval">Maximum Interval:</label>
<input type="number" id="interval" required>
<label for="malebuff">Male Buff (0 for none):</label>
<input type="number" id="malebuff" required>
<label for="ovulationbuff">Ovulation Buff:</label>
<input type="number" id="ovulationbuff" required>
<input type="submit" value="Run Simulation">
</form>
<div id="results"></div>
<script>
document.getElementById('simulationForm').addEventListener('submit', function(event) {
event.preventDefault();
const firstChildAge = parseInt(document.getElementById('first_child_age').value);
const lastChildAge = parseInt(document.getElementById('last_child_age').value);
const intervalm = parseInt(document.getElementById('intervalm').value);
const interval = parseInt(document.getElementById('interval').value);
let malebuff = parseInt(document.getElementById('malebuff').value);
const ovulationbuff = parseInt(document.getElementById('ovulationbuff').value);
if (malebuff === 0) {
malebuff = 100;
}
let total_children = (lastChildAge - firstChildAge) + 1;
let children = 0;
let singles = 0;
let twins = 0;
let triplets = 0;
let quadruplets = 0;
let quintuplets = 0;
let sextuplets = 0;
let births = 0;
let maleCount = 0;
let femaleCount = 0;
let deathCount = 0;
let mage = firstChildAge;
while (total_children > 0) {
const ange = (interval !== intervalm) ? Math.floor(Math.random() * (interval - intervalm + 1)) + intervalm : interval;
const chance = Math.floor(Math.random() * 1000) + 1;
if (chance > 346 * (ovulationbuff / 100) && chance <= 900) {
// Single birth
children += 1;
singles += 1;
mage += 1;
total_children -= ange;
// Determine gender
if (Math.random() < 0.5) {
maleCount++;
} else {
femaleCount++;
}
births += 1;
} else if (chance > 900) {
// Stillbirth
deathCount++;
mage += 1;
total_children -= 1;
} else if (chance > 148 && chance <= 346 * (1 + ovulationbuff / 100)) {
// Twin birth
children += 2;
twins += 1;
mage += 1;
total_children -= ange;
// Determine genders for twins
for (let i = 0; i < 2; i++) {
if (Math.random() < 0.5) {
maleCount++;
} else {
femaleCount++;
}
}
births += 1;
} else if (chance > 79 * (1 + ovulationbuff / 100) && chance <= 148 * (1 + ovulationbuff / 100)) {
// Triplet birth
children += 3;
triplets += 1;
mage += 1;
total_children -= ange;
// Determine genders for triplets
for (let i = 0; i < 3; i++) {
if (Math.random() < 0.5) {
maleCount++;
} else {
femaleCount++;
}
}
births += 1;
} else if (chance > 9 * (1 + ovulationbuff / 100) && chance <= 78920 * (1 + ovulationbuff / 100)) {
// Quadruplet birth
children += 4;
quadruplets += 1;
mage += 1;
total_children -= ange;
// Determine genders for quadruplets
for (let i = 0; i < 4; i++) {
if (Math.random() < 0.5) {
maleCount++;
} else {
femaleCount++;
}
}
births += 1;
} else {
// Other births
const other = Math.floor(Math.random() * (9 - 5 + 1)) + 5;
children += other;
births += 1;
mage += 1;
total_children -= ange;
// Determine genders for other births
for (let i = 0; i < other; i++) {
if (Math.random() < 0.5) {
maleCount++;
} else {
femaleCount++;
}
}
}
}
document.getElementById('results').innerHTML = `
<h2>Simulation Results</h2>
<p>Total Children: ${children}</p>
<p>Singles: ${singles}</p>
<p>Twins: ${twins}</p>
<p>Triplets: ${triplets}</p>
<p>Quadruplets: ${quadruplets}</p>
<p>Quintuplets: ${quintuplets}</p>
<p>Sextuplets: ${sextuplets}</p>
<p>Births: ${births}</p>
<p>Male Children: ${maleCount}</p>
<p>Female Children: ${femaleCount}</p>
<p>Deaths: ${deathCount}</p>
`;
});
</script>
</body>
</html>