11// Main application JavaScript for BalatroBench
22
33// Global state
4- const currentVersion = 'v0.4 .0' ;
4+ const currentVersion = 'v0.6 .0' ;
55const currentStrategy = 'default' ;
66
77// Initialize the app when DOM is loaded
@@ -197,15 +197,15 @@ function renderIndividualRunsDetailTable(runs) {
197197 ${ runs . map ( ( run , runIndex ) => {
198198 const totalToolCalls = run . successful_calls + ( run . error_calls ?. length || 0 ) + ( run . failed_calls ?. length || 0 ) ;
199199 const totalTokens = run . total_input_tokens + run . total_output_tokens ;
200-
200+
201201 return `
202202 <tr class="hover:bg-gray-500 transition-colors">
203203 <td class="px-2 py-3 text-center">
204204 <span class="text-xs sm:text-sm font-bold text-white">#${ runIndex + 1 } </span>
205205 </td>
206206 <td class="px-2 py-3 text-center">
207- ${ run . completed ?
208- '<span class="text-green-400 text-lg">✓</span>' :
207+ ${ run . completed ?
208+ '<span class="text-green-400 text-lg">✓</span>' :
209209 '<span class="text-red-400 text-lg">✗</span>'
210210 }
211211 </td>
@@ -290,7 +290,7 @@ function renderModelDetails(modelData) {
290290 </div>
291291 </div>
292292 </div>
293-
293+
294294 <!-- Average Stats Card -->
295295 <div class="bg-gray-700 rounded-lg p-4 mb-4">
296296 <h4 class="font-semibold text-white mb-3 text-lg">Average Statistics</h4>
@@ -357,14 +357,22 @@ function renderModelDetails(modelData) {
357357 </div>
358358 </div>
359359 </div>
360-
360+
361361 <!-- Individual Runs Table -->
362- <div class="bg-gray-700 rounded-lg p-4">
362+ <div class="bg-gray-700 rounded-lg p-4 mb-4 ">
363363 <h4 class="font-semibold text-white mb-3 text-lg">Individual Runs</h4>
364364 <div class="overflow-x-auto">
365365 ${ renderIndividualRunsDetailTable ( runs ) }
366366 </div>
367367 </div>
368+
369+ <!-- Final Round Distribution Chart -->
370+ <div class="bg-gray-700 rounded-lg p-4">
371+ <h4 class="font-semibold text-white mb-3 text-lg">Final Round Distribution</h4>
372+ <div class="h-64">
373+ <canvas id="finalRoundChart-${ modelData . config . model . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, '-' ) } "></canvas>
374+ </div>
375+ </div>
368376 </div>
369377 ` ;
370378}
@@ -463,6 +471,11 @@ async function loadModelDetails(modelPath, index) {
463471 // Render detailed view
464472 statsRow . querySelector ( 'td' ) . innerHTML = renderModelDetails ( modelData ) ;
465473
474+ // Create final round distribution chart after DOM is updated
475+ setTimeout ( ( ) => {
476+ createFinalRoundDistributionChart ( modelData ) ;
477+ } , 100 ) ;
478+
466479 } catch ( error ) {
467480 console . error ( 'Error loading model details:' , error ) ;
468481 statsRow . querySelector ( 'td' ) . innerHTML =
@@ -544,7 +557,7 @@ async function loadCommunityStrategies() {
544557 </div>
545558 <p class="text-gray-300 mb-4">${ strategy . description } </p>
546559 <div class="flex flex-wrap gap-2 mb-4">
547- ${ strategy . tags ? strategy . tags . map ( tag =>
560+ ${ strategy . tags ? strategy . tags . map ( tag =>
548561 `<span class="bg-gray-700 text-gray-300 px-2 py-1 rounded text-xs">${ tag } </span>`
549562 ) . join ( '' ) : '' }
550563 </div>
@@ -594,6 +607,81 @@ function tryStrategy(title) {
594607 `Trying strategy: ${ title } \n\nThis would redirect to a page where you can test the strategy.` ) ;
595608}
596609
610+ // Create final round distribution chart
611+ function createFinalRoundDistributionChart ( modelData ) {
612+ const chartId = `finalRoundChart-${ modelData . config . model . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, '-' ) } ` ;
613+ const canvas = document . getElementById ( chartId ) ;
614+
615+ if ( ! canvas ) return ;
616+
617+ // Extract final round data from all runs
618+ const finalRounds = modelData . stats . map ( run => run . final_round ) ;
619+
620+ // Create frequency distribution
621+ const roundCounts = { } ;
622+ finalRounds . forEach ( round => {
623+ roundCounts [ round ] = ( roundCounts [ round ] || 0 ) + 1 ;
624+ } ) ;
625+
626+ // Prepare data for Chart.js
627+ const rounds = Object . keys ( roundCounts ) . map ( Number ) . sort ( ( a , b ) => a - b ) ;
628+ const counts = rounds . map ( round => roundCounts [ round ] ) ;
629+
630+ const ctx = canvas . getContext ( '2d' ) ;
631+ new Chart ( ctx , {
632+ type : 'bar' ,
633+ data : {
634+ labels : rounds . map ( r => `Round ${ r } ` ) ,
635+ datasets : [ {
636+ label : 'Number of Runs' ,
637+ data : counts ,
638+ backgroundColor : 'rgba(59, 130, 246, 0.8)' ,
639+ borderColor : 'rgba(59, 130, 246, 1)' ,
640+ borderWidth : 1
641+ } ]
642+ } ,
643+ options : {
644+ responsive : true ,
645+ maintainAspectRatio : false ,
646+ plugins : {
647+ legend : {
648+ display : false
649+ }
650+ } ,
651+ scales : {
652+ y : {
653+ beginAtZero : true ,
654+ ticks : {
655+ stepSize : 1 ,
656+ color : '#9CA3AF'
657+ } ,
658+ grid : {
659+ color : 'rgba(156, 163, 175, 0.2)'
660+ } ,
661+ title : {
662+ display : true ,
663+ text : 'Number of Runs' ,
664+ color : '#9CA3AF'
665+ }
666+ } ,
667+ x : {
668+ ticks : {
669+ color : '#9CA3AF'
670+ } ,
671+ grid : {
672+ color : 'rgba(156, 163, 175, 0.2)'
673+ } ,
674+ title : {
675+ display : true ,
676+ text : 'Final Round' ,
677+ color : '#9CA3AF'
678+ }
679+ }
680+ }
681+ }
682+ } ) ;
683+ }
684+
597685// Export functions for global access
598686window . BalatroBench = {
599687 loadLeaderboard,
@@ -603,5 +691,6 @@ window.BalatroBench = {
603691 tryStrategy,
604692 loadModelDetails,
605693 toggleRunDetails,
606- initializeLeaderboard
694+ initializeLeaderboard,
695+ createFinalRoundDistributionChart
607696} ;
0 commit comments