magic / index.html
FILHODABLAZE's picture
from kivy.app import App
483cd58 verified
Raw History Blame Contribute Delete
12.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blaze Double Analyzer</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<style>
.color-white { background-color: #f8f9fa; color: #212529; }
.color-black { background-color: #212529; color: #f8f9fa; }
.color-red { background-color: #dc3545; color: white; }
.simulation-dot {
width: 20px;
height: 20px;
border-radius: 50%;
display: inline-block;
margin-right: 5px;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen">
<div class="container mx-auto px-4 py-8 max-w-4xl">
<header class="text-center mb-8" data-aos="fade-down">
<h1 class="text-3xl font-bold text-gray-800 mb-2">
<i data-feather="bar-chart-2" class="inline mr-2"></i>
Blaze Double Analyzer
</h1>
<p class="text-gray-600">Analyze your Blaze Double game history and get insights</p>
</header>
<main>
<div class="bg-white rounded-lg shadow-md p-6 mb-6" data-aos="fade-up">
<div class="mb-4">
<label for="history-input" class="block text-gray-700 font-medium mb-2">
<i data-feather="list" class="inline mr-2"></i>
Enter your game history:
</label>
<input type="text" id="history-input"
class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Example: white,black,red,white,red,red">
<p class="text-sm text-gray-500 mt-1">Separate colors with commas (white, black, red)</p>
</div>
<button id="analyze-btn"
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-md transition duration-200 flex items-center justify-center">
<i data-feather="activity" class="mr-2"></i>
Analyze History
</button>
</div>
<div id="results-section" class="hidden" data-aos="fade-up">
<div class="bg-white rounded-lg shadow-md p-6 mb-6">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i data-feather="pie-chart" class="mr-2"></i>
Color Frequency
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<canvas id="frequency-chart" height="200"></canvas>
</div>
<div id="frequency-stats" class="space-y-3">
<!-- Stats will be inserted here -->
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow-md p-6 mb-6">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i data-feather="trending-up" class="mr-2"></i>
Streaks Analysis
</h2>
<div id="streaks-results" class="space-y-2">
<!-- Streaks will be inserted here -->
</div>
</div>
<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
<i data-feather="zap" class="mr-2"></i>
Next 20 Rounds Simulation
</h2>
<div id="simulation-results" class="flex flex-wrap gap-2 mb-4">
<!-- Simulation dots will be inserted here -->
</div>
<div id="simulation-stats" class="text-gray-700">
<!-- Simulation stats will be inserted here -->
</div>
</div>
</div>
</main>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
AOS.init();
feather.replace();
document.getElementById('analyze-btn').addEventListener('click', analyzeHistory);
});
function analyzeHistory() {
const historyInput = document.getElementById('history-input').value.trim();
if (!historyInput) {
alert('Please enter your game history!');
return;
}
const history = historyInput.split(',').map(color => color.trim().toLowerCase());
// Calculate frequency
const frequency = {};
history.forEach(color => {
frequency[color] = (frequency[color] || 0) + 1;
});
const total = history.length;
const percentage = {};
for (const color in frequency) {
percentage[color] = Math.round((frequency[color] / total) * 100 * 100) / 100;
}
// Calculate streaks
const streaks = calculateStreaks(history);
// Simulate next rounds
const simulation = simulateRounds(frequency, 20);
// Display results
displayResults(frequency, percentage, streaks, simulation);
// Show results section
document.getElementById('results-section').classList.remove('hidden');
}
function calculateStreaks(history) {
if (history.length === 0) return [];
const streaks = [];
let currentColor = history[0];
let currentLength = 1;
for (let i = 1; i < history.length; i++) {
if (history[i] === currentColor) {
currentLength++;
} else {
streaks.push({ color: currentColor, length: currentLength });
currentColor = history[i];
currentLength = 1;
}
}
streaks.push({ color: currentColor, length: currentLength });
return streaks;
}
function simulateRounds(frequency, rounds) {
const colors = Object.keys(frequency);
const weights = colors.map(color => frequency[color]);
const total = weights.reduce((sum, weight) => sum + weight, 0);
const probabilities = weights.map(weight => weight / total);
const results = [];
for (let i = 0; i < rounds; i++) {
const random = Math.random();
let sum = 0;
for (let j = 0; j < probabilities.length; j++) {
sum += probabilities[j];
if (random <= sum) {
results.push(colors[j]);
break;
}
}
}
return results;
}
function displayResults(frequency, percentage, streaks, simulation) {
// Display frequency stats
const frequencyStats = document.getElementById('frequency-stats');
frequencyStats.innerHTML = '';
for (const color in frequency) {
const statDiv = document.createElement('div');
statDiv.className = 'flex justify-between items-center p-3 rounded-md';
statDiv.classList.add(`color-${color}`);
const colorName = color.charAt(0).toUpperCase() + color.slice(1);
const statText = document.createElement('span');
statText.className = 'font-medium';
statText.textContent = `${colorName}: `;
const statValue = document.createElement('span');
statValue.className = 'font-bold';
statValue.textContent = `${frequency[color]} times (${percentage[color]}%)`;
statDiv.appendChild(statText);
statDiv.appendChild(statValue);
frequencyStats.appendChild(statDiv);
}
// Display chart
const ctx = document.getElementById('frequency-chart').getContext('2d');
if (window.frequencyChart) {
window.frequencyChart.destroy();
}
const colors = Object.keys(frequency);
const backgroundColors = colors.map(color => {
if (color === 'white') return '#f8f9fa';
if (color === 'black') return '#212529';
if (color === 'red') return '#dc3545';
return '#6c757d';
});
window.frequencyChart = new Chart(ctx, {
type: 'pie',
data: {
labels: colors.map(color => color.charAt(0).toUpperCase() + color.slice(1)),
datasets: [{
data: Object.values(frequency),
backgroundColor: backgroundColors,
borderWidth: 1
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'bottom',
}
}
}
});
// Display streaks
const streaksResults = document.getElementById('streaks-results');
streaksResults.innerHTML = '';
const streakCounts = {};
streaks.forEach(streak => {
if (streak.length > 1) {
streakCounts[streak.color] = (streakCounts[streak.color] || 0) + 1;
}
});
for (const color in streakCounts) {
const streakDiv = document.createElement('div');
streakDiv.className = 'flex items-center p-3 rounded-md';
streakDiv.classList.add(`color-${color}`);
const colorName = color.charAt(0).toUpperCase() + color.slice(1);
const streakText = document.createElement('span');
streakText.className = 'font-medium';
streakText.textContent = `${colorName} streaks: ${streakCounts[color]} time(s)`;
streakDiv.appendChild(streakText);
streaksResults.appendChild(streakDiv);
}
if (Object.keys(streakCounts).length === 0) {
streaksResults.innerHTML = '<p class="text-gray-600">No streaks found in the history.</p>';
}
// Display simulation
const simulationResults = document.getElementById('simulation-results');
simulationResults.innerHTML = '';
const simFrequency = {};
simulation.forEach(color => {
simFrequency[color] = (simFrequency[color] || 0) + 1;
const dot = document.createElement('span');
dot.className = `simulation-dot color-${color}`;
dot.title = color.charAt(0).toUpperCase() + color.slice(1);
simulationResults.appendChild(dot);
});
const simulationStats = document.getElementById('simulation-stats');
simulationStats.innerHTML = '';
for (const color in simFrequency) {
const statDiv = document.createElement('div');
statDiv.className = 'mb-1';
const colorName = color.charAt(0).toUpperCase() + color.slice(1);
const statText = document.createElement('span');
statText.className = 'font-medium';
statText.textContent = `${colorName}: ${simFrequency[color]} time(s)`;
statDiv.appendChild(statText);
simulationStats.appendChild(statDiv);
}
// Refresh icons
feather.replace();
}
</script>
</body>
</html>