My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Generic;
using System.Linq;

namespace Roulette
{
public class TargetProfitWhenLosingAlgorithm : IAlgorithm
{
public double Amount { get; set; }
public double TargetProfit { get; set; }
public Bet Bet { get; set; }

public TargetProfitWhenLosingAlgorithm()
{
this.Amount = .05d;
this.TargetProfit = this.Amount;
}

public Bet ChooseBet(Outcome outcome, IEnumerable<Option> options)
{
if (ReferenceEquals(null, this.Bet))
{
var positiveOutcomes = options
.SelectMany(a => a.Outcomes)
.Where(a => a.Gain > 0)
;
var bestOddsPositiveOutcome = positiveOutcomes
.Where(a => a.Probability == positiveOutcomes.Max(b => b.Probability))
.First();
this.Bet = new Bet()
{
Amount = this.Amount
,
Option = options
.Where(option => option.Outcomes.Contains(bestOddsPositiveOutcome))
.First()
};
}
if (outcome.Gain < 0d)
{
return new Bet()
{
Amount = this.TargetProfit - outcome.Gain
,
Option = this.Bet.Option
};
}
return this.Bet;
}
}
}
Show details Hide details

Change log

r7 by jaderd on Sep 25, 2009   Diff
Remove and sort usings
Go to: 
Project members, sign in to write a code review

Older revisions

r6 by jaderd on Sep 25, 2009   Diff
Renamed method
r3 by jaderd on Sep 25, 2009   Diff

 
All revisions of this file

File info

Size: 1589 bytes, 50 lines
Hosted by Google Code