self = nil;

direction = 1;

enemy = nil;

-- zmienia cel na wroga
function onDamage(other, amount)
	if (other != self) then
		enemy = other;
	end;
end

-- losowo zmienia kierunek, 4% szans
function aiGetMove()

	if (enemy == nil) then
	{

		local temp = math.random();
		local fire = 0;

		if (temp > 0.95) then
			direction = 1 - direction;
		end
	}
--	else
--	{
--		local sx, sy = 0, 0; -- getWormPos(self);
--		local ex, ey = getWormPos(enemy);
--
--		if (ex < sx) then
--			direction = 1;
--		else
--			direction = 0;
--		end
--	}
	end

	return (8 * direction + 16 * (1 - direction));
end

