#include <iostream>
#include "person.h"
#include "city.h"
#include "graph.h"

bool Graph::tick() {
  cout << "TICK" << endl;

  // make choices
  City* ec;
  if (m_evader != NULL) ec = evader_choice(m_evader,this);
  vector<City*> pc(m_pursuers.size());
  int i;
  for (i = 0; i < m_pursuers.size(); i++) {
    pc[i] = pursuer_choice(m_pursuers[i],this);
  }

  // move them
  if (m_evader != NULL) m_evader->move(ec);
  for (i = 0; i < m_pursuers.size(); i++) {
    m_pursuers[i]->move(pc[i]);
    if (m_evader != NULL && m_pursuers[i]->location() == m_evader->location()) {
      cout << m_pursuers[i]->name() << " has caught " << m_evader->name() << " in " 
           << m_pursuers[i]->location()->name() << endl;
      // evader has been caught
      return false;
    }
  }
  
  // evader safe for another turn
  return true;
}



