本文整理汇总了C#中Decision类的典型用法代码示例。如果您正苦于以下问题:C# Decision类的具体用法?C# Decision怎么用?C# Decision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Decision类属于命名空间,在下文中一共展示了Decision类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
SolverContext context = SolverContext.GetContext();
Model model = context.CreateModel();
// ------------
// Parameters
Set city = new Set(Domain.IntegerNonnegative, "city");
Parameter dist = new Parameter(Domain.Real, "dist", city, city);
var arcs = from p1 in data
from p2 in data
select new Arc { City1 = p1.Name, City2 = p2.Name, Distance = p1.Distance(p2) };
dist.SetBinding(arcs, "Distance", "City1", "City2");
model.AddParameters(dist);
// ------------
// Decisions
Decision assign = new Decision(Domain.IntegerRange(0, 1), "assign", city, city);
Decision rank = new Decision(Domain.RealNonnegative, "rank", city);
model.AddDecisions(assign, rank);
// ------------
// Goal: minimize the length of the tour.
Goal goal = model.AddGoal("TourLength", GoalKind.Minimize,
Model.Sum(Model.ForEach(city, i => Model.ForEachWhere(city, j => dist[i, j] * assign[i, j], j => i != j))));
// ------------
// Enter and leave each city only once.
int N = data.Length;
model.AddConstraint("assign1",
Model.ForEach(city, i => Model.Sum(Model.ForEachWhere(city, j => assign[i, j],
j => i != j)) == 1));
model.AddConstraint("assign2",
Model.ForEach(city, j => Model.Sum(Model.ForEachWhere(city, i => assign[i, j], i => i != j)) == 1));
// Forbid subtours (Miller, Tucker, Zemlin - 1960...)
model.AddConstraint("no_subtours",
Model.ForEach(city,
i => Model.ForEachWhere(city,
j => rank[i] + 1 <= rank[j] + N * (1 - assign[i, j]),
j => Model.And(i != j, i >= 1, j >= 1)
)
)
);
Solution solution = context.Solve();
// Retrieve solution information.
Console.WriteLine("Cost = {0}", goal.ToDouble());
Console.WriteLine("Tour:");
var tour = from p in assign.GetValues() where (double)p[0] > 0.9 select p[2];
foreach (var i in tour.ToArray())
{
Console.Write(i + " -> ");
}
Console.WriteLine();
Console.WriteLine("Press enter to continue...");
Console.ReadLine();
}
开发者ID:jamesjrg,项目名称:taipan,代码行数:60,代码来源:Program.cs
示例2: Decide
public override Decision Decide(IEntityRecord opponent)
{
Decision trick = Decision.Undecided;
Outcome outcome = Outcome.Unknown;
int retries = 0;
int maxRetries = 5;
while (outcome == Outcome.Unknown || outcome == Outcome.Loss) {
// pick any hand and use it to see how opponent would react
// > note that it must have some amount of influence to be considered a real decision
trick = Decision.Next(1);
Decision reaction = new Decision();
foreach (Behavior behavior in opponent.GetComponents().OfType<Behavior>()) {
reaction += behavior.React(Record, trick);
}
outcome = trick.DetermineOutcome(reaction);
if (retries++ > maxRetries) {
break;
}
}
// > note that we do not use Decision.Counter on the reaction that resulted in a win, because
// it was actually the trick hand that caused the win
return Decision.Distribute(
trick.MostInfluencedHand, Influence);
}
开发者ID:Zolomon,项目名称:ComponentKit-Example-RockPaperScissors,代码行数:31,代码来源:Gifted.cs
示例3: Score
/// <summary>
/// Sprawdza, czy decyzja jest zwycieska
/// </summary>
/// <param name="mine"></param>
/// <param name="opponet"></param>
/// <returns></returns>
public static int Score(this Decision mine, Decision opponet)
{
if (mine == opponet)
return 0;
switch (mine)
{
case Decision.Rock:
if (opponet == Decision.Paper)
return -1;
else return 1;
case Decision.Paper:
if (opponet == Decision.Scissor)
return -1;
else
return 1;
case Decision.Scissor:
if (opponet == Decision.Rock)
return -1;
else
return 1;
default:
return 0;
}
}
开发者ID:quarion,项目名称:NeuralRockPaperScissors,代码行数:31,代码来源:RPSExtensions.cs
示例4: d2d
public static double[] d2d(Decision[] d)
{
var result = new double[d.Length];
for (int i = 0; i < d.Length; i++)
result[i] = d[i].ToDouble();
return result;
}
开发者ID:Billum,项目名称:KleineOpdracht,代码行数:7,代码来源:Program.cs
示例5: Main
static void Main(string[] args)
{
//4.1)
SimpleActivity greaterThan100Activity = new SimpleActivity(()=>Console.WriteLine("Value is greater than 100."));
//4.2)
SimpleActivity lessThan100Activity = new SimpleActivity(()=>Console.WriteLine("Value is less than 100."));
//3.)
Decision<int> greaterOrLess100Decision = new Decision<int>(multipliedValue => multipliedValue > 100, greaterThan100Activity, lessThan100Activity);
//2.)
InputOutputActivity<int,int> mutiplyBy10Activity = new InputOutputActivity<int, int>(inputValue => inputValue * 10, greaterOrLess100Decision);
//1.)
OutputActivity<int> getInputValueActivity = new OutputActivity<int>(()=>
{
Console.Write("Please type in value:");
var input = Console.ReadLine();
return Convert.ToInt32(input);
}, mutiplyBy10Activity);
WorkflowEngine engine = new WorkflowEngine();
engine.WorkflowProgressChanged += (arg1, arg2, arg3, arg4) => Console.WriteLine("Step:{0}\r\nContext:{1}\r\nSuccess:{2}\r\nException message:{3}", arg1, arg2, arg3, arg4 != null ? arg4.Message : string.Empty);
engine.WorkflowCompleted += (arg1, arg2) => Console.WriteLine("Completed:\r\nSucceeded:{0}\r\nException message:{1}", arg1, arg2 != null ? arg2.Message : string.Empty);
engine.Run(getInputValueActivity);
Console.ReadLine();
engine.Dispose();
}
开发者ID:ChrisMa1985,项目名称:Anaconda,代码行数:33,代码来源:Program.cs
示例6: WinByPointsPrediction
public WinByPointsPrediction(Decision by, Boxer winner, PlayerPrediction playerPrediction)
{
By = by;
Winner = winner;
Type = "WinByPointsPrediction";
PlayerPrediction = playerPrediction;
}
开发者ID:elmo61,项目名称:BritBoxing,代码行数:7,代码来源:WinByPointsPrediction.cs
示例7: DecisionTree
/// <summary>
/// Initializes a new instance of the <see cref="DecisionTree"/> class.
/// </summary>
/// <param name="_decisions">_decisions.</param>
/// <param name="_actions">_actions.</param>
/// <param name="_callback">_callback.</param>
public DecisionTree(Decision[] _decisions, TreeAction[] _actions, Action<TreeAction> _callback)
{
decisions = _decisions;
actions = _actions;
callback = _callback;
doneEvent = new ManualResetEvent(true);
}
开发者ID:weej89,项目名称:PsychoticGameDev,代码行数:14,代码来源:DecisionTree.cs
示例8: Transfer
public bool Transfer(Guid competitionId, Decision decision)
{
var competition = this.repository.Get(competitionId);
if (competition == null) return false;
if (!this.stateService.CanUpdateResult(competition)) return false;
competition.RegisterWin(decision.Winner);
competition.RegisterLoss(decision.Looser);
return this.repository.Update(competition);
}
开发者ID:dfreier,项目名称:duels,代码行数:10,代码来源:DecisionGateway.cs
示例9: GetNewer
/// <summary>
/// Gets the decision that has occured later in time.
/// </summary>
public static Decision GetNewer(Decision a, Decision b)
{
if (a == null)
return b;
if (b == null)
return a;
return a.time > b.time ? a : b;
}
开发者ID:pgolebiowski,项目名称:onism-cldr,代码行数:13,代码来源:Decision.cs
示例10: Start
//public GameObject gameLogic;
// Use this for initialization
void Start () {
gameState = FindObjectOfType<PersistantState>();
currentDecision = gameState.Decisions[gameState.Stage];
textDay.text = string.Format("Day {0}", gameState.Stage + 1);
textQuery.text = currentDecision.query;
buttonAlternative1.GetComponentInChildren<Text>().text = currentDecision.alternatives[0];
buttonAlternative1.onClick.AddListener(delegate { onClick(0); });
buttonAlternative2.GetComponentInChildren<Text>().text = currentDecision.alternatives[1];
buttonAlternative2.onClick.AddListener(delegate { onClick(1); });
}
开发者ID:bedder,项目名称:ggj2016,代码行数:14,代码来源:Decisions.cs
示例11: React
public override Decision React(IEntityRecord opponent, Decision decision)
{
Decision counter = Decision.Win(decision, Influence);
Hand choices =
counter.MostInfluencedHand |
decision.MostInfluencedHand;
return Decision.Next(
choices, Influence * 2);
}
开发者ID:Zolomon,项目名称:ComponentKit-Example-RockPaperScissors,代码行数:11,代码来源:Gifted.cs
示例12: BuildDecisions
public Decision[,] BuildDecisions()
{
for (int i = 0; i < Decisions.GetLength(0); i++)
{
for (int j = 0; j < Decisions.GetLength(1); j++)
{
Decisions[i, j] = new Decision(domain, "_" + i + "Decision" + j);
}
}
return Decisions;
}
开发者ID:IdanAzuri,项目名称:AI_Project,代码行数:12,代码来源:DecisionFactory.cs
示例13: React
public override Decision React(IEntityRecord opponent, Decision decision)
{
Decision reaction = Decision.Undecided;
History opponentHistory = opponent.GetComponent<History>();
if (opponentHistory != null) {
reaction = opponentHistory.PreviousDecision;
}
return Decision.Distribute(
reaction.MostInfluencedHand, Influence);
}
开发者ID:Zolomon,项目名称:ComponentKit-Example-RockPaperScissors,代码行数:13,代码来源:Paranoid.cs
示例14: MakeDecision
public bool MakeDecision(Guid sessionId, Decision decision)
{
var session = Get(sessionId);
if (session == null) return false;
if (session.IsClosed) return false;
var operationChecker = new OperationChecker(this.competitionRepository);
var gateway = new DecisionGateway(this.competitionRepository, operationChecker);
session.RegisterDecision(decision, gateway);
this.unitOfWork.Commit();
return true;
}
开发者ID:dfreier,项目名称:duels,代码行数:13,代码来源:SessionService.cs
示例15: RegisterDecision
public void RegisterDecision(Decision decision, IDecisionGateway gateway)
{
if (this.IsClosed) return;
var duel = decision.Duel;
AssertScheduleContainsDuel(duel);
AssertDecisionIsNotRegisteredYet(duel);
this.Outcomes.Add(new Outcome(decision));
this.Schedule.Remove(duel);
gateway.Transfer(this.CompetitionId, decision);
}
开发者ID:dfreier,项目名称:duels,代码行数:14,代码来源:Session.cs
示例16: init
/*
* Init method allow to pass a title and message that will be displayed to the user,
* and also a decision delegate
*/
public void init(string title, string message, Decision dec)
{
this.title.text = title;
this.message.text = message;
cancel.onClick.AddListener(delegate {
gameObject.SetActive(false);
dec(false);
});
ok.onClick.AddListener(delegate {
gameObject.SetActive(false);
dec(true);
});
gameObject.SetActive (true);
}
开发者ID:Emotiv,项目名称:community-sdk,代码行数:18,代码来源:MessageBox.cs
示例17: updateInputs
/// <summary>
/// Aktualizuje wejscia po kolejnej rundzie gry
/// </summary>
/// <param name="AIDecision">własna decyzja</param>
/// <param name="opponentDecision">decyzja przeciwnika</param>
public void updateInputs(Decision AIDecision, Decision opponentDecision )
{
//przesuwamy wejscia w prawo
double[] oldInputs = new double[inputs.Length];
inputs.CopyTo(oldInputs, 0);
for (int j = 3; j < inputs.Length; ++j)
inputs[j] = oldInputs[j - 3];
//dopisujemy nowe wejscia
for (int j = 0; j < 3; ++j)
{
inputs[j] = AIDecision.ToNeural()[j];
inputs[j + inputs.Length / 2] = opponentDecision.ToNeural()[j];
}
}
开发者ID:quarion,项目名称:NeuralRockPaperScissors,代码行数:20,代码来源:RPSNetork.cs
示例18: ResultElement
/// <summary>
/// Creates a new Result using the provided information.
/// </summary>
/// <param name="resourceId">The resource id for this result.</param>
/// <param name="decision">The decission of the evaluation.</param>
/// <param name="status">The status with information about the execution.</param>
/// <param name="obligations">The list of obligations</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public ResultElement(string resourceId, Decision decision, StatusElement status, ObligationCollection obligations, XacmlVersion schemaVersion)
: base(XacmlSchema.Context, schemaVersion)
{
_resourceId = resourceId;
Decision = decision;
// If the status is null, create an empty status
Status = status ?? new StatusElement(null, null, null, schemaVersion);
// If the obligations are null, leave the empty ObligationCollection.
if (obligations != null)
{
_obligations = obligations;
}
}
开发者ID:mingkongbin,项目名称:anycmd,代码行数:23,代码来源:ResultElement.cs
示例19: scoreRound
public void scoreRound(Decision playerDecision)
{
var opponentDecision = decisionMaker.getNextDecision();
int score = playerDecision.Score(opponentDecision);
if (score == -1)
opponentScore += 1;
else if (score == 1)
playerScore += 1;
ScoreLabel.Content = playerScore + " : " + opponentScore;
HistoryTextBox.Text = "Ty: " + playerDecision.toLocalString() + ", przeciwnik: " + opponentDecision.toLocalString();
decisionMaker.rememberDecision(playerDecision);
}
开发者ID:quarion,项目名称:NeuralRockPaperScissors,代码行数:16,代码来源:MainWindow.xaml.cs
示例20: sendDecision
private void sendDecision(Decision decision)
{
BroadcastMessage("Decision", decision);
if(decision == Decision.left){
currentHorizontal--;
}
if(decision == Decision.right){
currentHorizontal++;
}
if(decision == Decision.up){
currentVertical++;
}
if(decision == Decision.down){
currentVertical--;
}
}
开发者ID:AlexTiTanium,项目名称:Kombain-game,代码行数:20,代码来源:EnemiesBrain.cs
注:本文中的Decision类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论