@@ -851,6 +851,208 @@ function transitionSignalEntries(configuration, limit = 6) {
851851 } ) ) ;
852852}
853853
854+ // Univers vivant browser mirror.
855+ //
856+ // Canonical source lives in src/automate_universel.multi:
857+ // - valeur_semantique
858+ // - resumer_univers_vivant
859+ // - construire_univers_vivant
860+ // - source_univers_vivant
861+ //
862+ // This JS block exists only because the static browser app still needs a rich
863+ // JSON/list/dictionary bridge until the Multilingual runtime can expose the
864+ // full core directly in the browser.
865+ function symbolToSemanticValue ( symbol , alphabet ) {
866+ const index = alphabet . findIndex ( ( candidate ) => String ( candidate ) === String ( symbol ) ) ;
867+ return {
868+ symbol,
869+ index : index >= 0 ? index : null ,
870+ } ;
871+ }
872+
873+ function canonicalRuleEntries ( configuration ) {
874+ const config = normaliserConfiguration ( configuration ) ;
875+ const keys = toutesClesVoisinage ( config . alphabet_entree , config . taille_voisinage ) ;
876+ if ( config . mode_regle === "table" ) {
877+ return keys . map ( ( key ) => {
878+ const voisinage = JSON . parse ( key ) ;
879+ return {
880+ neighborhood : voisinage . map ( ( value ) => symbolToSemanticValue ( value , config . alphabet_entree ) ) ,
881+ output : normaliserSortie (
882+ config . table_transition [ key ] ?? config . table_transition [ ancienneCleVoisinage ( voisinage ) ] ?? sortieDefaut ( config ) ,
883+ config ,
884+ ) . map ( ( value ) => symbolToSemanticValue ( value , config . alphabet_sortie ) ) ,
885+ } ;
886+ } ) ;
887+ }
888+ if ( config . mode_regle === "totalistique" ) {
889+ return keys . map ( ( key ) => {
890+ const voisinage = JSON . parse ( key ) ;
891+ return {
892+ neighborhood : voisinage . map ( ( value ) => symbolToSemanticValue ( value , config . alphabet_entree ) ) ,
893+ output : transition_totalistique_compatible ( voisinage , config ) . map ( ( value ) => symbolToSemanticValue ( value , config . alphabet_sortie ) ) ,
894+ } ;
895+ } ) ;
896+ }
897+ return [ ] ;
898+ }
899+
900+ function transition_totalistique_compatible ( voisinage , configuration ) {
901+ const sum = voisinage . reduce ( ( acc , value ) => acc + Number ( value ) , 0 ) ;
902+ const baseIndex = Number . isFinite ( sum )
903+ ? ( ( Math . trunc ( sum ) % configuration . alphabet_sortie . length ) + configuration . alphabet_sortie . length ) % configuration . alphabet_sortie . length
904+ : voisinage . length % configuration . alphabet_sortie . length ;
905+ return Array . from (
906+ { length : configuration . nombre_canaux_sortie } ,
907+ ( _ , channel ) => configuration . alphabet_sortie [ ( baseIndex + channel ) % configuration . alphabet_sortie . length ] ,
908+ ) ;
909+ }
910+
911+ function initialLociForSemanticCore ( configuration ) {
912+ const config = normaliserConfiguration ( configuration ) ;
913+ const ligne = creerGenerationInitiale ( config ) ;
914+ return ligne . map ( ( value , x ) => ( {
915+ id : `cell_${ x } ` ,
916+ locus : [ x , 0 ] ,
917+ state : symbolToSemanticValue ( value , config . alphabet_entree ) ,
918+ } ) ) ;
919+ }
920+
921+ function semanticCoreTier ( configuration ) {
922+ const config = normaliserConfiguration ( configuration ) ;
923+ if ( config . mode_regle === "aleatoire" ) return 3 ;
924+ if ( config . mode_regle === "numerique" ) return 2 ;
925+ if ( config . taille_voisinage > 3 || config . alphabet_entree . length > 2 || config . nombre_canaux_sortie > 1 ) return 2 ;
926+ return 1 ;
927+ }
928+
929+ function semanticCoreTierName ( tier ) {
930+ return [
931+ "static" ,
932+ "elementary rewrite" ,
933+ "finite-state rewrite" ,
934+ "stochastic rewrite" ,
935+ "open-ended process" ,
936+ ] [ tier ] || "process" ;
937+ }
938+
939+ function semanticCoreSummary ( configuration ) {
940+ if ( window . AutomaginariumUniversVivant ?. resumer_univers_vivant ) {
941+ return window . AutomaginariumUniversVivant . resumer_univers_vivant ( configuration ) ;
942+ }
943+ const config = normaliserConfiguration ( configuration ) ;
944+ const tier = semanticCoreTier ( config ) ;
945+ return {
946+ profile : "automaginarium-1d-ca-v1" ,
947+ tier,
948+ tier_name : semanticCoreTierName ( tier ) ,
949+ topology : `${ config . largeur } x1 ${ config . frontiere === "circulaire" ? "wrapped" : "bounded" } lattice` ,
950+ schedule : `${ Math . max ( 0 , config . hauteur - 1 ) } synchronous step(s)` ,
951+ rule : `${ config . mode_regle } / neighborhood ${ config . taille_voisinage } / ${ config . nombre_canaux_sortie } channel(s)` ,
952+ } ;
953+ }
954+
955+ function buildSemanticCoreV1 ( configurationBrute ) {
956+ if ( window . AutomaginariumUniversVivant ?. construire_univers_vivant ) {
957+ return window . AutomaginariumUniversVivant . construire_univers_vivant ( configurationBrute ) ;
958+ }
959+ const config = normaliserConfiguration ( configurationBrute ) ;
960+ const summary = semanticCoreSummary ( config ) ;
961+ const tableEntries = canonicalRuleEntries ( config ) ;
962+ return {
963+ kind : "semantic-core-v1" ,
964+ profile : summary . profile ,
965+ name : config . nom ,
966+ metadata : {
967+ generator : "Automaginarium" ,
968+ profile : summary . profile ,
969+ tier : summary . tier ,
970+ tier_name : summary . tier_name ,
971+ notes : "Automaginarium 1D cellular-automaton profile for Multilingual 0.8 process tooling." ,
972+ } ,
973+ state : {
974+ population : "fixed" ,
975+ empty : {
976+ state : symbolToSemanticValue ( config . alphabet_entree [ 0 ] , config . alphabet_entree ) ,
977+ } ,
978+ alphabet : {
979+ input : config . alphabet_entree . map ( ( value ) => symbolToSemanticValue ( value , config . alphabet_entree ) ) ,
980+ output : config . alphabet_sortie . map ( ( value ) => symbolToSemanticValue ( value , config . alphabet_sortie ) ) ,
981+ } ,
982+ loci : initialLociForSemanticCore ( config ) ,
983+ } ,
984+ topology : {
985+ kind : "lattice" ,
986+ dimensionality : 1 ,
987+ width : config . largeur ,
988+ height : 1 ,
989+ wrap : config . frontiere === "circulaire" ,
990+ neighborhood : "automaginarium-1d" ,
991+ radius : Math . floor ( config . taille_voisinage / 2 ) ,
992+ boundary_value : symbolToSemanticValue ( config . valeur_frontiere , config . alphabet_entree ) ,
993+ } ,
994+ rule : {
995+ kind : "automaginarium-transition" ,
996+ mode : config . mode_regle ,
997+ neighborhood_size : config . taille_voisinage ,
998+ output_channels : config . nombre_canaux_sortie ,
999+ numeric_rule : config . numero_regle !== undefined ? String ( config . numero_regle ) : undefined ,
1000+ table : tableEntries ,
1001+ } ,
1002+ schedule : {
1003+ kind : "synchronous" ,
1004+ steps : Math . max ( 0 , config . hauteur - 1 ) ,
1005+ projection : "rows-as-time" ,
1006+ } ,
1007+ rendering : {
1008+ cell_size : config . rendu ?. taille_cellule || 5 ,
1009+ palette : config . rendu ?. palette || null ,
1010+ gradient : config . rendu ?. gradient || null ,
1011+ } ,
1012+ source_configuration : {
1013+ ...config ,
1014+ numero_regle : config . numero_regle !== undefined ? String ( config . numero_regle ) : undefined ,
1015+ } ,
1016+ } ;
1017+ }
1018+
1019+ function semanticCoreSource ( configurationBrute ) {
1020+ if ( window . AutomaginariumUniversVivant ?. source_univers_vivant ) {
1021+ return window . AutomaginariumUniversVivant . source_univers_vivant ( configurationBrute ) ;
1022+ }
1023+ const config = normaliserConfiguration ( configurationBrute ) ;
1024+ const tableName = `${ String ( config . nom || "univers" ) . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 ] + / g, "_" ) . replace ( / ^ _ | _ $ / g, "" ) || "univers" } _rule` ;
1025+ return [
1026+ "# Automaginarium semantic-core-v1 profile source" ,
1027+ "# Generated from the active Automaginarium configuration." ,
1028+ "" ,
1029+ `let width = ${ config . largeur } ` ,
1030+ `let steps = ${ Math . max ( 0 , config . hauteur - 1 ) } ` ,
1031+ `let alphabet_input = ${ JSON . stringify ( config . alphabet_entree ) } ` ,
1032+ `let alphabet_output = ${ JSON . stringify ( config . alphabet_sortie ) } ` ,
1033+ `let initial_loci = ${ JSON . stringify ( initialLociForSemanticCore ( config ) ) } ` ,
1034+ "" ,
1035+ `def ${ tableName } ():` ,
1036+ ` return automaginarium_transition(${ JSON . stringify ( {
1037+ mode : config . mode_regle ,
1038+ neighborhood_size : config . taille_voisinage ,
1039+ output_channels : config . nombre_canaux_sortie ,
1040+ table : canonicalRuleEntries ( config ) ,
1041+ } ) } )`,
1042+ "" ,
1043+ "let process = build_process_core(" ,
1044+ " {\"loci\": initial_loci, \"population\": \"fixed\"}," ,
1045+ ` lattice_topology(width, 1, ${ config . frontiere === "circulaire" ? "True" : "False" } , "automaginarium-1d"),` ,
1046+ ` ${ tableName } (),` ,
1047+ " synchronous_schedule()" ,
1048+ ")" ,
1049+ ] . join ( "\n" ) ;
1050+ }
1051+
1052+ const resumerUniversVivant = semanticCoreSummary ;
1053+ const construireUniversVivant = buildSemanticCoreV1 ;
1054+ const sourceUniversVivant = semanticCoreSource ;
1055+
8541056function ruleSpaceLabel ( configuration ) {
8551057 const { s, k, t, m, maxRule } = ruleConfiguration ( configuration ) ;
8561058 return `${ t } ^(${ m } ·${ s } ^${ k } ) = ${ maxRule } regles possibles` ;
@@ -921,6 +1123,12 @@ window.AutomaginariumCore = {
9211123 ruleSpaceLabel,
9221124 summarizeConfig,
9231125 summarizeTransition,
1126+ semanticCoreSummary,
1127+ buildSemanticCoreV1,
1128+ semanticCoreSource,
1129+ resumerUniversVivant,
1130+ construireUniversVivant,
1131+ sourceUniversVivant,
9241132 universeHudMetrics,
9251133 randomRuleNumber,
9261134 cleVoisinage,
0 commit comments