/RandomChoice

An simple library for making those hard (well just random) choices

Primary LanguageC#

A little helper library that given an (optionaly weighted) list of methods chooses one at random. Useful if you are making a game or something I guess.

	//add actions to the selector
	var selector = RandomSelector
			.AddAction(() => { doSomething(); })
			.AddAction(() => { doSomeOtherThing(); });

	selector.Choose(); //randomly picks an action to run

You can also optionally weight each action.

	//add actions to the selector (must add up to 1.0)
	var selctor = RandomSelector
			.AddAction(0.7, () => { probablyDoThis(); })
			.AddAction(0.2, () => { maybeDoThis(); })
			.AddAction(0.1, () => { smallChanceOfThis(); });

	selector.Choose(); //randomly picks an action to run