//////////////////////////////////////////////////////////////////////////////
//
// File: school.h
//
// Purpose: This is the interface for the School class.
//
// Authors:
//   txe  Travis Emmitt
//
// Modifications:
//   21-APR-1998  txe  Initial creation
//   22-APR-1998  txe  Added session_least, match_least
//   23-APR-1998  txe  Using static debug, changed constructor
//   24-APR-1998  txe  Added FindBestArch(), FindBestWeights()
//
//////////////////////////////////////////////////////////////////////////////

#ifndef SCHOOL_H
#define SCHOOL_H

#include "debug.h"
#include "game.h"
#include "nn_arch.h"
#include "nplayer.h"

#define BAR_LEN                 50
#define DEFAULT_LOSS_RATE_GOAL  30
#define DEFAULT_MUTATION_RATE   0.2
#define NUM_PERIODS             10
#define LOSS_RATE_THRESHOLD     0

class School : public Game {
private:
  Arch *arch;		           // NeuNet architecture
  Arch *best_arch;	           // best architecture so far
  char  best_arch_file[MAX_LEN+1]; // name of temporary best arch file
  float best_loss_rate;            // best loss rate of all sessions
  char  best_wts_file[MAX_LEN+1];  // for saving nn state
  int   finding_arch;              // if true, looking for best arch
  int   losses[NUM_PERIODS];       // number of losses (per period)
  float loss_rate_goal;            // loss rate goal (if here, we stop school)
  int   match;                     // match number
  float mutation_rate;             // rate at which arch mutates
  int   num_games;	           // number of games per match
  int   num_matches;               // number of matches per session
  int   session;                   // session number
  NeuralPlayer *student;           // student (must be a NeuralPlayer)
  
  void  PrintLossBar ();
  float RunSession   (int num_matches, int num_games); // returns loss rate
  
public:
  School (char *name, char *players_file, char *rules_file, char *best_root);
  int  FindBestArch    (int num_sessions, int num_matches, int num_games);
  int  FindBestWeights (int num_matches, int num_games);
  void SetLossRateGoal (float loss_rate_goal);
  void SetMutationRate (float mutation_rate);
};

#endif

//////////////////////////////////////////////////////////////////////////////





















