/*--------------------------------------------------------------------
 * FICHERO:       Azar.h
 * OBJETIVO:      Definir el objeto "Azar"
 * IDENTIFICADOR: Azr
 * AUTOR:         Pedro Reina
 * FECHA:         J.13.7.1995
 *------------------------------------------------------------------*/

/*--------------------------------------------------------------------
 * Funciones pblicas
 *
 *   Azr_Inicia()            Azar.h
 *   Azr_Entero()            Azar.h
 *------------------------------------------------------------------*/

/*--------------------------------------------------------------------
 * Funciones conocidas
 *
 *   Ninguna
 *------------------------------------------------------------------*/

/*--------------------------------------------------------------------
 * Funciones privadas
 *
 *   Ninguna
 *------------------------------------------------------------------*/

#ifndef _AZAR_
#define _AZAR_

/*--------------------------------------------------------------------
 * Ficheros de cabecera
 *------------------------------------------------------------------*/

#include "General.h"
#include <stdlib.h>         /*  rand()  srand()                     */

#ifdef OLIMPO_PC
#include <bios.h>           /*  biostime()                          */
#endif

#ifdef OLIMPO_QL
#include <qlib.h>           /*  mt_rclck()                          */
#endif

/*--------------------------------------------------------------------
 * Definicin de macros constantes
 *------------------------------------------------------------------*/

    /* Ninguno */

/*--------------------------------------------------------------------
 * Definicin de tipos
 *------------------------------------------------------------------*/

   /* Ninguno */

/*--------------------------------------------------------------------
 * Variables globales
 *------------------------------------------------------------------*/

   /* Ninguna */

/*--------------------------------------------------------------------
 * Declaracin de funciones
 *------------------------------------------------------------------*/

   /* Ninguna */

/*--------------------------------------------------------------------
 * Definicin de macros funciones
 *------------------------------------------------------------------*/

/*--------------------------------------------------------------Olimpo
 * MACRO:    Azr_Inicia ()
 * OBJETIVO: Iniciar el generador con un nmero aleatorio
 * ENTRADAS: Ninguna, se lee el reloj del sistema
 * SALIDAS:  Ninguna
 * EJEMPLO:  Azr_Inicia ()
 *------------------------------------------------------------------*/

#ifdef OLIMPO_PC
#define Azr_Inicia()  srand(biostime(0,0L))
#endif

#ifdef OLIMPO_QL
#define Azr_Inicia()  srand((unsigned)mt_rclck())
#endif

/*--------------------------------------------------------------Olimpo
 * MACRO:    Azr_Entero ()
 * OBJETIVO: Obtener un nmero entero aleatorio en un 
 *           rango especificado
 * ENTRADAS: Los valores ms bajo y ms alto admitidos
 * SALIDAS:  Un nmero entero entre los extremos 
 *           (ambos inclusive)
 * EJEMPLOS: Azr_Entero (0,100)
 *           Azr_Entero (-10,10)
 *------------------------------------------------------------------*/

#define Azr_Entero(a,b)  ((a)+(rand()%((b)-(a)+1)))

#endif  /* _AZAR_ */