"use client"; import { useState } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { gameData } from "@/lib/game-data"; import { Grid3X3, Target } from "lucide-react"; interface HoveredCell { word1: string; word2: string; distance: number; } export function ScoreMatrixVisualization() { const [hoveredCell, setHoveredCell] = useState(null); const { words, distances, finalScore } = gameData.finalMatrix; const getColorIntensity = (distance: number) => { const maxDistance = Math.max(...distances.flat()); const minDistance = Math.min(...distances.flat().filter(d => d > 0)); const normalizedDistance = (distance - minDistance) / (maxDistance - minDistance); if (distance === 0) return "bg-gray-200"; const intensity = Math.floor(normalizedDistance * 4) + 1; return `bg-green-${intensity * 100} hover:bg-green-${Math.min(intensity * 100 + 100, 900)}`; }; const getCellClasses = (distance: number) => { if (distance === 0) { return "bg-gray-200 text-gray-500"; } const maxDistance = Math.max(...distances.flat()); const intensity = distance / maxDistance; if (intensity > 0.8) return "bg-green-500 text-white hover:bg-green-600"; if (intensity > 0.6) return "bg-green-400 text-white hover:bg-green-500"; if (intensity > 0.4) return "bg-green-300 text-gray-900 hover:bg-green-400"; if (intensity > 0.2) return "bg-green-200 text-gray-900 hover:bg-green-300"; return "bg-green-100 text-gray-900 hover:bg-green-200"; }; return ( Semantic Distance Matrix

Interactive matrix showing semantic distances between final word pairs

Score: {finalScore}
{words.map((word, index) => ( ))} {words.map((rowWord, rowIndex) => ( {words.map((colWord, colIndex) => { const distance = distances[rowIndex][colIndex]; return ( ); })} ))}
{word}
{rowWord}
setHoveredCell({ word1: rowWord, word2: colWord, distance })} onMouseLeave={() => setHoveredCell(null)} >
{distance}
{hoveredCell && (
{hoveredCell.word1} ↔ {hoveredCell.word2} Distance: {hoveredCell.distance}

{hoveredCell.distance === 0 ? "Same word (diagonal)" : `Higher values indicate more semantically distant concepts` }

)}
Low distance
Medium distance
High distance
Matrix is symmetric

Matrix Analysis

Average Distance:
{(distances.flat().filter(d => d > 0).reduce((a, b) => a + b, 0) / distances.flat().filter(d => d > 0).length).toFixed(1)}
Highest Distance:
{Math.max(...distances.flat())}
Lowest Distance:
{Math.min(...distances.flat().filter(d => d > 0))}
); }