-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (57 loc) · 1.82 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="dice.png">
<title>Dice Roll Statistics</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
</head>
<body>
<h1>Dice Roll</h1>
<p>Rolls dice and records the sum of their values, plotting a chart. You can also see the expected probability
distribution.</p>
<label for="numDice">Number of dice to roll:</label>
<input type="number" id="numDice" min="1" max="10" value="2">
<label for="numSides">Number of sides of the dice:</label>
<input type="number" id="numSides" min="1" max="10" value="6">
<br>
<button id="rollButton">Roll Dice</button>
<button id="clearButton">Clear Rolls</button>
<input type="text" id="numRolls" placeholder="Enter number of rolls" value="1">
<button id="toggleDistributionLineButton">Toggle Distribution Line</button>
<br>
<label for="totalRolls">Total rolls:</label>
<div id="totalRolls">0</div>
<div style="width: 50%; height: 50%;">
<canvas id="myChart" width="100%" height="50%"></canvas>
</div>
<button id="toggleExpectedProbabilitiesTable">Show expected probabilities</button>
<style>
table {
border-collapse: collapse;
}
tr {
border-top: 1px solid black;
border-bottom: 1px solid black;
}
td,
th {
border-left: 1px solid black;
border-right: 1px solid black;
padding: 7px;
text-align: center;
}
</style>
<div id="expectedProbabilitiesTableDiv"
style="overflow:scroll; height:100px; width:50%; border: 1px solid black; display: block;">
<table id="expectedProbabilitiesTable" style="display: block;">
<tr>
<th>Sum</th>
</tr>
<tr>
<th>Probability</th>
</tr>
</table>
</div>
<script src="script.js"></script>
</body>
</html>