import sys
sys.dont_write_bytecode=True
from table import *

class Model(Charmed):
  "Information about decision,objective pairs."
  def __init__(i):
    i.t = Table()
    for x in i.has():
      i.t.has(x)
  def name(i): return i.__class__.__name__
  def valid(i,lst) : return True
  def empty(i):
    return [None] * len(i.t.columns)
  def decisions(i,repeats=The.model.repeats): 
    for _ in range(repeats):
      tmp = i.empty()
      for col in i.t.indep:
        tmp[col.pos] = col.any()
      if i.valid(tmp):
        return tmp
    return None
  def get(i,lst,x) : return lst[i.t.at(x)]
  def put(i,lst,x,y) : lst[i.t.at(x)] = y 
  def seen(i,lst):
    i.score(lst)
    i.t.seen(lst)
    return lst
  def any(i):
    new = i.decisions()
    if new:
      return i.seen(new)
 
