public Player(IRandom random) { Health = 10; Attack = 3; Cargo = 1; Nature = random.Get(NatureUpperBound); }
/// <summary> /// Get free position on the field. If field is full , throw InvalidOperationException. /// </summary> private Position GetFreePosition(Field field) { if (field.HasFreeSpace == false) { throw new InvalidOperationException("Field has no free space"); } Position newPosition; do { newPosition = new Position(_random.Get(field.Width), _random.Get(field.Height)); } while (_validator.PositionIsTaken(field, newPosition)); return(newPosition); }
public async Task <HandGesture> GetGesture() { return(await Task.Factory.StartNew <HandGesture>(() => { // Fake some thinking time var r = _Random.Get(3); return (HandGesture)r; })); }
public async Task <HandGesture> GetGesture() { return(await Task.Factory.StartNew <HandGesture>(() => { var idx = _Random.Get(_Frequency.Count()); var likelyGesture = _Frequency.ElementAt(idx); return _WinningGestures[likelyGesture]; })); }