{"id":10751,"date":"2025-10-25T13:53:32","date_gmt":"2025-10-25T11:53:32","guid":{"rendered":"https:\/\/spgoo.org\/?page_id=10751"},"modified":"2025-10-26T14:12:21","modified_gmt":"2025-10-26T13:12:21","slug":"axelrod-round-robin","status":"publish","type":"page","link":"https:\/\/spgoo.org\/?page_id=10751","title":{"rendered":"Axelrod round-robin"},"content":{"rendered":"<script type='text\/javascript'>\nvar id = \"10667\";<\/script>\n<script type='text\/javascript' src='https:\/\/spgoo.org\/wp-content\/uploads\/winp-css-js\/10667.js?ver=1762078084'><\/script>\n\n\n<link rel=\"stylesheet\" href=\"https:\/\/cdn.jsdelivr.net\/npm\/jsxgraph\/distrib\/jsxgraph.css\">\r\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/jsxgraph\/distrib\/jsxgraphcore.js\"><\/script>\r\n<link rel=\"stylesheet\" type=\"text\/css\" href=\"https:\/\/cdn.jsdelivr.net\/gh\/bitmaks\/cm-web-fonts@latest\/fonts.css\">\r\n\r\n\r\n<!-- MathJax -->\r\n<script>\r\n\twindow.MathJax = {\r\n\t\ttex: { inlineMath: [['\\\\(', '\\\\)'], ['$', '$']] },\r\n\t\tsvg: { fontCache: 'global' }\r\n\t};\r\n<\/script>\r\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/mathjax@3\/es5\/tex-svg.js\"><\/script>  \r\n    <style>\r\n\t\t* {\r\n\t\t\tmargin: 0;\r\n\t\t\tpadding: 0;\r\n\t\t\tbox-sizing: border-box;\r\n\t\t}\r\n\r\n\t\t.board {\r\n\t\t\tborder: 2px solid #ccc;\r\n\t\t\tbox-shadow: 0 0 10px rgba(0,0,0,0.1);\r\n\t\t}\r\n\r\n\t\t#board2 {\r\n\t\tposition: absolute;\r\n\t\t\tleft:28%;\r\n\t\t\ttop:22%;\t\r\n        width: 500px;\r\n        height: 400px;\r\n        }\r\n\r\n\t\t#gameContainer {\r\n            position: absolute;\r\n\t\t\tleft:15%;\r\n\t\t\ttop:10%;\r\n            width: 800px;\r\n            height: 800px;\r\n            background: rgba(255, 255, 255, 0.1);\r\n            border-radius: 50%;\r\n            box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\r\n        }\r\n\r\n        #canvas {\r\n            position: absolute;\r\n            top: 0;\r\n            left: 0;\r\n        }\r\n\r\n        .fighter {\r\n            position: absolute;\r\n            width: 50px;\r\n            height: 50px;\r\n            border-radius: 50%;\r\n            display: flex;\r\n            align-items: center;\r\n            justify-content: center;\r\n            font-size: 24px;\r\n            cursor: pointer;\r\n            transition: all 0.3s ease;\r\n            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);\r\n            border: 3px solid white;\r\n        }\r\n\r\n        .fighter:hover {\r\n            transform: scale(1.1);\r\n            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);\r\n        }\r\n\r\n        .fighter.fighting {\r\n            z-index: 100;\r\n            \/* pointer-events: none;*\/\r\n        }\r\n\r\n        #controls {\r\n            position: absolute;\r\n            top: 100px;\r\n            left: 1200px;\r\n            transform: translateX(-50%);\r\n            background: rgba(255, 255, 255, 0.95);\r\n            padding: 20px;\r\n            border-radius: 15px;\r\n            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);\r\n            text-align: center;\r\n            min-width: 400px;\r\n            z-index: 1000;\r\n        }\r\n\r\n         #controls h1 {\r\n            margin-bottom: 10px;\r\n            color: #667eea;\r\n            font-size: 20px;\r\n        }\r\n\r\n        #liste_strategies {\r\n\t\t\tdisplay:none;\r\n            position: absolute;\r\n            top: 500px;\r\n            left: 1200px;\r\n            transform: translateX(-50%);\r\n            background: rgba(255, 255, 255, 0.95);\r\n            padding: 20px;\r\n            border-radius: 15px;\r\n            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);\r\n            text-align: center;\r\n            min-width: 400px;\r\n            z-index: 1000;\r\n        }\r\n\t\t #liste_strategies h1 {\r\n            margin-bottom: 10px;\r\n            color: #667eea;\r\n            font-size: 20px;\r\n        }\r\n        #message {\r\n            margin: 10px 0;\r\n            font-weight: bold;\r\n            color: #764ba2;\r\n            min-height: 24px;\r\n        }\r\n\r\n        button {\r\n            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\r\n            color: white;\r\n            border: none;\r\n            padding: 10px 20px;\r\n            border-radius: 8px;\r\n            cursor: pointer;\r\n            font-size: 16px;\r\n            margin: 5px;\r\n            transition: transform 0.2s;\r\n        }\r\n\r\n        button:hover {\r\n            transform: scale(1.05);\r\n        }\r\n\r\n        button:disabled {\r\n            opacity: 0.5;\r\n            cursor: not-allowed;\r\n        }\r\n\r\n        #stats {\r\n            margin-top: 10px;\r\n            font-size: 14px;\r\n            color: #555;\r\n        }\r\n\r\n        .combat-effect {\r\n            position: absolute;\r\n            width: 100px;\r\n            height: 100px;\r\n            border-radius: 50%;\r\n            background: radial-gradient(circle, rgba(255, 215, 0, 0.8) 0%, rgba(255, 69, 0, 0) 70%);\r\n            animation: explode 0.5s ease-out;\r\n            pointer-events: none;\r\n            z-index: 99;\r\n        }\r\n\r\n\t\t.section  label {\r\n            display: block;\r\n            margin-bottom: 5px;\r\n            font-size: 13px;\r\n        }\r\n        \r\n        \r\n        .section input[type=\"range\"] {\r\n            width: 100%;\r\n            margin: 10px 0;\r\n        }\r\n\t\t\r\n        @keyframes explode {\r\n            from {\r\n                transform: scale(0);\r\n                opacity: 1;\r\n            }\r\n            to {\r\n                transform: scale(2);\r\n                opacity: 0;\r\n            }\r\n        }\r\n    <\/style>\r\n<h1>\\(\\textrm{Tournois d&#8217;Axelrod : round-robin}\\)<\/h1>  \r\n<div id=\"controls\">\r\n\t\t<h1>Contr\u00f4le simulation<\/h1>\r\n\t\t<label title=\"Chaque candidat re\u00e7oit une strat\u00e9gie unique pendant tout le tournoi.\" >Strat\u00e9gie Unique<\/label>\r\n\t\t<input type=\"radio\" id=\"strategUnique\"  name=\"Mode_strateg\" onchange=\"modif_modestrateg();\" checked \/>\r\n\t\t<label title=\"A chaque duel le candidat re\u00e7oit une strat\u00e9gie tir\u00e9e au hasard.\">Strat\u00e9gie multiple<\/label>\r\n\t\t<input type=\"radio\" id=\"strategMultiple\" name=\"Mode_strateg\" onchange=\"modif_modestrateg();\"\/>\r\n\t\r\n\t\t<label>Nb candidats : <span id=\"lbl_Candidats\" >50<\/span><\/label>\r\n\t\t<input type=\"range\" id=\"sizeCandidats\" min=\"10\" max=\"80\" value=\"20\" onchange=\"init();\">\r\n\t\t<label>Nb de duels : <span id=\"lbl_duels\" >190<\/span><\/label>\r\n\t\t<label>Nb de confrontations par duel : <span id=\"lbl_parties\" >10<\/span><\/label>\r\n\t\t<input type=\"range\" id=\"sizeDuels\" min=\"10\" max=\"100\" value=\"10\" onchange=\"init();\">\r\n\r\n        <div id=\"message\">round-robin<\/div>\r\n        <div id=\"stats\">Candidats : <span id=\"count\">8<\/span> duels: <span id=\"nbduelsRestant\">0<\/span><\/div>\r\n        <button id=\"startBtn\">\u25b6\ufe0f Lancer Duel<\/button>\r\n        <button id=\"resetBtn\">\ud83d\udd04 Nouvelle Partie<\/button>\r\n<\/div>\r\n<div id=\"liste_strategies\">\r\n\t<h1>Liste des strat\u00e9gies<\/h1>\r\n\t<div id=\"id_liste\"><\/div>\r\n<\/div>\r\n<div style=\"width:1000px;height:900px;\">\r\n    <div id=\"gameContainer\">\r\n        <!-- <canvas id=\"canvas\" width=\"600\" height=\"600\"><\/canvas> -->\r\n    <\/div>\r\n    <div id=\"board2\" class=\"board\"><\/div>\r\n<\/div>\r\n<div style=\"display:flex;justify-content:space-between;\">\r\n\t<a style=\"font-Size:20px;color:white\" href=\"https:\/\/spgoo.org\/?page_id=10890\">\\(\\,\\,\\,\\textrm{Tournoi Elimination directe}\\)<\/a> \r\n\t<a style=\"font-Size:20px;color:white\" href=\"https:\/\/spgoo.org\/?page_id=10669\">\\(\\,\\,\\,\\textrm{Tournoi Face \u00e0 Face}\\)<\/a> \r\n<\/div>\r\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\" style=\"text-align:center;\"><summary style=\"color:white\">D\u00e9tails<\/summary>\r\n<div id=\"explications\" style=\"color:white\" >\r\n\t<h1>Explications sur le simulateur<\/h1>\r\n<p>Configuration en tournoi Round-Robin\r\n\t\t<li>Dans cette configuration, un ensemble de joueurs va apparaitre autour du simulateur. Une fois la partie d\u00e9marr\u00e9e, une s\u00e9lection de deux joueurs parmi l&#8217;ensemble sera effectu\u00e9e. Les deux joueurs apr\u00e8s avoir s\u00e9lection\u00e9s une strat\u00e9gie pourront se confronter. La strat\u00e9gie est conserv\u00e9e pour un m\u00eame joueur tout au long du tournoi. Le jeu se d\u00e9roulera jusqu&#8217;\u00e0 ce que chaque joueur ait affront\u00e9 tous les autres.<\/li>\r\n\t<\/p><\/div>\r\n<\/details>\r\n\r\n\r\n    <script>\r\n\r\n        const board2 = JXG.JSXGraph.initBoard('board2', { boundingbox: [-10, 10, 10, -10],\r\n        axis: false,keepAspectRatio:true,showCopyright: false,showNavigation: false});\r\n\r\n        \/\/ zone d'affectation aux joueurs \r\n        board2.create('polygon',[[-13,0],[-13,10],[13,10],[13,0]],{highlight:false,fillColor:\"#EBACA2\",opacity:0.9,vertices:{visible:false}});\r\n        board2.create('polygon',[[-13,0],[-13,-10],[13,-10],[13,0]],{highlight:false,fillColor:\"#BED3C3\",opacity:0.9,vertices:{visible:false}});\r\n\r\n        \/\/ ecriture des strat\u00e9gies retenus et en cours \r\n        const  Strateg1 =  board2.create('text',[0,8,\"\\\\(\\\\textrm{Strat\u00e9gie joueur 1}\\\\)\"],{fontSize:16,fixed:true,highlight:false,opacity:1,anchorX:'middle',anchorY:'middle',color:'red'});\r\n        const  Strateg2 =  board2.create('text',[0,-8,\"\\\\(\\\\textrm{Strat\u00e9gie joueur 2}\\\\)\"],{fontSize:16,fixed:true,highlight:false,anchorX:'middle',anchorY:'middle',color:'red'});\r\n\r\n\r\n        \/\/tableau central\r\n        const p0 = board2.create('point', [-11, 0],{visible:false});\r\n        const p1 = board2.create('point', [11, -0],{visible:false});\r\n        const  l0 = board2.create('line', [p0, p1],{highlight:false,fixed:true,shadow:true});\r\n        var ineq0 = board2.create('inequality', [l0],{inverse: false, fillColor: '#EBACA2',opacity:0.1});\r\n        var ineq1 = board2.create('inequality', [l0],{inverse: true, fillColor: '#BED3C3',opacity:0.1});\r\n\r\n        var pc10 = board2.create('point',[-5.5,5],{visible:false});\r\n        var pc10_A = board2.create('point',[-5.5,2.5],{visible:false});\r\n        var circCurseur10 =  board2.create('circle',[pc10,2.5],{fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#AE181E',opacity:0.0});\r\n        \/\/ varie de -0.25 \u00e0 0.75 \r\n        var pc10_Glider = board2.create('glider',[circCurseur10],{visible:true,color:\"#EBACA2\",label:{visible:false}});\r\n        beta = board2.create('angle', [ pc10_A,pc10, pc10_Glider], {\r\n                type: 'sector',\r\n                layer:11,\r\n                label:{visible:false},\r\n                orthoType: 'square',\r\n                fillColor:\"red\",\r\n                opacity:0.7,\r\n                \/*orthoSensitivity: 2,*\/\r\n                radius: 2.5\r\n            });\r\n        pc10_Glider.setGliderPosition(-0.25);\r\n        var circ10 =  board2.create('circle',[pc10,2],{layer:10,fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#AE181E',opacity:0.1});\r\n        \/\/var text10 =  board2.create('text',[-5.5,5,\"\\\\(\\\\textrm{C} \\\\)\"],{fixed:true,highlight:false,anchorX:'middle',anchorY:'middle',fontSize:16,color:'Navy'});\r\n        var imb0 = board2.create('image', ['.\/personnalisation\/images\/poignee.png', [-6.9,3.6], [3,3]],{layer:15,fixed:true,anchorX:'middle',anchorY:'middle',opacity:1});\r\n\r\n\r\n        var pc11 = board2.create('point',[5.5,5],{visible:false});\r\n        var pc11_A = board2.create('point',[5.5,2.5],{visible:false});\r\n        var circCurseur11 =  board2.create('circle',[pc11,2.5],{fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#AE181E',opacity:0.0});\r\n        \/\/ varie de -0.25 \u00e0 0.75 \r\n        var pc11_Glider = board2.create('glider',[circCurseur11],{visible:true,color:\"#EBACA2\",label:{visible:false}});\r\n        board2.create('angle', [ pc11_A,pc11, pc11_Glider], {\r\n                type: 'sector',\r\n                layer:11,\r\n                label:{visible:false},\r\n                orthoType: 'square',\r\n                fillColor:\"red\",\r\n                opacity:0.7,\r\n                \/*orthoSensitivity: 2,*\/\r\n                radius: 2.5\r\n            });\r\n        pc11_Glider.setGliderPosition(-0.25);\r\n        var circ11 =  board2.create('circle',[pc11,2],{layer:10,fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#AE181E',opacity:0.2});\r\n        \/\/var text11 =  board2.create('text',[5.5,5,\"\\\\(\\\\textrm{T} \\\\)\"],{fixed:true,highlight:false,anchorX:'middle',anchorY:'middle',fontSize:16,color:'Navy'});\r\n        var imb1 = board2.create('image', ['.\/personnalisation\/images\/couteau.png', [4,3.6], [3,3]],{layer:15,fixed:true,anchorX:'middle',anchorY:'middle'});\r\n\r\n        var pc20 = board2.create('point',[-5.5,-5],{visible:false});\r\n        var pc20_A = board2.create('point',[-5.5,-7.5],{visible:false});\r\n        var circCurseur20 =  board2.create('circle',[pc20,2.5],{fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#AE181E',opacity:0.0});\r\n        \/\/ varie de -0.25 \u00e0 0.75 \r\n        var pc20_Glider = board2.create('glider',[circCurseur20],{visible:true,color:\"#BED3C3\",label:{visible:false}});\r\n        board2.create('angle', [ pc20_A,pc20, pc20_Glider], {\r\n                type: 'sector',\r\n                layer:11,\r\n                label:{visible:false},\r\n                orthoType: 'square',\r\n                fillColor:\"lightgreen\",\r\n                opacity:0.7,\r\n                \/*orthoSensitivity: 2,*\/\r\n                radius: 2.5\r\n            });\r\n        pc20_Glider.setGliderPosition(-0.25);\r\n        var circ20 =  board2.create('circle',[pc20,2],{layer:10,fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#BED3C3',opacity:0.2});\r\n        \/\/var text20 =  board2.create('text',[-5.5,-5,\"\\\\(\\\\textrm{C} \\\\)\"],{fixed:true,highlight:false,anchorX:'middle',anchorY:'middle',fontSize:16,color:'Navy'});\r\n        var imb3 = board2.create('image', ['.\/personnalisation\/images\/poignee.png', [-6.9,-6.5], [3,3]],{layer:15,fixed:true,anchorX:'middle',anchorY:'middle'});\r\n\r\n        var pc21 = board2.create('point',[5.5,-5],{visible:false});\r\n        var pc21_A = board2.create('point',[5.5,-7.5],{visible:false});\r\n        var circCurseur21 =  board2.create('circle',[pc21,2.5],{fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#AE181E',opacity:0.0});\r\n        \/\/ varie de -0.25 \u00e0 0.75 \r\n        var pc21_Glider = board2.create('glider',[circCurseur21],{visible:true,color:\"#BED3C3\",label:{visible:false}});\r\n        board2.create('angle', [ pc21_A,pc21, pc21_Glider], {\r\n                type: 'sector',\r\n                layer:11,\r\n                label:{visible:false},\r\n                orthoType: 'square',\r\n                fillColor:\"lightgreen\",\r\n                opacity:0.7,\r\n                \/*orthoSensitivity: 2,*\/\r\n                radius: 2.5\r\n            });\r\n        pc21_Glider.setGliderPosition(-0.25);\r\n        var circ21 =  board2.create('circle',[pc21,2],{layer:10,fixed:true,shadow:true,strokeColor:'darkgreen',fillColor:'#BED3C3',opacity:0.2});\r\n        \/\/var text21 =  board2.create('text',[5.5,-5,\"\\\\(\\\\textrm{T} \\\\)\"],{fixed:true,highlight:false,anchorX:'middle',anchorY:'middle',fontSize:16,color:'Navy'});\r\n        var imb4 = board2.create('image', ['.\/personnalisation\/images\/couteau.png', [4,-6.5], [3,3]],{layer:15,fixed:true,anchorX:'middle',anchorY:'middle'});\r\n\r\n\r\n        const emojis = [\"janvier\",\"gabin\",\"woman-1\",\"woman-2\",\"woman-6\",\"ladenree\",\"paul\",\"bourville\" ];\r\n        const colors = [ '#4ECDC4', '#45B7D1', '#FFA07A',  '#F7DC6F', '#BB8FCE', '#85C1E2','#FF6B6B','#98D8C8'];\r\n        \r\n        let fighters = [];\r\n        let isFighting = false;\r\n        let setBoucle=null; \r\n\r\n        const container = document.getElementById('gameContainer');\r\n        \/\/const canvas = document.getElementById('canvas');\r\n        \/\/const ctx = canvas.getContext('2d');\r\n        const message = document.getElementById('message');\r\n        const count = document.getElementById('count');\r\n        const startBtn = document.getElementById('startBtn');\r\n        const resetBtn = document.getElementById('resetBtn');\r\n\t\tconst sizeCandidats= document.getElementById('sizeCandidats');\r\n\t\tconst sizeDuels=document.getElementById(\"sizeDuels\");\r\n\t\t\r\n        class Fighter {\r\n            constructor(emoji, color, index, total) {\r\n                this.emoji = emoji;\r\n                this.color = color;\r\n\t\t\t\tthis.id=index;\r\n                this.power = Math.floor(Math.random() * 50) + 50;\r\n                this.element = this.createElement();\r\n                this.index = index;\r\n\t\t\t\tthis.score=0; \/\/ score engrang\u00e9 au cours des rencontres \r\n                this.total = total;\r\n                this.strategie=null;\r\n\t\t\t\tthis.CstrategiesUser={};   \/\/ le cumul des user\/strat\u00e9gie rencontr\u00e9es \r\n                this.updatePosition();\r\n\t\t\t\tthis.statut=\"jouer\";\r\n            }\r\n\r\n            createElement() {\r\n                const div = document.createElement('div');\r\n                div.className = 'fighter';\r\n                const img=document.createElement('img');\r\n                img.src=\".\/personnalisation\/images\/\"+this.emoji+\".png\" ;\r\n                img.setAttribute(\"style\",\"witdh:40px;height:40px;\")\r\n                \/\/img.setAttribute(\"height\",\"40px\")\r\n                div.appendChild(img);\r\n                div.style.backgroundColor = this.color;\r\n\t\t\t\timg.setAttribute(\"data-toggle\",\"tooltip\");\r\n\t\t\t\timg.setAttribute(\"data-placement\",\"right\");\r\n\t\t\t\timg.setAttribute(\"title\",\"score\");\r\n\t\t\t\timg.joueur=this;\r\n\t\t\t\timg.addEventListener(\"mouseover\",function() {\r\n\t\t\t\t\tdocument.getElementById(\"liste_strategies\").style.display=\"block\";\r\n\t\t\t\t\tthis.title=\"score :\"+ this.joueur.score;\r\n\t\t\t\t\tconst zone=document.getElementById(\"id_liste\");\r\n\t\t\t\t\tzone.innerHTML=\"\";\r\n\t\t\t\t\tObject.keys(this.joueur.CstrategiesUser).forEach(user=>{\r\n\t\t\t\t\t\tconst item=document.createElement(\"p\");\r\n\t\t\t\t\t\titem.setAttribute(\"style\",\"color:black;\")\r\n\t\t\t\t\t\titem.innerHTML=user+\" Strateg : \" +this.joueur.CstrategiesUser[user][\"strateg\"]+\"res : \"+ this.joueur.CstrategiesUser[user][\"result\"];\r\n\t\t\t\t\t\tzone.appendChild(item);\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t\timg.addEventListener(\"mouseleave\",function() {\r\n\t\t\t\t\tdocument.getElementById(\"liste_strategies\").style.display=\"none\";\r\n\r\n\t\t\t\t});\r\n\t\t\t\t\r\n                container.appendChild(div);\r\n\t\t\t\t\r\n                return div;\r\n            }\r\n\r\n            updatePosition() {\r\n                const angle = (this.index \/ this.total) * 2 * Math.PI - Math.PI \/ 2;\r\n                const radius = 350;\r\n                const centerX = 400;\r\n                const centerY = 400;\r\n                \r\n                const x = centerX + radius * Math.cos(angle) - 25;\r\n                const y = centerY + radius * Math.sin(angle) - 25;\r\n                \r\n                this.element.style.left = x + 'px';\r\n                this.element.style.top = y + 'px';\r\n            }\r\n\r\n            highlight() {\r\n                this.element.style.transform = 'scale(1.2)';\r\n                this.element.style.boxShadow = '0 0 20px ' + this.color;\r\n            }\r\n\r\n            deselect() {\r\n                this.element.style.transform = 'scale(1)';\r\n                this.element.style.boxShadow = '0 4px 10px rgba(0, 0, 0, 0.3)';\r\n            }\r\n\r\n            moveToCenter() {\r\n                return new Promise(resolve => {\r\n                    this.element.classList.add('fighting');\r\n                    const centerX = 350 + (Math.random() - 0.5) * 50;\r\n                    const centerY = 350 + (Math.random() - 0.5) * 50;\r\n                    this.element.style.left = centerX + 'px';\r\n                    this.element.style.top = centerY + 'px';\r\n                    setTimeout(resolve, 600);\r\n                });\r\n            }\r\n\r\n            moveToHaut() {\r\n                return new Promise(resolve => {\r\n                    this.element.classList.add('fighting');\r\n                    const centerX = 370 ;\r\n                    const centerY = 270 ;\r\n                    this.element.style.left = centerX + 'px';\r\n                    this.element.style.top = centerY + 'px';\r\n                    setTimeout(resolve, 600);\r\n                });\r\n            }\r\n            moveToBas() {\r\n                return new Promise(resolve => {\r\n                    this.element.classList.add('fighting');\r\n                    const centerX = 370 ;\r\n                    const centerY = 450 ;\r\n                    this.element.style.left = centerX + 'px';\r\n                    this.element.style.top = centerY + 'px';\r\n                    setTimeout(resolve, 600);\r\n                });\r\n            }\r\n            remove() {\r\n                this.element.style.opacity = '0';\r\n                this.element.style.transform = 'scale(0)';\r\n                setTimeout(() => this.element.remove(), 300);\r\n            }\r\n        }\r\n  \t\t\/\/ let nb_pas=10;\r\n        let nbj=50;\r\n\t\tlet nb_duels=10;\r\n\t\t\r\n        let pas_score=1\/nb_duels;\r\n        const resultat={\"C-T\":[5,0],\"C-C\":[1,1],\"T-T\":[1,1],\"T-C\":[0,5]}\r\n        let fct1=null, fct2=null; \r\n        let pas=0;\r\n        let histo1=[];\r\n        let histo2=[];\r\n        let choix1=\"T\";\r\n        let choix2=\"\";\r\n        let score1=0;\r\n        let score2=0;\r\n        let Cscore1=0;\r\n        let Cscore2=0;\r\n        let CptC1=0, CptT1=0;\r\n        let CptC2=0, CptT2=0;           \r\n        let declenche=null;\t\t\r\n\t\t\r\n\t\t\r\n\t\tconst game_init=function() {\r\n\t\t\tfct1=null, fct2=null; \r\n\t\t\thisto1=[];\r\n\t\t\thisto2=[];\r\n\t\t\tchoix1=\"T\";\r\n\t\t\tchoix2=\"\";\r\n\t\t\tscore1=0;\r\n\t\t\tscore2=0;\r\n\t\t\tCscore1=0;\r\n\t\t\tCscore2=0;\r\n\t\t\tCptC1=0, CptT1=0;\r\n\t\t\tCptC2=0, CptT2=0;  \r\n\t\t\tpc10_Glider.setGliderPosition(-0.25);\r\n\t\t\tpc11_Glider.setGliderPosition(-0.25);\r\n\t\t\tpc20_Glider.setGliderPosition(-0.25);\r\n\t\t\tpc21_Glider.setGliderPosition(-0.25);\r\n\t\t\tpas=nb_duels;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n        function init() {\r\n\t\t\tnbj=parseInt(document.getElementById(\"sizeCandidats\").value);\r\n\t\t\tdocument.getElementById(\"lbl_Candidats\").innerHTML=nbj;\r\n\t\t\tnb_duels=parseInt(document.getElementById(\"sizeDuels\").value);\r\n\t\t\tdocument.getElementById(\"lbl_parties\").innerHTML=nb_duels;\r\n\t\t\tdocument.getElementById(\"lbl_duels\").innerHTML=parseInt(nbj*(nbj-1)\/2);\r\n\t\t\tdocument.getElementById(\"nbduelsRestant\").innerHTML=\"0\";\r\n            fighters = [];\r\n            isFighting = false;\r\n            container.querySelectorAll('.fighter').forEach(el => el.remove());\r\n            let j=0;\r\n            for (let i = 0; i < nbj; i++) {\r\n                const emo=emojis[i%8];\r\n\t\t\t\tconst coul= colors[j];\r\n\t\t\t\tif (i>0) {\r\n\t\t\t\t\tif (i%7==0) {\r\n\t\t\t\t\t\tj++;\r\n\t\t\t\t\t\tj=j%7;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n                \r\n                fighters.push(new Fighter(emo,coul , i, nbj));\r\n            }\r\n            \r\n            updateStats();\r\n            message.textContent = 'Pr\u00eat \u00e0 commencer';\r\n            startBtn.disabled = false;\r\n\t\t\tgame_init();\r\n\t\t\t\r\n        }\r\n\t\tlet strategie_unique=true;  \r\n\t\t\r\n\t\t\/\/ fixe la strategie_unique  : true ou false en fonction du choix utilisateur \r\n\t\tconst modif_modestrateg=function() {\r\n\t\t\tif (document.getElementById(\"strategUnique\").checked) {\r\n\t\t\t\tstrategie_unique=true;\r\n\t\t\t}else {\r\n\t\t\t\tstrategie_unique=false;\r\n\t\t\t}\r\n\t\t\tconsole.log(strategie_unique);\r\n\t\t}\r\n\t\t\r\n\t\t\/\/ -------------------------------------------------------------------------------\r\n\t\t\/\/ Selection doit se faire en fonction  de l'historique \r\n\t\t\/\/ une personne ne peut rencontrer plusieurs fois le m\u00eame adversaire \r\n\t\t\/\/ -------------------------------------------------------------------------------\r\n        function selectRandomFighters() {\r\n\t\t\t\/\/ prendre uniquement parmi les statuts jouer\r\n            const available = [...fighters.filter(e=>e.statut==\"jouer\")];\r\n            const index1 = Math.floor(Math.random() * available.length);\r\n            const fighter1 = available[index1];\r\n\t\t\tavailable.splice(index1, 1);\r\n            \/\/ verifier si le fighter1 n'a pas d\u00e9j\u00e0 jouer contre lui\r\n            const dejajoues=fighter1.CstrategiesUser;\r\n\t\t\tlet ite=0;\r\n\t\t\tlet fighter2=null;\r\n\t\t\twhile (ite<nb_iterations*2) {\r\n            \tconst index2 = Math.floor(Math.random() * available.length);\r\n\t\t\t\tconst num=available[index2].id;\r\n\t\t\t\tif (dejajoues[num]==undefined) {\r\n\t\t\t\t\tfighter2 = available[index2];\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tavailable.splice(index2, 1);\r\n\t\t\t\tite++;\r\n\t\t\t}  \r\n\t\t\tconsole.log(fighter1.id,fighter2.id);\r\n            return [fighter1, fighter2];\r\n        }\r\n\r\n        \/\/ ---------------------------------------------------------------------------\r\n        \/\/ effectue un choix al\u00e9atoire dans la liste des strat\u00e9gies dans chaque serie \r\n        \/\/ ---------------------------------------------------------------------------\r\n        const choix_strateg=function() {\r\n            \/\/ plusieurs series : 3 Premier tournoisn,s econd tournois et tournois uletrieurs \r\n            \/\/ on choisit parmis 3 la s\u00e9rie \r\n            let numserie = parseInt(Math.random()*0); \r\n            \/\/ et ensuite dans cette serie la strat\u00e9gie en fonction du nombre\r\n            const serie= Object.keys(tableau_strategies)[numserie];\r\n            const nb=tableau_strategies[serie].length;\r\n            const num_strateg= parseInt(Math.random()*nb);\r\n            return  tableau_strategies[serie][num_strateg];\r\n        }\r\n\t\tlet nb_iterations=90;\r\n\t\tlet nb_ite=0;\r\n\t\t\r\n        async function startFight() {\r\n\t\t\t\/\/ arret de la partie : quand tout le monde \u00e0 jouer avec tout le monde\r\n            if (nb_ite > nb_iterations) {\r\n\t\t\t\tsizeCandidats.disabled = false;\r\n\t\t\t\tsizeDuels.disabled = false;\r\n\t\t\t\tresetBtn.disabled = false;\t\r\n                \/\/clearInterval(setBoucle);\r\n                return;\r\n            }\r\n\t\t\tdocument.getElementById(\"nbduelsRestant\").innerHTML=nb_ite;\r\n            nb_ite++;\r\n            \/\/ isFighting = true;\r\n            startBtn.disabled = true;\r\n\t\t\tresetBtn.disabled = true;\r\n            sizeCandidats.disabled = true;\r\n\t\t\tsizeDuels.disabled = true;\r\n            const [fighter1, fighter2] = selectRandomFighters();\r\n            \r\n            message.textContent = `${fighter1.emoji} VS ${fighter2.emoji}`;\r\n            \r\n            fighter1.highlight();\r\n            fighter2.highlight();\r\n            \r\n            await new Promise(resolve => setTimeout(resolve, 200));\r\n\t\t\tif (strategie_unique) {\r\n\t\t\t\tif (fighter1.strategie==null )\r\n\t\t\t\t\tfighter1.strategie= choix_strateg();\r\n\t\t\t\tif (fighter2.strategie==null )\r\n            \t\tfighter2.strategie= choix_strateg();\t\r\n\t\t\t}else {\r\n\t\t\t\t\/\/ on m\u00e9morise les strat\u00e9gies des deux joueurs \r\n\t\t\t\tfighter1.strategie= choix_strateg();\r\n\t\t\t\tfighter2.strategie= choix_strateg();\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n            Strateg1.setText(fighter1.strategie.key);\r\n            Strateg2.setText(fighter2.strategie.key);\r\n            \r\n            await Promise.all([\r\n                fighter1.moveToHaut(),\r\n                fighter2.moveToBas()\r\n            ]);\r\n\r\n            createCombatEffect();           \r\n                                    \r\n            await new Promise(resolve => setTimeout(resolve, 500));\r\n            let winner =null; \r\n\t\t\tlet loser = null; \r\n            const resultat =await  game_start(fighter1,fighter2);\r\n\t\t\t\r\n\t\t\tif (resultat==0 ){  \/\/ ex aequo \r\n\t\t\t\tmessage.textContent = `${fighter1.emoji} \u00e9galit\u00e9 ${fighter2.emoji} !`;\r\n\t\t\t\tfighter1.CstrategiesUser[fighter2.id]={\"strateg\":fighter1.strategie.key,\"result\":\"Exaequo\"};\r\n\t\t\t\tfighter2.CstrategiesUser[fighter1.id]={\"strateg\":fighter2.strategie.key,\"result\":\"Exaequo\"};\r\n\t\t\t} if (resultat==1){\r\n\t\t\t\twinner =fighter1;\r\n\t\t\t\tloser = fighter2;\r\n\t\t\t\tmessage.textContent = `${winner.emoji} gagne contre ${loser.emoji} !`;\t\r\n\t\t\t\tfighter1.CstrategiesUser[fighter2.id]={\"strateg\":fighter1.strategie.key,\"result\":\"Winner\"};\r\n\t\t\t\tfighter2.CstrategiesUser[fighter1.id]={\"strateg\":fighter2.strategie.key,\"result\":\"Loser\"};\r\n\t\t\t}else {\r\n\t\t\t\twinner =fighter2;\r\n\t\t\t\tloser = fighter1;\t\t\t\t\r\n\t\t\t\tmessage.textContent = `${winner.emoji} gagne contre ${loser.emoji} !`;\t\t\t\t\t\t\t\t\r\n\t\t\t\tfighter1.CstrategiesUser[fighter2.id]={\"strateg\":fighter1.strategie.key,\"result\":\"Loser\"};\r\n\t\t\t\tfighter2.CstrategiesUser[fighter1.id]={\"strateg\":fighter2.strategie.key,\"result\":\"Winner\"};\r\n\r\n\t\t\t}\r\n            await new Promise(resolve => setTimeout(resolve, 2000));\r\n            \/\/ await new Promise(resolve => setTimeout(resolve,1000));\r\n            \r\n            repositionFighters();\r\n            \r\n            fighter1.deselect();\r\n            fighter1.element.classList.remove('fighting');\r\n            fighter2.deselect();\r\n            fighter2.element.classList.remove('fighting');\r\n            \r\n\t\t\t\/\/ on v\u00e9rifie si les joueurs doivent encore jouer \r\n\t\t\tif (Object.keys(fighter1.CstrategiesUser).length==nbj-1)\r\n\t\t\t\t{\r\n\t\t\t\t\t\/\/ il s'arr\u00eate de jouer \r\n\t\t\t\t\tfighter1.statut=\"arret\";\r\n\t\t\t\t}\r\n\t\t\tif (Object.keys(fighter2.CstrategiesUser).length==nbj-1)\r\n\t\t\t\t{\r\n\t\t\t\t\t\/\/ il s'arr\u00eate de jouer \r\n\t\t\t\t\tfighter2.statut=\"arret\";\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\r\n            \/\/isFighting = false;\r\n            \r\n            updateStats();\r\n            \r\n            if (fighters.length === 1) {\r\n                message.textContent = `\ud83c\udfc6 ${fighters[0].emoji} est le champion !`;\r\n                startBtn.disabled = true;\r\n            } else {\r\n                message.textContent = 'Pr\u00eat pour le prochain combat';\r\n                startBtn.disabled = false;\r\n            }\r\n            startFight(); \r\n        }\r\n\r\n        function repositionFighters() {\r\n            fighters.forEach((fighter, index) => {\r\n                fighter.index = index;\r\n                fighter.total = fighters.length;\r\n                fighter.updatePosition();\r\n            });\r\n        }\r\n\r\n        function createCombatEffect() {\r\n            const effect = document.createElement('div');\r\n            effect.className = 'combat-effect';\r\n            effect.style.left = '250px';\r\n            effect.style.top = '250px';\r\n            container.appendChild(effect);\r\n            setTimeout(() => effect.remove(), 500);\r\n        }\r\n\r\n        function updateStats() {\r\n            count.textContent = fighters.length;\r\n        }\r\n        \r\n        \/\/ boucle sur le combat \r\n        const boucle=function() {\r\n            startFight(); \r\n            \/\/ setBoucle= setInterval(startFight,1000);\r\n        }\r\n        startBtn.addEventListener('click', boucle);\r\n        resetBtn.addEventListener('click', init);\r\n\r\n        init();\r\n\r\n      \r\n        \/\/ ---------------------------------------------------\r\n        \/\/ gestion des parties: \r\n        \/\/ ---------------------------------------------------\r\n        async function game_start(fighter1,fighter2) {\r\n\t\t\tpas_score=1\/nb_duels;\r\n            game_init();\r\n\t\t\tnb_iterations=parseInt(nbj*(nbj-1)\/2);\r\n\t\t\tpas=0;\r\n            fct1=fighter1.strategie.signature;\r\n            fct1=fct1.replace(\"choixAdv\",\"choix2\").replace(\"HistoAdv\",\"histo2\").replace(\"HistoMe\",\"histo1\");\r\n            fct2=fighter2.strategie.signature;\r\n            fct2=fct2.replace(\"choixAdv\",\"choix1\").replace(\"HistoAdv\",\"histo1\").replace(\"HistoMe\",\"histo2\");\r\n            return await execute(fighter1,fighter2);\r\n        }\r\n        async function execute(fighter1,fighter2) { \r\n\t\t\tlet res1=0,res2=0;\r\n            while (pas<nb_duels) {\r\n                eval(\"choix1=\"+fct1);\r\n                histo1.push(choix1);\r\n                eval(\"choix2=\"+fct2);\r\n                histo2.push(choix2);\r\n                \/\/ calcul des scores score1 et score2 \r\n                [score1,score2]=resultat[choix1+\"-\"+choix2];\r\n                \/\/ calcul des cumuls Cscore1 et Cscore2\r\n                res1+=score1;res2+=score2;\r\n                if (choix1==\"C\")  {CptC1++;pc10_Glider.setGliderPosition(-0.25+CptC1*pas_score);}\r\n                if (choix1==\"T\")  {CptT1++;pc11_Glider.setGliderPosition(-0.25+CptT1*pas_score);}\r\n                if (choix2==\"C\")  {CptC2++;pc20_Glider.setGliderPosition(-0.25+CptC2*pas_score);}\r\n                if (choix2==\"T\")  {CptT2++;pc21_Glider.setGliderPosition(-0.25+CptT2*pas_score);}\r\n                pas++;\r\n                await new Promise(resolve => setTimeout(resolve, 200));\r\n            } \r\n\t\t\tfighter1.score+=res1;\r\n\t\t\tfighter2.score+=res2;\r\n\t\t\t\r\n\t\t\treturn res1>res2?1:res2<res1?2:0;\r\n            \r\n        }\r\n      \r\n\r\n\r\n\r\n\r\n    <\/script>\r\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-10751","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages\/10751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spgoo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10751"}],"version-history":[{"count":2,"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages\/10751\/revisions"}],"predecessor-version":[{"id":10893,"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages\/10751\/revisions\/10893"}],"wp:attachment":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}