define(["util", "whrandom"], function (util, RandomStream) {
  var Randomizer = util.Class({
    constructor: function (seed) {
      this.stream = RandomStream(seed);
    },
    number: function (max) {
      return Math.floor(this.stream() * max);
    },
    pick: function (seq) {
      return seq[this.number(seq.length)];
    },
    pickDist: function (items) {
      var total = 0;
      for (var a in items) {
        if (! items.hasOwnProperty(a)) {
          continue;
        }
        if (typeof items[a] != "number") {
          throw "Bad property: " + a + " not a number";
        }
        total += items[a];
      }
      var num = this.number(total);
      var last;
      for (a in items) {
        if (! items.hasOwnProperty(a)) {
          continue;
        }
        last = a;
        if (num < items[a]) {
          return a;
        }
        num -= items[a];
      }