// - - - - - - - - - - - - - - - - - - - - - - - -
// File: creature.h                               |
// Purpose: provides interface for class Creature |
// Author: Taivo Lints, Estonia                   |
// Date: May, 2003                                |
// Copyright: see copyright.txt                   |
// - - - - - - - - - - - - - - - - - - - - - - - -

#ifndef CREATURE_H
#define CREATURE_H

#include "ann/neuralnetwork.h"
#include "allegro.h"
#include <vector>
using namespace std;

class Creature {       // Represents a moving creature with
                       // light intensity sensors.


  public:

    // ******************************
    // * Construction & Destruction *
    // ******************************

    Creature(BITMAP* pArena, int color_of_icircle, int color_of_ocircle,
               int start_of_gradient, char* conf_file);
                    // Creature constructor. Needs a pointer to the bitmap this
                    // creature will "live" on. Also needs the palette colors
                    // for inner and outer circles of sensors, start of light's
                    // color gradient on palette, and a configuration file
                    // for neural network.

    Creature(const Creature& rC);  // Creature copy-constructor.

    Creature& operator=(const Creature& rC);  // Operator overloading.

    ~Creature();       // Creature destructor.


    // **************************
    // * Parameters & variables *
    // **************************

    double x,                // Position of creature.
           y;

    double speed_x,          // Speed of creature.
           speed_y;

    double speedup_factor;   // Speeds up creatures movement.
          
    int color_of_icircle,    // Palette colors for inner and outer circles
        color_of_ocircle;    // of sensors.

    bool flag_incor_net;     // Indicates that neural network is incorrect
                             // (configuration file is missing or the numbers
                             // of inputs and outputs are wrong).

    // *************
    // * Functions *
    // *************

    void update();           // Updates creature's position (except when
                             // flag_incor_net is true).

    void draw();             // Draws creature on the bitmap.

    void load_network(char* config_file); // Loads a new network into creature.


  // *****************
  // * Private stuff *
  // *****************

  // You can't use that stuff from outside code.

  private:

    BITMAP* pArena;          // A pointer to the bitmap this creature
                             // "lives" on.

    NeuralNetwork* pNet;     // A pointer to the neural network that controls
                             // creature's movement.

    vector<double> v_dbl_inps;  // A vector for feeding sensor information
                                // into neural network.

    vector<double> v_dbl_outputs; // A vector for getting control values from
                                  // neural network.

    class Position {         // Just a useful class for storing the
      public:                // position of something (e.g. sensors).
        int x,
            y;
    };

    vector<Position> vPositions;  // Relative positions of sensors.

    int start_of_gradient;   // Start of light's color gradient on palette.

};

#endif // CREATURE_H