Accueil > > > LABYRINTHES EN PHP (GD + HTML) GÉNÉRATION + RÉSOLUTION
LABYRINTHES EN PHP (GD + HTML) GÉNÉRATION + RÉSOLUTION
Information sur la source
Description
Voici une classe qui génère et résout des labyrinthes en php le résultat peut être afficher en image/png ou en tableau html.
Pour l'utilisation regardez le fichier index.php
Source
- <?php
- /**
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- set_time_limit(10);
-
- error_reporting(E_ALL);
-
- /*
-
- ---- Générateur et Solveur de Labyrinthes ----
-
-
-
- fichier gen.fusion.class.php
-
- Genere un labyrinthe par fusion.
-
- CF : article sur wikipedia.
-
-
-
- */
-
-
-
- /* Codage de class type : php5 */
-
-
-
- define('IDX', 3);
-
-
-
- /* Sud et Est ( bas et droite) */
-
- define('S', 0);
-
- define('E', 1);
-
- define('N', 2);
-
- define('O', 3);
-
-
-
- require 'labyrinthe.class.php5';
-
- require 'solveur.class.php5';
-
-
-
- require 'genFusion.class.php5';
-
- require 'genExplo.class.php5';
-
-
-
- require 'solveDAG.class.php5';
-
-
-
-
-
- ?>
-
- <?php
-
- if(isset($_POST['choix']))
-
- {
-
-
-
- if($_POST['taille'] < 1000)
-
- $m = $n = intval($_POST['taille']);
-
- elseif($_POST['taille'] == 1020){
-
- $m = 10;
-
- $n = 20;
-
- }
-
- elseif($_POST['taille'] == 2030){
-
- $m = 30;
-
- $n = 20;
-
- }
-
- else
-
- die('TAILLE NON CORRECTE');
-
-
-
- $w_case = intval($_POST['w_case']);
-
- if($_POST['method'] == 'fusion')
-
- $class = new genFusion($m, $n, $w_case);
-
- elseif($_POST['method'] == 'explo')
-
- $class = new genExplo($m, $n, $w_case);
-
-
-
- $time_gene = microtime(1);
-
- $laby = $class->generer();
-
- if(empty($_POST['resoudre']))
-
- {
-
- if($_POST['affichage'] == 'html')
-
- {
-
- $class->laby2html($laby, $time_start);
-
- }
-
- else
-
- $class->laby2png($laby);
-
-
-
- }
-
- else
-
- {
-
- $solve = new solveDAG($laby, $m, $n);
-
- $time_res = microtime(1);
-
- $solution = $solve->resoudre();
-
- if($_POST['affichage'] == 'html')
-
- {
-
- $class->laby2html($laby, $solution, $time_gene, $time_res);
-
- }
-
- else
-
- $class->laby2png($laby, $solution);
-
- }
-
- }
-
- else
-
- {
-
- ?>
-
- <form action="" method="post">
-
- <fieldset>
-
- <p><strong>Optimisation en cours</strong></p>
-
- <legend>Methode de génération</legend>
-
- <label for="fusion">Fusion</label><input type="radio" name="method" value="fusion" /><br />
-
- <label for="explo">Exploration exaustive</label><input type="radio" name="method" value="explo" id="explo" />
-
- </fieldset>
-
- <fieldset>
-
- <legend>Methode d'affichage</legend>
-
- <label for="png">Image PNG</legend><input id="png" type="radio" name="affichage" value="png" /><br />
-
- <label for="html">Tableau HTML (affiche le tps d'execution)</legend><input id="html" type="radio" name="affichage" value="html" />
-
- </fieldset>
-
- <fieldset>
-
- <legend>Taille</legend>
-
- <label for="10">10*10</label><input id="10" type="radio" name="taille" value="10" /><br />
-
- <label for="20">20*20</label><input id="20" type="radio" name="taille" value="20" /><br />
-
- <label for="40">40*40</label><input id="40" type="radio" name="taille" value="40" /><br />
-
- <label for="45">45*45</label><input id="45" type="radio" name="taille" value="45" /><br />
-
- <label for="1020">10*20</label><input id="1020" type="radio" name="taille" value="1020" /><br />
-
- <label for="2030">30*20</label><input id="2030" type="radio" name="taille" value="2030" /><br />
-
- </fieldset>
-
- <fieldset>
-
- <legend>Taille des cases</legend>
-
- <select name="w_case">
-
- <option value="10">10</option>
-
- <option value="15">15</option>
-
- <option value="20" selected="selected">20</option>
-
- <option value="30">30</option>
-
- <option value="50">50</option>
-
- <option value="70">70</option>
-
- </select>
-
- </fieldset>
-
- <fieldset>
-
- <legend>Resolution</legend>
-
- <label for="resoudre">Resoudre ?</label><input type="checkbox" name="resoudre" id="resoudre" checked="checked" /><br />
-
- <label for="DAG">Methode DAG</label><input type="radio" name="methode_res" id="DAG" selected="selected" />
-
- </fieldset>
-
- <input type="submit" name="choix" value="Créer" />
-
- </form>
-
- <?php
-
- }
-
- ?>
<?php
/**
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
set_time_limit(10);
error_reporting(E_ALL);
/*
---- Générateur et Solveur de Labyrinthes ----
fichier gen.fusion.class.php
Genere un labyrinthe par fusion.
CF : article sur wikipedia.
*/
/* Codage de class type : php5 */
define('IDX', 3);
/* Sud et Est ( bas et droite) */
define('S', 0);
define('E', 1);
define('N', 2);
define('O', 3);
require 'labyrinthe.class.php5';
require 'solveur.class.php5';
require 'genFusion.class.php5';
require 'genExplo.class.php5';
require 'solveDAG.class.php5';
?>
<?php
if(isset($_POST['choix']))
{
if($_POST['taille'] < 1000)
$m = $n = intval($_POST['taille']);
elseif($_POST['taille'] == 1020){
$m = 10;
$n = 20;
}
elseif($_POST['taille'] == 2030){
$m = 30;
$n = 20;
}
else
die('TAILLE NON CORRECTE');
$w_case = intval($_POST['w_case']);
if($_POST['method'] == 'fusion')
$class = new genFusion($m, $n, $w_case);
elseif($_POST['method'] == 'explo')
$class = new genExplo($m, $n, $w_case);
$time_gene = microtime(1);
$laby = $class->generer();
if(empty($_POST['resoudre']))
{
if($_POST['affichage'] == 'html')
{
$class->laby2html($laby, $time_start);
}
else
$class->laby2png($laby);
}
else
{
$solve = new solveDAG($laby, $m, $n);
$time_res = microtime(1);
$solution = $solve->resoudre();
if($_POST['affichage'] == 'html')
{
$class->laby2html($laby, $solution, $time_gene, $time_res);
}
else
$class->laby2png($laby, $solution);
}
}
else
{
?>
<form action="" method="post">
<fieldset>
<p><strong>Optimisation en cours</strong></p>
<legend>Methode de génération</legend>
<label for="fusion">Fusion</label><input type="radio" name="method" value="fusion" /><br />
<label for="explo">Exploration exaustive</label><input type="radio" name="method" value="explo" id="explo" />
</fieldset>
<fieldset>
<legend>Methode d'affichage</legend>
<label for="png">Image PNG</legend><input id="png" type="radio" name="affichage" value="png" /><br />
<label for="html">Tableau HTML (affiche le tps d'execution)</legend><input id="html" type="radio" name="affichage" value="html" />
</fieldset>
<fieldset>
<legend>Taille</legend>
<label for="10">10*10</label><input id="10" type="radio" name="taille" value="10" /><br />
<label for="20">20*20</label><input id="20" type="radio" name="taille" value="20" /><br />
<label for="40">40*40</label><input id="40" type="radio" name="taille" value="40" /><br />
<label for="45">45*45</label><input id="45" type="radio" name="taille" value="45" /><br />
<label for="1020">10*20</label><input id="1020" type="radio" name="taille" value="1020" /><br />
<label for="2030">30*20</label><input id="2030" type="radio" name="taille" value="2030" /><br />
</fieldset>
<fieldset>
<legend>Taille des cases</legend>
<select name="w_case">
<option value="10">10</option>
<option value="15">15</option>
<option value="20" selected="selected">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="70">70</option>
</select>
</fieldset>
<fieldset>
<legend>Resolution</legend>
<label for="resoudre">Resoudre ?</label><input type="checkbox" name="resoudre" id="resoudre" checked="checked" /><br />
<label for="DAG">Methode DAG</label><input type="radio" name="methode_res" id="DAG" selected="selected" />
</fieldset>
<input type="submit" name="choix" value="Créer" />
</form>
<?php
}
?>
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Bug EasyPHP d'urgence !!! [ par Clem ]
Je pose ce message car il y a plus de chances ici que sur le forum easyphp.J'ai un bug avec easyphp. Vous avez certainemant remarqué qu'il y a un bout
Bug EasyPHP d'urgence !!! [ par Clem ]
Je pose ce message car il y a plus de chances ici que sur le forum easyphp.J'ai un bug avec easyphp. Vous avez certainemant remarqué qu'il y a un bout
Récupérer le résultat d'une requète pour l'afficher dans un tableau??? [ par DJ'Ska & Dreams... ]
Mon problème est le suivant: j'arrive à me connecter à ma base mySQL, lorsque j'execute une requète et que je souhaite afficher mes résultats, mes rés
Afficher les données dans un tableau ? [ par inceV ]
Contenant 2 lignes et 1 seule cellule :c'est à dire :- 1ère ligne où je veux afficher le titre de l'article par exemple,-2ème ligne où je veux affiche
Tableau......Help [ par benett ]
Bonjour à tous,comment peut-on cacher une cellule dans un tableau en cliquant sur un lien, et comment faire l'inverse également toujours via le même p
filtrer un tableau URGENT [ par flyersy ]
je récupère un résultat MySQL dans un tableau1 dont une des colonne contient un identifiant et une autre une chaîne "chem" de type 1,52,4,8. Je concat
générer des miniatures avec gd 1.6 [ par vegetaline ]
muhaha alors là c'est rigolo, un super défi pour les programmeurs fous!ok j'ai le code pour générer des miniatures grâce au php, mais ça marche qu'ave
comment afficher sous forme de tableau [ par Xime ]
bonjourvoila j'aimerais savoir comment afficher mes données que je recupere de ma base de données sous forme de tableau (la taille sera en fonction du
tri tableau 2 dimensions [ par lebobby ]
Bonjour je voudrais savoir comment je pourrais faire pour trier ce tableau :$tab[0]=array("i"=>"23", "c" => "rge", "date" =>'2002-08-03 12:00
tableau genere automatiquement avec mysql [ par maivg ]
bonjoursvoila je cherche un script pour genere un tableau de 4 sur 5 avec ma base de donne qui ne contient qu'un seul champs.help helpmerci et A+
|
Derniers Blogs
[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg [MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|