/*

CLASS {NATIVE_Random|_CSharp}, NATIVE:

*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public class AL4_random
{

    public static List<Random> All_random = new List<Random>();
    
    public static int New_random_object()
    {
    	if (All_random.Count() == 0)
    		All_random.Add(null);
        int h = All_random.LastIndexOf(null);
        if (h <= 0)
        {
            h = All_random.Count();
            All_random.Add(null);
        }
        All_random[h] = new Random();
        return h;
    }
    
    public static void Release_random_object(int H)
    {
    	if (H == 0) return;
        All_random[H] = null;
        while (All_random.Count() > 0 && All_random[All_random.Count()-1] == null)
            All_random.RemoveAt(All_random.Count()-1);
    }
    
    public static void Random_object_set_seed(int H, int Seed)
    {
    	if (H == 0) return;
        All_random[H] = new Random(Seed);
    }
    
    public static int Random_object_next_in_range(int H, int Max)
    {
    	if (H == 0) return 0;
        Random R = All_random[H];
        if (Max < 0) Max = 0;
        return R.Next(Max);
    }
    
    public static double Random_object_probable_value(int H)
    {
    	if (H == 0) return 0;
        Random R = All_random[H];
        return R.NextDouble();
    }
    
/*

CONST STR:
    NATIVE_Random_import = ""

    NATIVE_new_random_object = @
    "    RESULT = AL4_random.New_random_object();" 
                
    NATIVE_release_random_object = @
    "   AL4_random.Release_random_object((int)X_Handle);" 
    
    NATIVE_Set_seed = @
    "    AL4_random.Random_object_set_seed((int)X_Handle, (int)X_Seed);" 
        
    NATIVE_Next = @
    "    RESULT = AL4_random.Random_object_next_in_range("
    "		(int)X_Handle, (int)X_Max);"
        
    NATIVE_Probable = @
    "    RESULT = AL4_random.Random_object_probable_value((int)X_Handle);"
    
    .
        
*/

}

/*
END
*/

