";
// let o == cat
$o = "
";
if (($rows >= 4) && ($columns >= 4)) {
$this->rows = $rows;
$this->columns = $columns;
} else {
$this->rows = 6;
$this->columns = 7;
}
if ($s_layout) {
$this->layout = unserialize($s_layout);
} else {
for($i = 0; $i < $rows; $i++) {
for($j = 0; $j < $columns; $j++) {
$tmp[$j] = ' ';
}
$this->layout[] = $tmp;
}
/*
$this->layout = array (
array (' ', ' ', ' ',' ', ' ', ' ',' '),
array (' ', ' ', ' ',' ', ' ', ' ',' '),
array (' ', ' ', ' ',' ', ' ', ' ',' '),
array (' ', ' ', ' ',' ', ' ', ' ',' '),
array (' ', ' ', ' ',' ', ' ', ' ',' '),
array (' ', ' ', ' ',' ', ' ', ' ',' '),
);
*/
/*
$this->layout = array (
array (" ", " ", " "," ", " ", " ", " "),
array (" ", " ", " "," ", " ", " ", " "),
array (" ", " ", " "," ", " ", " ", " "),
array (" ", " ", " "," ", " ", " ", " "),
array (" ", " ", "$o"," ", "$x", "$o", " "),
array (" ", "$x", "$x","$o", "$o", "$x", "$o"),
);
*/
}
}
function pick_first() {
$i = rand(0,1);
if ($i == 0) {
$this->turn = 'cat';
}
if ($i == 1) {
$this->turn = 'dog';
}
}
function print_layout() {
prethis($this->layout);
}
function update() {
// update array
$column = (int) $_POST["{$_POST['s_turn']}_move"];
// put at bottom of array
$i_key = $this->rows - 1; // number of rows
$i_sent = 1;
while ($i_sent > 0) {
if ($this->layout[$i_key][$column] == ' ') {
$this->layout[$i_key][$column] = "\n";
$i_sent = 0;
}
if ($i_key == 0) {
$i_sent = 0;
}
$i_key--;
}
if ($_POST['s_turn'] == 'dog') {
$this->turn = 'cat';
}
if ($_POST['s_turn'] == 'cat') {
$this->turn = 'dog';
}
}
function display() {
$columns = $this->columns;
// $s_display .= "rows: {$this->rows} columns: {$this->columns}
\n";
$s_display .= "
";
if (IsColumnFilled($this->rows, $i, $this->layout)) {
$s_display .= " ";
} else {
$s_display .= "";
}
// $s_display .= "(" . ($this->layout[$i]) . ")\n";
$s_display .= " | \n";
}
$s_display .= "
| \n"; $s_display .= $item; $s_display .= " | \n"; } $s_display .= "