mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 07:00:20 +00:00 
			
		
		
		
	Add method to get random bias
This commit is contained in:
		
							parent
							
								
									11475ea4af
								
							
						
					
					
						commit
						0b367a4542
					
				@ -5909,4 +5909,23 @@ public static class BiasCatalog
 | 
			
		||||
        { IMPLICIT_STEREOTYPES.Id, IMPLICIT_STEREOTYPES },
 | 
			
		||||
        { IMPLICIT_ASSOCIATIONS.Id, IMPLICIT_ASSOCIATIONS },
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    public static Bias GetRandomBias(ref IList<int> usedBias)
 | 
			
		||||
    {
 | 
			
		||||
        if(usedBias.Count >= ALL_BIAS.Count)
 | 
			
		||||
            usedBias.Clear();
 | 
			
		||||
        
 | 
			
		||||
        int randomBiasIndex;
 | 
			
		||||
        lock (RANDOM)
 | 
			
		||||
        {
 | 
			
		||||
            randomBiasIndex = RANDOM.Next(0, ALL_BIAS.Count);
 | 
			
		||||
            while(usedBias.Contains(randomBiasIndex))
 | 
			
		||||
                randomBiasIndex = RANDOM.Next(0, ALL_BIAS.Count);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        usedBias.Add(randomBiasIndex);
 | 
			
		||||
        return ALL_BIAS.Values.ElementAt(randomBiasIndex);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private static readonly Random RANDOM = new();
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user