
import sys
import cairo
import math

from random import random # for myfn

import widgets

from widgets.texteditor import TextEditor
from core.mathlib import MathLib
from core.world import TheWorld
from ontology.thing import Thing


class LivingThing(Thing):
  
  def __init__(self):
    Thing.__init__(self)

  def receives__left(self, value = random() * 5.0):
    if self.rotation < 0:
      self.rotation = 359.0
    self.rotation -= value
  left = receives__left


  def receives__right(self, value = random() * 5.0):
    if self.rotation > 359.0:
      self.rotation = 0.0
    self.rotation += value
  right = receives__right


  def grow(self, value = 0.0001):
    self.width += value
    self.height += value


  def shrink(self, value = 0.0001):
    self.width -= value
    self.height -= value


  def eat(self):
    pass


  def sense(self):
    """Returns a list of inhabitants within a predefined constant ratio"""
    # Should we do tuples ?
    # First element is inhabitant, second element is heading+distance ?
    
    pass


  def measure(self, inhabitant):
    # returns distance to inhabitant
    # Return a tuple with distance/heading ?
    pass
  
  
  def reproduce(self):
    pass
  
  