I wonder if anyone could help me with this little problem. I am creating a grid based on some user defined dimentions. I have that working just fine. Now, I want the use to be able to enter points one the grid and have them show up... this is where I am getting hung up.
An example can be seen here in the design stages: http://worldclassdesigns.com/AI/setup.php
Example:
If the user has entered the following info:
Grid width (in number of blocks): 7 blocks
Grid height (in number of blocks): 3 blocks
it would print out like this.
* * * * * * * * *
* 0 0 0 0 0 0 0 *
* 0 0 0 0 0 0 0 *
* 0 0 0 0 0 0 0 *
* * * * * * * * *
This is a 7 by 3 grid with a surrounding box of *'s I will replace the 0's and #'s with pictures when this is completed.
now the user can enter as many places to put *'s as they want. So it might look like this:
* * * * * * * * *
* 0 0 0 0 0 0 0 *
* 0 0 0 * * 0 0 *
* 0 0 0 0 0 0 0 *
* * * * * * * * *
The user has entered 2 stars at the locations:
1st * i=4 and j=2
2nd* i=5 and j=2
This is where Im having the trouble. I need the code to print out the grid with the *'s in the selected areas.
Code:
I am currently working ont he bottom so yes, there are problems with it. Part one asks the user for the grid dimensions and number of obstacles. Part two asks for the locations of each obstacle. And I need part three to print the grid with the obstacles int eh correct place.
Please please please help,
-JRW
An example can be seen here in the design stages: http://worldclassdesigns.com/AI/setup.php
Example:
If the user has entered the following info:
Grid width (in number of blocks): 7 blocks
Grid height (in number of blocks): 3 blocks
it would print out like this.
* * * * * * * * *
* 0 0 0 0 0 0 0 *
* 0 0 0 0 0 0 0 *
* 0 0 0 0 0 0 0 *
* * * * * * * * *
This is a 7 by 3 grid with a surrounding box of *'s I will replace the 0's and #'s with pictures when this is completed.

now the user can enter as many places to put *'s as they want. So it might look like this:
* * * * * * * * *
* 0 0 0 0 0 0 0 *
* 0 0 0 * * 0 0 *
* 0 0 0 0 0 0 0 *
* * * * * * * * *
The user has entered 2 stars at the locations:
1st * i=4 and j=2
2nd* i=5 and j=2
This is where Im having the trouble. I need the code to print out the grid with the *'s in the selected areas.
Code:
PHP Code:
<?php
// ######################################## STEP 1 #
if ((!$step) || ($step==1)) {
global $grid_length, $grid_width, $number_obsticals, $grid_name, $PHP_SELF;
?>
Welcome to the A.I. Path Planner. <br>
Step 1 - Grid Setup<br>
Please fill out the form below. The grid name will
be used to pull up the project at a later date.<br> The grid
length and width is measured in number of blocks and will determine the area of
the <br> grid. The number of obstacles will be used
in a future step, but it refers to the number of <br>
blocks that will be taken up by obstacles.<br>
<form method="GET" action="setup.php">
<input type="hidden" name="step" value="2">
<table border="0" width="500" cellspacing="1" cellpadding="0">
<tr>
<td width="278">Enter grid width (in number of blocks): </td>
<td width="212"><input type="text" name="i" size="3"> blocks</td>
</tr>
<tr>
<td width="278">Enter grid height (in number of blocks): </td>
<td width="212"><input type="text" name="j" size="3"> blocks</td>
</tr>
<tr>
<td width="278">Enter number of obstacles: </td>
<td width="212"><input type="text" name="number_obstacles" size="3"> obstacles</td>
</tr>
<tr>
<td width="278"><font size="1"> </font></td>
<td width="212"><font size="1"> </font></td>
</tr>
<tr>
<td width="278"></td>
<td width="212"><input type="submit" value="Step 2"><input type="reset" value="Reset"></td>
</tr>
</table>
</form>
<?php
}
// ######################################## STEP 2 #line53
if ($step==2) {
if ((!$i) || (!$j) || (!$number_obstacles)) {
echo "You have not filled out every field. Please <a href='http://worldclassdesigns.com/AI/setup.php?step=1'>GO BACK</a> and fill out all the fields.";
} else {
?>
<table border="0" width="500" cellspacing="1" cellpadding="0">
<tr>
<td width="278">Grid width (in number of blocks): </td>
<td width="212"><? echo "$i"; ?> blocks</td>
</tr>
<tr>
<td width="278">Grid height (in number of blocks): </td>
<td width="212"><? echo "$j"; ?> blocks</td>
</tr>
<tr>
<td width="278">Number of obstacles: </td>
<td width="212"><? echo "$number_obstacles"; ?> obstacles</td>
</tr>
<tr>
<td width="278"><font size="1"> </font></td>
<td width="212"><font size="1"> </font></td>
</tr>
</table>
<?
}
echo "The grid will look like this:<br>";
// create grid
$it = $i + 2;
$jt = $j + 2;
for($counter=0; $counter<$it; $counter++)
{
echo " * ";
}
echo "<br>";
$temp = 0;
while($temp != $j) {
echo " * ";
for($counter=0; $counter<$i; $counter++)
{
echo "0";
}
echo " * <br>";
$temp++;
}
for($counter=0; $counter<$it; $counter++)
{
echo " * ";
}
echo "<br><br>Please enter the coordinates of the obsticles in the i / j format.<br>";
?>
<form method="GET" action="setup.php">
<input type="hidden" name="step" value="3">
<input type="hidden" name="number_obstacles" value="<? echo "$number_obstacles" ?>">
<input type="hidden" name="i" value="<? echo "$i" ?>">
<input type="hidden" name="j" value="<? echo "$j" ?>">
<table border="0" width="500" cellspacing="1" cellpadding="0">
<tr>
<td width="278">Enter starting point coordinates: </td>
<td width="106" align="right"><input type="text" name="start_i" size="3"> i</td>
<td width="106" align="right"><input type="text" name="start_j>" size="3"> j</td>
</tr>
<tr>
<td width="278">Enter ending point coordinates: </td>
<td width="106" align="right"><input type="text" name="end_i" size="3"> i</td>
<td width="106" align="right"><input type="text" name="end_j" size="3"> j</td>
</tr>
<?
for($o=0; $o<$number_obstacles; $o++)
{
?>
<tr>
<td width="278">Enter obsticle <?=$o?> coordinates: </td>
<td width="106" align="right"><input type="text" name="obstacle_i<?=$o?>" size="3"> i</td>
<td width="106" align="right"><input type="text" name="obstacle_j<?=$o?>" size="3"> j</td>
</tr>
<?
}
?>
<tr>
<td width="278"><font size="1"> </font></td>
<td width="106"><font size="1"> </font></td>
<td width="106"><font size="1"> </font></td>
</tr>
<tr>
<td width="500" colspan="3">
<p align="right"><input type="submit" value="Step 3"><input type="reset" value="Reset"></p>
</td>
</table>
</form>
<?
}
// ######################################## STEP 3 #
if ($step==3) {
//create grid with start, end, and obstacles.
$it = $i + 2;
$jt = $j + 2;
//create top border
for($counter=0; $counter<$it; $counter++)
{
echo " * ";
}
echo "<br>";
//create middle sections of grid
$temp = 0;
while($temp != $j) {
echo " * ";
if(
for($counter=0; $counter<$i; $counter++)
{
for($0_counter=0; $o_counter<$number_obstacles, $o_counter++)
{
$present_obstacle = "obstacle_i" . $o_counter;
if($present_obstacle
echo "0";
}
echo " * <br>";
$temp++;
}
}
?>
Please please please help,
-JRW
Comment