<?php error_reporting(E_ALL ^ E_NOTICE); require 'Maze.php'; require 'AStar.php'; $maze = new Maze(); $aStar = new AStar(); $w = $_POST['w'] ? $_POST['w'] : 6; // 迷宫宽 $h = $_POST['h'] ? $_POST['h'] : 6; // 迷宫高 $maze->set($w, $h); $maze->create(); $grids = $maze->get(); // 寻路 $aStar->set($w, $h, $grids); $path = $aStar->search(0, $w * $h - 1); // 从零开始找到35 // 画迷宫方法 function div($x, $y, $v) { global $w, $h, $path; //if ( $y > 4 ) $v = 0; $k = $y * $w + $x; //if ( array_key_exists($k, $this->_enable) ) { //echo "<div class=\"grid cell_enable_{$this->_enable[$k]}\" style=\""; //} else { echo "<div class=\"grid cell_{$v}\" style=\""; //} echo 'top:' . 34 * $y . 'px;'; echo 'left:' . 34 * $x . 'px;';