<?php

class Mouse
{
	const NAME = 'm';
	public $point;
	
	public function getStartPoint()
	{
		$x = mt_rand(1, Field::WIDTH);
		$y = mt_rand(1, Field::HEIGHT);
		
		$this->point = array("x" => $x,"y" => $y);
	}
	
	public function takeStep($field)
	{	
		$y = $this->point["y"];
		$x = $this->point["x"];
		
		$mouseEyes = array();
		
		for ($x; $x < $this->point["x"] + 4; $x++) {
			if ($field[$y][$x] == Cat::NAME) {
				$mouseEyes[] = array($x, $y);
			}
		}
		
		for ($y; $y < $this->point["y"] + 4; $y++) {
			if ($field[$y][$x] == Cat::NAME) {
				$mouseEyes[] = array($x, $y);
			}
		}
		
		for ($x; $x > $this->point["x"] - 4; $x--) {
			if ($field[$y][$x] == Cat::NAME) {
				$mouseEyes[] = array($x, $y);
			}
		}
		
		for ($y; $y > $this->point["y"] - 4; $y--) {
			if ($field[$y][$x] == Cat::NAME) {
				$mouseEyes[] = array($x, $y);
			}
		}
		
	}
}

class Cat
{
	const NAME = 'C';
	public $point;
	
	public function getStartPoint()
	{
		$x = mt_rand(1, 8);
		$y = mt_rand(1, 6);
		
		$this->point = array("x" => $x,"y" => $y);
	}
	
	public function takeStep()
	{
		
	}
}

class Field
{
	const WIDTH = 16;
	const HEIGHT = 20;
	
	public $field;
	
	public function createField()
	{
		for ($y = 0; $y < self::WIDTH; $y++) {
			for ($x = 0; $x < self::HEIGHT; $x++) {
				$field[$y][$x] = ".";
			}
		}
		
		$this->field = $field;
	}
}

class Game
{
	
}

$field = new Field;
$field->createField();

$m1 = new Mouse;
$m1->getStartPoint();
$m1->takeStep($field->field);

foreach ($field->field as $string) {
	echo implode("", $string)."\n";
}
