{"id":9384,"date":"2023-10-23T17:24:29","date_gmt":"2023-10-23T15:24:29","guid":{"rendered":"https:\/\/www.mathweb.fr\/euclide\/?p=9384"},"modified":"2023-11-05T14:49:22","modified_gmt":"2023-11-05T13:49:22","slug":"le-jeu-du-taquin-en-python","status":"publish","type":"post","link":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/","title":{"rendered":"Le jeu du Taquin en Python"},"content":{"rendered":"\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n&rsquo;est qu&rsquo;une matrice carr\u00e9e&#8230; Mais graphiquement, cela donne quoi avec <em>pygame<\/em> ?<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-video\"><video height=\"642\" style=\"aspect-ratio: 612 \/ 642;\" width=\"612\" controls src=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/taquin.mp4\"><\/video><\/figure>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Le module <em>pygame<\/em> est tr\u00e8s int\u00e9ressant pour repr\u00e9senter graphiquement le taquin.<\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Avant, j&rsquo;utilisais <em>tkinter<\/em>,; mais \u00e7a, c&rsquo;\u00e9tait avant&#8230; Regardons de plus pr\u00e8s comment impl\u00e9menter le jeu du Taquin en Python. Pour savoir ce qu&rsquo;est ce jeu, regardez <a href=\"https:\/\/fr.wikipedia.org\/wiki\/Taquin\" target=\"_blank\" rel=\"noreferrer noopener\">wikipedia<\/a>.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-white ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Au menu sur cette page...<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#Le_jeu_du_Taquin_en_Python_premiers_pas\" >Le jeu du Taquin en Python: premiers pas<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#Le_jeu_du_Taquin_interface_graphique\" >Le jeu du Taquin: interface graphique<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#Le_jeu_du_Taquin_en_Python_ameliorations_avec_des_images\" >Le jeu du Taquin en Python: am\u00e9liorations avec des images<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Le_jeu_du_Taquin_en_Python_premiers_pas\"><\/span>Le jeu du Taquin en Python: premiers pas<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Il faut d&rsquo;abord cr\u00e9er une matrice 4&#215;4 (mais qui ne pollue pas, elle&#8230;). Je vais utiliser <em>numpy<\/em>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"false\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">array( [ [1,2,3,4], [5,6,7,8] , [9,10,11,12], [13,14,15,0] ] )<\/pre>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">C&rsquo;est le plateau initial. Ici, le \u00ab\u00a00\u00a0\u00bb d\u00e9finira l&rsquo;espace vide. Maintenant, il faut m\u00e9langer tout \u00e7a. Et pour se faire, nous allons devoir d\u00e9finir les mouvements.<\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Alors, comme j&rsquo;anticipe beaucoup, je vais directement m&rsquo;orienter vers la <a href=\"https:\/\/www.mathweb.fr\/euclide\/tag\/poo\/\" target=\"_blank\" rel=\"noreferrer noopener\">POO<\/a>.<\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Je vais d\u00e9finir mon taquin comme un objet, et d\u00e9finir des m\u00e9thodes pour cr\u00e9er les mouvements n\u00e9cessaires: bouger une case vers le haut, le bas, la droite et la gauche. Je vais aussi impl\u00e9menter une m\u00e9thode qui affiche en mode texte le plateau (avant <\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Voici un premier jet:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Taquin:\n    def __init__(self):\n        self.plateau = array( [ [1,2,3,4], [5,6,7,8] , [9,10,11,12], [13,14,15,0] ] )\n        self.directions = [] # liste des mouvements utilis\u00e9s pour m\u00e9langer le taquin\n        \n    def __str__(self):\n        return self.plateau.__str__()\n        \n    def poszero(self):\n        for y in range(4):\n            for x in range(4):\n                if self.plateau[y][x] == 0: return y,x\n                \n    def possible_mouvements(self):\n        i,j = self.poszero()\n        impossible = []\n        possible = ['L' , 'R' , 'U' , 'D']\n        if i == 0:\n            impossible.append('D')\n        if i == 3:\n            impossible.append('U')\n        if j == 0:\n            impossible.append('R')\n        if j == 3:\n            impossible.append('L')\n        \n        return [ i for i in possible if i not in impossible ]\n        \n    def down(self):\n        i,j = self.poszero()\n        if i != 0:\n            self.plateau[i][j] = self.plateau[i-1][j]\n            self.plateau[i-1][j] = 0\n            \n    def up(self):\n        i,j = self.poszero()\n        if i != 3:\n            self.plateau[i][j] = self.plateau[i+1][j]\n            self.plateau[i+1][j] = 0\n            \n    def left(self):\n        i,j = self.poszero()\n        if j != 3:\n            self.plateau[i][j] = self.plateau[i][j+1]\n            self.plateau[i][j+1] = 0\n            \n    def right(self):\n        i,j = self.poszero()\n        if j != 0:\n            self.plateau[i][j] = self.plateau[i][j-1]\n            self.plateau[i][j-1] = 0\n            \n    def mix(self):\n        for _ in range( 10, 100 ):\n            direction = choice( self.possible_mouvements() )\n            self.directions.append(direction)\n            match direction:\n                case 'L' : self.left()\n                case 'R' : self.right()\n                case 'U' : self.up()\n                case _ : self.down()<\/pre>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">La m\u00e9thode mix() m\u00e9lange le plateau initial en faisant des mouvements al\u00e9atoires pris parmi ceux qui sont possibles (en fonction  de la position du z\u00e9ro).<\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">\u00c0 ce stade, nous pouvons d\u00e9finir notre taquin:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;&gt;&gt; T = Taquin()\n&gt;&gt;&gt; T.mix()\n&gt;&gt;&gt; print( T )\n&#91;&#91; 2 10  6  5]\n &#91; 9  1  4  7]\n &#91; 0 13 12  8]\n &#91;14  3 11 15]]\n&gt;&gt;&gt; T.up()\n&gt;&gt;&gt; print( T )\n&#91;&#91; 2 10  6  5]\n &#91; 9  1  4  7]\n &#91;14 13 12  8]\n &#91; 0  3 11 15]]<\/code><\/pre>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\"> \u00ab\u00a0T.up()\u00a0\u00bb a d\u00e9tect\u00e9 la case vide et a mont\u00e9 la case qui \u00e9tait sous l&rsquo;espace vide. Bon, c&rsquo;est cool! Maintenant, il faudrait l&rsquo;interface graphique&#8230;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Le_jeu_du_Taquin_interface_graphique\"><\/span>Le jeu du Taquin: interface graphique<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Je vous balance le code direct, c&rsquo;est plus simple:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\"\"\"\nLe jeu du Taquin\nSt\u00e9phane Pasquet\n2023-10-23\nhttps:\/\/mathweb.fr\n\"\"\"\n\nfrom numpy import array\nfrom random import randint, choice\nimport pygame\n\n\"\"\"\nD\u00e9finition de l'objet: Taquin()\n\"\"\"\n\nclass Taquin:\n    def __init__(self):\n        self.plateau = array( [ [1,2,3,4], [5,6,7,8] , [9,10,11,12], [13,14,15,0] ] )\n        self.directions = [] # liste des mouvements utilis\u00e9s pour m\u00e9langer le taquin\n        \n    def __str__(self):\n        return self.plateau.__str__()\n        \n    def poszero(self):\n        for y in range(4):\n            for x in range(4):\n                if self.plateau[y][x] == 0: return y,x\n                \n    def possible_mouvements(self):\n        i,j = self.poszero()\n        impossible = []\n        possible = ['L' , 'R' , 'U' , 'D']\n        if i == 0:\n            impossible.append('D')\n        if i == 3:\n            impossible.append('U')\n        if j == 0:\n            impossible.append('R')\n        if j == 3:\n            impossible.append('L')\n        \n        return [ i for i in possible if i not in impossible ]\n        \n    def down(self):\n        i,j = self.poszero()\n        if i != 0:\n            self.plateau[i][j] = self.plateau[i-1][j]\n            self.plateau[i-1][j] = 0\n            \n    def up(self):\n        i,j = self.poszero()\n        if i != 3:\n            self.plateau[i][j] = self.plateau[i+1][j]\n            self.plateau[i+1][j] = 0\n            \n    def left(self):\n        i,j = self.poszero()\n        if j != 3:\n            self.plateau[i][j] = self.plateau[i][j+1]\n            self.plateau[i][j+1] = 0\n            \n    def right(self):\n        i,j = self.poszero()\n        if j != 0:\n            self.plateau[i][j] = self.plateau[i][j-1]\n            self.plateau[i][j-1] = 0\n            \n    def mix(self):\n        for _ in range( 10, 100 ):\n            direction = choice( self.possible_mouvements() )\n            self.directions.append(direction)\n            match direction:\n                case 'L' : self.left()\n                case 'R' : self.right()\n                case 'U' : self.up()\n                case _ : self.down()\n                \n    def graphicplate(self, screen, win = False):\n        font = pygame.font.Font(None, 100)\n        if win:\n            color = (84,8,8)\n        else:\n            color = (40,58,82)\n        for y in range(4):\n            for x in range(4):\n                if self.plateau[y][x] != 0:\n                    pygame.draw.rect(screen, color, pygame.Rect(16+x*146, 16+y*146, 142, 142), border_radius=20)\n                    if self.plateau[y][x] &lt; 10:\n                        dx = 0\n                    else:\n                        dx = -16\n                    screen.blit( font.render(str(self.plateau[y][x]),1,(255,255,255)) , (70+dx + 144*x , 58 + 144*y) )\n                \n    def play(self):\n        T.mix()\n        pygame.init()\n        screen = pygame.display.set_mode((610, 610))\n        pygame.display.set_caption('Le jeu du Taquin - St\u00e9phane Pasquet - mathweb.fr')\n        green = (9,44,28)\n        marroon = (33,21,3)\n        marroon_light = (47,32,8)\n        running = True\n        \n        \n        while running:\n            screen.fill( green )\n            pygame.draw.rect(screen, marroon, pygame.Rect(10, 10, 585, 585))\n            pygame.draw.rect(screen, marroon_light, pygame.Rect(16, 16, 584, 584))\n            \n            if (self.plateau == array( [ [1,2,3,4], [5,6,7,8] , [9,10,11,12], [13,14,15,0] ] )).all():\n                self.graphicplate(screen, win = True)\n            else:\n                self.graphicplate(screen)\n                \n            \n            # Fermeture de la fen\u00eatre\n            for event in pygame.event.get():\n                if event.type == pygame.QUIT:\n                    running = False\n                if event.type == pygame.KEYDOWN:\n                    if event.key == pygame.K_UP:\n                        self.up()\n                    elif event.key == pygame.K_DOWN:\n                        self.down()\n                    elif event.key == pygame.K_LEFT:\n                        self.left()\n                    elif event.key == pygame.K_RIGHT:\n                        self.right()\n                \n            pygame.display.flip()\n            \n        pygame.quit()\n                  \n        \nif __name__ == \"__main__\":\n    T = Taquin()\n    T.play()<\/pre>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Et voil\u00e0! Pour jouer, il suffit d&rsquo;appuyer sur les fl\u00e8ches du clavier pour faire bouger les cases.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2190 : fl\u00e8che de gauche pour faire bouger la case qui se trouve \u00e0 droite de l&rsquo;espace vide vers la gauche;<\/li>\n\n\n\n<li>\u2192 : fl\u00e8che de droite pour faire bouger la case qui se trouve \u00e0 gauche de l&rsquo;espace vide vers la droite;<\/li>\n\n\n\n<li>\u2191 : fl\u00e8che du haut pour faire bouger la case qui se trouve sous l&rsquo;espace vide vers le haut;<\/li>\n\n\n\n<li>\u2193 : fl\u00e8che du bas pour faire bouger la case qui se trouve au-dessus de l&rsquo;espace vide vers le bas;<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Le_jeu_du_Taquin_en_Python_ameliorations_avec_des_images\"><\/span>Le jeu du Taquin en Python: am\u00e9liorations avec des images<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">N&rsquo;\u00e9tant pas totalement satisfait, j&rsquo;ai souhait\u00e9 am\u00e9liorer l&rsquo;apparence en ins\u00e9rant des images plut\u00f4t que d&rsquo;ins\u00e9rer du texte. Cela donne alors ceci:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-medium\"><a href=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image.png\" data-fancybox=\"gallery\"><img loading=\"lazy\" decoding=\"async\" width=\"286\" height=\"300\" src=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-286x300.png\" alt=\"taquin en Python avec images nombres\" class=\"wp-image-9399\" srcset=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-286x300.png 286w, https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-600x629.png 600w, https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image.png 612w\" sizes=\"auto, (max-width: 286px) 100vw, 286px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\"> Et maintenant que le plus gros des modifications est fait, je peux d\u00e9sormais remplacer les nombres par une image d\u00e9coup\u00e9e:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-medium\"><a href=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-1.png\" data-fancybox=\"gallery\"><img loading=\"lazy\" decoding=\"async\" width=\"286\" height=\"300\" src=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-1-286x300.png\" alt=\"taquin en python avec image\" class=\"wp-image-9400\" srcset=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-1-286x300.png 286w, https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-1-600x629.png 600w, https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/image-1.png 612w\" sizes=\"auto, (max-width: 286px) 100vw, 286px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Pour cette derni\u00e8re version, il m&rsquo;a fallu \u00e9crire un script annexe qui permet de d\u00e9couper mon image enti\u00e8re en 16 cases (dont la derni\u00e8re ne sera pas mise afin de laisser un trou).<\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Vous trouverez dans le dossier compress\u00e9 suivant tout ce qu&rsquo;il faut:<\/p>\n\n\n\n<div class=\"wp-block-file aligncenter\"><a id=\"wp-block-file--media-ea97cafd-dd1b-4328-98ac-df92e7c8306a\" href=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/Taquin.zip\">Taquin<\/a><a href=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/11\/Taquin.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-ea97cafd-dd1b-4328-98ac-df92e7c8306a\">T\u00e9l\u00e9charger<\/a><\/div>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">N&rsquo;h\u00e9sitez pas \u00e0 partager vos remarques et suggestions en laissant un commentaire.<\/p>\n\n\n\n<p class=\"is-style-Paragraph-paragraph wp-block-paragraph\">Et n&rsquo;h\u00e9sitez pas \u00e0 soutenir ce site sur <a href=\"https:\/\/fr.tipeee.com\/mathwebfr\" target=\"_blank\" rel=\"noreferrer noopener\">Tipeee<\/a> si ce que je propose vous satisfait.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n&rsquo;est qu&rsquo;une matrice carr\u00e9e&#8230; Mais graphiquement, cela donne quoi avec pygame ?<\/p>\n","protected":false},"author":1,"featured_media":9386,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[68,140,223,404],"class_list":["post-9384","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-jeu","tag-poo","tag-pygame","tag-taquin"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Le jeu du Taquin en Python - Mathweb.fr<\/title>\n<meta name=\"description\" content=\"Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n&#039;est qu&#039;une matrice carr\u00e9e... Avec pygame, cela donne quoi ?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Le jeu du Taquin en Python - Mathweb.fr\" \/>\n<meta property=\"og:description\" content=\"Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n&#039;est qu&#039;une matrice carr\u00e9e... Avec pygame, cela donne quoi ?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Mathweb.fr\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-23T15:24:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-05T13:49:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/head-articles-python-taquin.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"740\" \/>\n\t<meta property=\"og:image:height\" content=\"198\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"St\u00e9phane Pasquet\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"St\u00e9phane Pasquet\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/\"},\"author\":{\"name\":\"St\u00e9phane Pasquet\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\"},\"headline\":\"Le jeu du Taquin en Python\",\"datePublished\":\"2023-10-23T15:24:29+00:00\",\"dateModified\":\"2023-11-05T13:49:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/\"},\"wordCount\":532,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/head-articles-python-taquin.jpg\",\"keywords\":[\"jeu\",\"poo\",\"pygame\",\"taquin\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/\",\"name\":\"Le jeu du Taquin en Python - Mathweb.fr\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/head-articles-python-taquin.jpg\",\"datePublished\":\"2023-10-23T15:24:29+00:00\",\"dateModified\":\"2023-11-05T13:49:22+00:00\",\"description\":\"Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n'est qu'une matrice carr\u00e9e... Avec pygame, cela donne quoi ?\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/head-articles-python-taquin.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/head-articles-python-taquin.jpg\",\"width\":740,\"height\":198,\"caption\":\"python jeu taquin pygame\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/2023\\\/10\\\/23\\\/le-jeu-du-taquin-en-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Le jeu du Taquin en Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#website\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/\",\"name\":\"Mathweb.fr\",\"description\":\"Math\u00e9matiques, LaTeX et Python\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/#\\\/schema\\\/person\\\/e4d3bb07968238378f0d5052a70dcd69\",\"name\":\"St\u00e9phane Pasquet\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\",\"url\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\",\"contentUrl\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\",\"width\":74,\"height\":77,\"caption\":\"St\u00e9phane Pasquet\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.mathweb.fr\\\/euclide\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-logo-mathweb.webp\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Le jeu du Taquin en Python - Mathweb.fr","description":"Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n'est qu'une matrice carr\u00e9e... Avec pygame, cela donne quoi ?","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/","og_locale":"fr_FR","og_type":"article","og_title":"Le jeu du Taquin en Python - Mathweb.fr","og_description":"Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n'est qu'une matrice carr\u00e9e... Avec pygame, cela donne quoi ?","og_url":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/","og_site_name":"Mathweb.fr","article_published_time":"2023-10-23T15:24:29+00:00","article_modified_time":"2023-11-05T13:49:22+00:00","og_image":[{"width":740,"height":198,"url":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/head-articles-python-taquin.jpg","type":"image\/jpeg"}],"author":"St\u00e9phane Pasquet","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"St\u00e9phane Pasquet","Dur\u00e9e de lecture estim\u00e9e":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#article","isPartOf":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/"},"author":{"name":"St\u00e9phane Pasquet","@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69"},"headline":"Le jeu du Taquin en Python","datePublished":"2023-10-23T15:24:29+00:00","dateModified":"2023-11-05T13:49:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/"},"wordCount":532,"commentCount":2,"publisher":{"@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69"},"image":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/head-articles-python-taquin.jpg","keywords":["jeu","poo","pygame","taquin"],"articleSection":["Python"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/","url":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/","name":"Le jeu du Taquin en Python - Mathweb.fr","isPartOf":{"@id":"https:\/\/www.mathweb.fr\/euclide\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#primaryimage"},"image":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/head-articles-python-taquin.jpg","datePublished":"2023-10-23T15:24:29+00:00","dateModified":"2023-11-05T13:49:22+00:00","description":"Le jeu du Taquin en Python est assez facile \u00e0 impl\u00e9menter. Apr\u00e8s tout, ce n'est qu'une matrice carr\u00e9e... Avec pygame, cela donne quoi ?","breadcrumb":{"@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#primaryimage","url":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/head-articles-python-taquin.jpg","contentUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2023\/10\/head-articles-python-taquin.jpg","width":740,"height":198,"caption":"python jeu taquin pygame"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mathweb.fr\/euclide\/2023\/10\/23\/le-jeu-du-taquin-en-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.mathweb.fr\/euclide\/"},{"@type":"ListItem","position":2,"name":"Le jeu du Taquin en Python"}]},{"@type":"WebSite","@id":"https:\/\/www.mathweb.fr\/euclide\/#website","url":"https:\/\/www.mathweb.fr\/euclide\/","name":"Mathweb.fr","description":"Math\u00e9matiques, LaTeX et Python","publisher":{"@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mathweb.fr\/euclide\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":["Person","Organization"],"@id":"https:\/\/www.mathweb.fr\/euclide\/#\/schema\/person\/e4d3bb07968238378f0d5052a70dcd69","name":"St\u00e9phane Pasquet","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp","url":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp","contentUrl":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp","width":74,"height":77,"caption":"St\u00e9phane Pasquet"},"logo":{"@id":"https:\/\/www.mathweb.fr\/euclide\/wp-content\/uploads\/2025\/06\/cropped-logo-mathweb.webp"}}]}},"_links":{"self":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/posts\/9384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/comments?post=9384"}],"version-history":[{"count":0,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/posts\/9384\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/media\/9386"}],"wp:attachment":[{"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/media?parent=9384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/categories?post=9384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mathweb.fr\/euclide\/wp-json\/wp\/v2\/tags?post=9384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}