My favorites
|
Sign in
roulette-challenge
Achieve the best odds when playing roulette
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
‹r6
r10
Source path:
svn
/
trunk
/
Roulette
/
Roulette
/
Algorithm
/
TargetProfitWhenLosingAlgorithm.cs
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:
...estOddsInvariableBetAlgorithm.cs
...Roulette/Algorithm/IAlgorithm.cs
...rgetProfitWhenLosingAlgorithm.cs
/trunk/Roulette/Roulette/Bet.cs
...k/Roulette/Roulette/Evaluator.cs
.../Roulette/Roulette/Game/IGame.cs
...ulette/Game/VegasRouletteGame.cs
/trunk/Roulette/Roulette/Option.cs
/trunk/Roulette/Roulette/Outcome.cs
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
View raw file
Hosted by