diff --git a/cryptide_project/Script/LatexScript.tsx b/cryptide_project/Script/LatexScript.tsx index e0e6479..aed90de 100644 --- a/cryptide_project/Script/LatexScript.tsx +++ b/cryptide_project/Script/LatexScript.tsx @@ -8,10 +8,11 @@ import Stub from "../src/model/Stub"; import GameCreator from "../src/model/GameCreator"; import Indice from "../src/model/Indices/Indice"; import { SportToString } from "../src/model/EnumExtender"; +import GraphCreator from "../src/model/Graph/GraphCreator"; +import { DataSet, Network } from "vis-network"; function generateLatexCode(personsNet : PersonNetwork, choosenPerson : Person, choosenIndices : Indice[]) { let latexCode = ""; - //*Setup @@ -23,11 +24,6 @@ function generateLatexCode(personsNet : PersonNetwork, choosenPerson : Person, c latexCode += "\\usetikzlibrary {shapes.multipart}\n" - - //! A quoi sert "fille" ? - // latexCode += "%\\newcommand{\\fille}[1]{\\underline{#1}}" - // latexCode += "\\newcommand{\\fille}[1]{#1} % Solution" - latexCode += "\\newcommand{\\Basketball}{\\includegraphics[width=.5cm]{ballon-de-basket.png}}\n" latexCode += "\\newcommand{\\Football}{\\includegraphics[width=.4cm]{ballon-de-foot.png}}\n" latexCode += "\\newcommand{\\Bowling}{\\includegraphics[width=.5cm]{bowling.png}}\n" @@ -43,16 +39,81 @@ function generateLatexCode(personsNet : PersonNetwork, choosenPerson : Person, c latexCode+= "\\begin{tikzpicture}[scale=.9]\n" - + //? Coordonnée en position. + //! marche pas + // const graph = GraphCreator.CreateGraph(personsNet) + + // const container = document.getElementById('graph-container'); + // if (!container) { + // console.error("Container not found"); + // return; + // } + // // Charger les données dans le graph + // const nodes = new DataSet(graph.nodesPerson); + + // // Configuration des options du Graphe + // const initialOptions = { + // layout: { + // improvedLayout: true, + // hierarchical: { + // enabled: false, + // direction: 'LR', // LR (Left to Right) ou autre selon votre préférence + // sortMethod: 'hubsize' + // } + // }, + // physics: { + // enabled: true, + // barnesHut: { + // gravitationalConstant: -1000, + // springConstant: 0.001, + // springLength: 100 + // } + // } + // }; + + // const networkData = { nodes: nodes, edges: graph.edges }; + // const network = new Network(container, networkData, initialOptions); + + personsNet.getPersons().forEach((person, index) => { + + // //? Coordonnée en forme de grille. const xCoordinate = index % 5; const yCoordinate = Math.floor(index / 5); + const scaledX = xCoordinate * 4; + const scaledY = yCoordinate * 4; + + latexCode += ` \\node[draw, circle split] (${person.getId()}) at (${scaledX},${scaledY}) { ${person.getName()} \\nodepart{lower}`; - const scaledX = xCoordinate * 2; - const scaledY = yCoordinate * 2; - latexCode += ` \\node[draw, circle split] (${person.getId()}) at (${scaledX},${scaledY}) { ${person.getName()} \\nodepart{lower}`; + + //? Coordonnée en position. + //! marche pas + // var nodesData = network.getPositions(); + // // for (var nodeId in nodesData) { + // // if (nodesData.hasOwnProperty(nodeId)) { + // // var position = nodesData[nodeId]; + // // console.log("Nœud " + nodeId + " - Position : x = " + position.x + ", y = " + position.y); + // // } + // // } + // // latexCode += ` \\node[draw, circle split] (${person.getId()}) at (${x},${y}) { ${person.getName()} \\nodepart{lower}`; //x et y de la position + + // // Obtenir les coordonnées du nœud + // const nodeId = person.getId().toString(); + // const position = nodesData[nodeId]; + // if (position) { + // const x = position.x.toFixed(2); // Arrondir à 2 décimales + // const y = position.y.toFixed(2); + + // latexCode += ` \\node[draw, circle split] (${person.getId()}) at (${x},${y}) { ${person.getName()} \\nodepart{lower}`; + + // person.getSports().forEach((sport) => { latexCode += ` \\${SportToString(sport, 'fr')}{}` }); + // latexCode += "};\n"; + // } else { + // console.error(`Les coordonnées du nœud ${nodeId} ne sont pas disponibles.`); + // } + person.getSports().forEach((sport) => { latexCode += ` \\${SportToString(sport, 'fr')}{}`}) latexCode += "};\n"; @@ -68,6 +129,7 @@ function generateLatexCode(personsNet : PersonNetwork, choosenPerson : Person, c latexCode += "\\end{tikzpicture}\n"; latexCode += "\\end{center}\n"; + //* Zone d'énoncé : latexCode += "\n\n\\paragraph{Première énigme}\n" @@ -96,5 +158,10 @@ const latexCode = generateLatexCode(networkPerson, choosenPerson, choosenIndices const filePath = './graph.tex'; -fs.writeFileSync(filePath, latexCode, 'utf-8'); +if (typeof latexCode === 'undefined') { + console.log('Variable is undefined'); +} +else{ + fs.writeFileSync(filePath, latexCode, 'utf-8'); +} console.log(`Le code LaTeX a été enregistré dans le fichier : ${filePath}`); diff --git a/graph.aux b/graph.aux index c62d3f9..cde4834 100644 --- a/graph.aux +++ b/graph.aux @@ -1,3 +1,3 @@ \relax -\@writefile{toc}{\contentsline {paragraph}{Première énigme}{1}{}\protected@file@percent } -\gdef \@abspage@last{1} +\@writefile{toc}{\contentsline {paragraph}{Première énigme}{2}{}\protected@file@percent } +\gdef \@abspage@last{2} diff --git a/graph.pdf b/graph.pdf index 6eec8b5..242fe3b 100644 Binary files a/graph.pdf and b/graph.pdf differ diff --git a/graph.tex b/graph.tex index 929d91a..eaa16b7 100644 --- a/graph.tex +++ b/graph.tex @@ -14,110 +14,108 @@ Voici le graphe de SocialGraphe \begin{center} \begin{tikzpicture}[scale=.9] - \node[draw, circle split] (0) at (0,0) { Aaliyah \nodepart{lower} \Football{}}; - \node[draw, circle split] (1) at (2,0) { Evelyn \nodepart{lower} \Baseball{} \Bowling{}}; - \node[draw, circle split] (2) at (4,0) { Sebastian \nodepart{lower} \Tennis{} \Basketball{}}; - \node[draw, circle split] (3) at (6,0) { Emily \nodepart{lower} \Bowling{} \Tennis{}}; - \node[draw, circle split] (4) at (8,0) { Stella \nodepart{lower} \Baseball{} \Football{}}; - \node[draw, circle split] (5) at (0,2) { Sadie \nodepart{lower} \Basketball{} \Tennis{}}; - \node[draw, circle split] (6) at (2,2) { Savannah \nodepart{lower} \Baseball{} \Bowling{}}; - \node[draw, circle split] (7) at (4,2) { Ivy \nodepart{lower} \Basketball{} \Football{}}; - \node[draw, circle split] (8) at (6,2) { Olivia \nodepart{lower} \Basketball{}}; - \node[draw, circle split] (9) at (8,2) { Nora \nodepart{lower} \Baseball{} \Tennis{} \Bowling{}}; - \node[draw, circle split] (10) at (0,4) { Peyton \nodepart{lower} \Football{} \Bowling{}}; - \node[draw, circle split] (11) at (2,4) { Zoe \nodepart{lower} \Football{} \Baseball{}}; - \node[draw, circle split] (12) at (4,4) { Mason \nodepart{lower} \Tennis{}}; - \node[draw, circle split] (13) at (6,4) { Layla \nodepart{lower} \Basketball{} \Tennis{}}; - \node[draw, circle split] (14) at (8,4) { Chloe \nodepart{lower} \Baseball{} \Football{} \Basketball{}}; - \node[draw, circle split] (15) at (0,6) { Mia \nodepart{lower} \Bowling{}}; - \node[draw, circle split] (16) at (2,6) { Daniel \nodepart{lower} \Football{}}; - \node[draw, circle split] (17) at (4,6) { Charlotte \nodepart{lower} \Tennis{} \Basketball{}}; - \node[draw, circle split] (18) at (6,6) { Connor \nodepart{lower} \Baseball{} \Bowling{} \Tennis{}}; - \node[draw, circle split] (19) at (8,6) { Elijah \nodepart{lower} \Bowling{} \Football{}}; - \node[draw, circle split] (20) at (0,8) { Luke \nodepart{lower} \Baseball{}}; - \node[draw, circle split] (21) at (2,8) { Michael \nodepart{lower} \Basketball{} \Football{}}; - \node[draw, circle split] (22) at (4,8) { Aurora \nodepart{lower} \Basketball{} \Bowling{} \Baseball{}}; - \node[draw, circle split] (23) at (6,8) { Carter \nodepart{lower} \Tennis{}}; - \node[draw, circle split] (24) at (8,8) { James \nodepart{lower} \Bowling{} \Tennis{} \Basketball{}}; - \node[draw, circle split] (25) at (0,10) { Joshua \nodepart{lower} \Football{} \Baseball{}}; - \node[draw, circle split] (26) at (2,10) { Owen \nodepart{lower} \Football{}}; - \node[draw, circle split] (27) at (4,10) { Joseph \nodepart{lower} \Basketball{} \Baseball{}}; - \node[draw, circle split] (28) at (6,10) { Oliver \nodepart{lower} \Bowling{} \Tennis{}}; - \node[draw, circle split] (29) at (8,10) { Hazel \nodepart{lower} \Tennis{} \Basketball{}}; - \draw (0) -- (29); - \draw (0) -- (26); - \draw (1) -- (23); - \draw (2) -- (27); - \draw (2) -- (26); - \draw (3) -- (28); - \draw (3) -- (11); - \draw (3) -- (18); - \draw (3) -- (22); - \draw (4) -- (18); - \draw (4) -- (21); - \draw (4) -- (17); - \draw (4) -- (10); - \draw (5) -- (19); - \draw (6) -- (19); - \draw (7) -- (29); - \draw (7) -- (23); - \draw (7) -- (15); - \draw (8) -- (21); - \draw (8) -- (22); + \node[draw, circle split] (0) at (0,0) { Alexander \nodepart{lower} \Football{} \Bowling{}}; + \node[draw, circle split] (1) at (4,0) { Wyatt \nodepart{lower} \Baseball{} \Tennis{}}; + \node[draw, circle split] (2) at (8,0) { Mia \nodepart{lower} \Basketball{}}; + \node[draw, circle split] (3) at (12,0) { William \nodepart{lower} \Baseball{} \Football{}}; + \node[draw, circle split] (4) at (16,0) { Zoey \nodepart{lower} \Basketball{} \Bowling{} \Tennis{}}; + \node[draw, circle split] (5) at (0,4) { Isabella \nodepart{lower} \Tennis{}}; + \node[draw, circle split] (6) at (4,4) { Abigail \nodepart{lower} \Baseball{}}; + \node[draw, circle split] (7) at (8,4) { Savannah \nodepart{lower} \Bowling{} \Basketball{} \Football{}}; + \node[draw, circle split] (8) at (12,4) { Peyton \nodepart{lower} \Football{}}; + \node[draw, circle split] (9) at (16,4) { Alice \nodepart{lower} \Tennis{} \Baseball{}}; + \node[draw, circle split] (10) at (0,8) { Sophia \nodepart{lower} \Bowling{} \Basketball{} \Bowling{}}; + \node[draw, circle split] (11) at (4,8) { Layla \nodepart{lower} \Tennis{} \Baseball{} \Football{}}; + \node[draw, circle split] (12) at (8,8) { Ava \nodepart{lower} \Basketball{}}; + \node[draw, circle split] (13) at (12,8) { Harper \nodepart{lower} \Bowling{}}; + \node[draw, circle split] (14) at (16,8) { Sebastian \nodepart{lower} \Tennis{} \Basketball{} \Baseball{}}; + \node[draw, circle split] (15) at (0,12) { Michael \nodepart{lower} \Football{}}; + \node[draw, circle split] (16) at (4,12) { Natalie \nodepart{lower} \Bowling{} \Football{} \Baseball{}}; + \node[draw, circle split] (17) at (8,12) { Penelope \nodepart{lower} \Basketball{}}; + \node[draw, circle split] (18) at (12,12) { Lily \nodepart{lower} \Tennis{} \Tennis{}}; + \node[draw, circle split] (19) at (16,12) { Eleanor \nodepart{lower} \Football{}}; + \node[draw, circle split] (20) at (0,16) { Henry \nodepart{lower} \Bowling{} \Basketball{}}; + \node[draw, circle split] (21) at (4,16) { Claire \nodepart{lower} \Baseball{} \Basketball{}}; + \node[draw, circle split] (22) at (8,16) { Caleb \nodepart{lower} \Baseball{}}; + \node[draw, circle split] (23) at (12,16) { Charlotte \nodepart{lower} \Bowling{} \Football{} \Tennis{}}; + \node[draw, circle split] (24) at (16,16) { Luke \nodepart{lower} \Football{}}; + \node[draw, circle split] (25) at (0,20) { Connor \nodepart{lower} \Baseball{} \Tennis{}}; + \node[draw, circle split] (26) at (4,20) { Aiden \nodepart{lower} \Basketball{} \Bowling{} \Tennis{}}; + \node[draw, circle split] (27) at (8,20) { Aurora \nodepart{lower} \Football{}}; + \node[draw, circle split] (28) at (12,20) { Nathan \nodepart{lower} \Bowling{} \Baseball{}}; + \node[draw, circle split] (29) at (16,20) { Aurora \nodepart{lower} \Basketball{}}; + \draw (0) -- (11); + \draw (0) -- (13); + \draw (0) -- (18); + \draw (1) -- (13); + \draw (1) -- (24); + \draw (2) -- (22); + \draw (2) -- (16); + \draw (2) -- (9); + \draw (2) -- (6); + \draw (3) -- (4); + \draw (3) -- (20); + \draw (4) -- (28); + \draw (4) -- (3); + \draw (5) -- (17); + \draw (5) -- (15); + \draw (5) -- (24); + \draw (6) -- (2); + \draw (7) -- (17); + \draw (7) -- (24); + \draw (7) -- (22); + \draw (7) -- (11); \draw (8) -- (25); - \draw (8) -- (20); - \draw (9) -- (29); - \draw (9) -- (20); - \draw (10) -- (4); - \draw (10) -- (24); - \draw (11) -- (3); - \draw (12) -- (19); - \draw (12) -- (21); + \draw (8) -- (21); + \draw (8) -- (24); + \draw (8) -- (11); + \draw (9) -- (2); + \draw (10) -- (25); + \draw (10) -- (26); + \draw (10) -- (27); + \draw (11) -- (0); + \draw (11) -- (7); + \draw (11) -- (8); \draw (12) -- (20); - \draw (12) -- (22); - \draw (13) -- (25); - \draw (13) -- (16); - \draw (13) -- (23); - \draw (14) -- (25); - \draw (14) -- (21); - \draw (14) -- (16); - \draw (14) -- (22); - \draw (15) -- (7); - \draw (15) -- (25); - \draw (16) -- (13); - \draw (16) -- (14); - \draw (17) -- (4); - \draw (18) -- (3); - \draw (18) -- (4); - \draw (19) -- (5); - \draw (19) -- (6); - \draw (19) -- (12); - \draw (20) -- (8); - \draw (20) -- (9); + \draw (12) -- (27); + \draw (13) -- (0); + \draw (13) -- (1); + \draw (14) -- (15); + \draw (15) -- (5); + \draw (15) -- (14); + \draw (15) -- (20); + \draw (15) -- (17); + \draw (16) -- (2); + \draw (16) -- (26); + \draw (17) -- (5); + \draw (17) -- (7); + \draw (17) -- (15); + \draw (17) -- (20); + \draw (18) -- (0); + \draw (19) -- (23); + \draw (20) -- (3); \draw (20) -- (12); - \draw (21) -- (4); + \draw (20) -- (15); + \draw (20) -- (17); \draw (21) -- (8); - \draw (21) -- (12); - \draw (21) -- (14); - \draw (22) -- (3); - \draw (22) -- (8); - \draw (22) -- (12); - \draw (22) -- (14); - \draw (23) -- (1); - \draw (23) -- (7); - \draw (23) -- (13); - \draw (24) -- (10); + \draw (22) -- (2); + \draw (22) -- (7); + \draw (22) -- (23); + \draw (23) -- (19); + \draw (23) -- (22); + \draw (24) -- (1); + \draw (24) -- (5); + \draw (24) -- (7); + \draw (24) -- (8); \draw (25) -- (8); - \draw (25) -- (13); - \draw (25) -- (14); - \draw (25) -- (15); - \draw (26) -- (0); - \draw (26) -- (2); - \draw (27) -- (2); - \draw (28) -- (3); - \draw (29) -- (0); - \draw (29) -- (7); - \draw (29) -- (9); + \draw (25) -- (10); + \draw (26) -- (10); + \draw (26) -- (16); + \draw (26) -- (29); + \draw (27) -- (10); + \draw (27) -- (12); + \draw (28) -- (4); + \draw (29) -- (26); \end{tikzpicture} \end{center} @@ -125,10 +123,10 @@ Voici le graphe de SocialGraphe \paragraph{Première énigme} Trouver qui est le coupable avec les indices suivants. \begin{compactitem} -\item Indice 1 : Le suspect a entre 20 et 29 ans. -\item Indice 2 : Le suspect pratique au moins du Tennis et/ou du Football . -\item Indice 3 : Le suspect a les cheveux Brun ou Blond . -\item Indice 4 : Le suspect a au moins un ami avec les cheveux Blond . +\item Indice 1 : Le suspect pratique au moins du Baseball et/ou du Basketball . +\item Indice 2 : Le suspect pratique 2 ou 1 sport(s). +\item Indice 3 : Le suspect a les cheveux Roux ou Blond . +\item Indice 4 : Le suspect a au moins un ami avec les cheveux Roux . \end{compactitem} -% Solution : Oliver +% Solution : Nathan \end{document}