public IsValidAction ( ActionType action ) : bool | ||
action | ActionType | |
Результат | bool |
public override ActionType GetBestAction(Game game) { Console.WriteLine("Upcard: " + game.Upcard() + " | Hand: " + game.PlayerHandSet.ActiveHand + " (" + game.PlayerHandSet.ActiveHand.PointCount() + ")"); if (game.IsValidAction(ActionType.Hit)) { Console.Write("(H)it "); } if (game.IsValidAction(ActionType.Stand)) { Console.Write("(S)tand "); } if (game.IsValidAction(ActionType.Surrender)) { Console.Write("Sur(r)ender "); } if (game.IsValidAction(ActionType.Split)) { Console.Write("S(p)lit "); } if (game.IsValidAction(ActionType.Double)) { Console.Write("(D)ouble "); } string input = Console.ReadLine(); if (input[0] == 'h') { return(ActionType.Hit); } if (input[0] == 's') { return(ActionType.Stand); } if (input[0] == 'r') { return(ActionType.Surrender); } if (input[0] == 'p') { return(ActionType.Split); } if (input[0] == 'd') { return(ActionType.Double); } Console.WriteLine("Ops"); return(ActionType.Surrender); }
private List <ActionEv> Evaluate(Game game) { shell.StandardInput.WriteLine("h"); for (int i = 0; i < 9; i++) { shell.StandardInput.WriteLine(32 - counts[i]); } shell.StandardInput.WriteLine(128 - counts[9]); shell.StandardInput.WriteLine(game.Upcard().PointValue); shell.StandardInput.WriteLine(game.PlayerHandSet.ActiveHand.Count); foreach (Card card in game.PlayerHandSet.ActiveHand) { shell.StandardInput.WriteLine(card.PointValue); } List <ActionEv> actions = new List <ActionEv>(); if (game.IsValidAction(ActionType.Hit)) { actions.Add(Ev("h")); } if (game.IsValidAction(ActionType.Stand)) { actions.Add(Ev("t")); } if (game.IsValidAction(ActionType.Double)) { actions.Add(Ev("d")); } if (game.IsValidAction(ActionType.Split)) { actions.Add(Ev("s")); } if (game.IsValidAction(ActionType.Surrender)) { actions.Add(Ev("S")); } shell.StandardInput.WriteLine("q"); actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return(ae2.Ev.CompareTo(ae1.Ev)); }); /*Console.WriteLine("Upcard: " + upcard + " Hand: " + hand); * foreach (ActionEv ae in actions) * Console.WriteLine(ae.Action + " " + ae.Ev); * Console.ReadKey();*/ return(actions); }
public override List <ActionEv> GetActions(Game game) { SuperEval.Initialize(game); int split_card = game.PlayerHandSet.ActiveHand[0].PointValue; List <ActionEv> actions = new List <ActionEv>(); if (game.IsValidAction(ActionType.Stand)) { actions.Add(new ActionEv() { Action = ActionType.Stand, Ev = SuperEval.StandEv() }); } if (game.IsValidAction(ActionType.Hit)) { actions.Add(new ActionEv() { Action = ActionType.Hit, Ev = SuperEval.HitEv() }); } if (game.IsValidAction(ActionType.Double)) { actions.Add(new ActionEv() { Action = ActionType.Double, Ev = SuperEval.DoubleEv() }); } if (game.IsValidAction(ActionType.Surrender)) { actions.Add(new ActionEv() { Action = ActionType.Surrender, Ev = SuperEval.SurrenderEv() }); } if (game.IsValidAction(ActionType.Split)) { actions.Add(new ActionEv() { Action = ActionType.Split, Ev = SuperEval.SplitEv(split_card, game.Rules.Splits - game.SplitCount) }); } actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return(ae2.Ev.CompareTo(ae1.Ev)); }); return(actions); }
public override ActionType GetBestAction(Game game) { Console.WriteLine(game.PlayerHandSet.ActiveHand); List <ActionEv> actions = Evaluate(game); foreach (ActionEv ae in actions) { Console.WriteLine(ae.Action + " " + ae.Ev); } foreach (ActionEv ae in actions) { if (game.IsValidAction(ae.Action)) { return(ae.Action); } else { Console.WriteLine("OMGGG " + ae.Action); } } Console.WriteLine("BIG FUCCCCKKK"); return(ActionType.Split); }
public override List<ActionEv> GetActions(Game game) { List<ActionType> allowed_actions = new List<ActionType>(); if (game.IsValidAction(ActionType.Stand)) allowed_actions.Add(ActionType.Stand); if (game.IsValidAction(ActionType.Hit)) allowed_actions.Add(ActionType.Hit); if (game.IsValidAction(ActionType.Double)) allowed_actions.Add(ActionType.Double); if (game.IsValidAction(ActionType.Split)) allowed_actions.Add(ActionType.Split); if (game.IsValidAction(ActionType.Surrender)) allowed_actions.Add(ActionType.Surrender); CardSet some_cards = new CardSet(); //Hand active_hand = game.PlayerHandSet.ActiveHand; List<CardSet> player_hands = new List<CardSet>(); foreach (Hand hand in game.PlayerHandSet) { player_hands.Add(hand.Cards); } return agent.GetActions(GetSeenCards(game, false), game.DealerHand[0], player_hands.ToArray(), game.PlayerHandSet.ActiveIndex, allowed_actions); }
public override List <ActionEv> GetActions(Game game) { List <ActionType> allowed_actions = new List <ActionType>(); if (game.IsValidAction(ActionType.Stand)) { allowed_actions.Add(ActionType.Stand); } if (game.IsValidAction(ActionType.Hit)) { allowed_actions.Add(ActionType.Hit); } if (game.IsValidAction(ActionType.Double)) { allowed_actions.Add(ActionType.Double); } if (game.IsValidAction(ActionType.Split)) { allowed_actions.Add(ActionType.Split); } if (game.IsValidAction(ActionType.Surrender)) { allowed_actions.Add(ActionType.Surrender); } CardSet some_cards = new CardSet(); //Hand active_hand = game.PlayerHandSet.ActiveHand; List <CardSet> player_hands = new List <CardSet>(); foreach (Hand hand in game.PlayerHandSet) { player_hands.Add(hand.Cards); } return(agent.GetActions(GetSeenCards(game, false), game.DealerHand[0], player_hands.ToArray(), game.PlayerHandSet.ActiveIndex, allowed_actions)); }
public override List<ActionEv> GetActions(Game game) { SuperEval.Initialize(game); int split_card = game.PlayerHandSet.ActiveHand[0].PointValue; List<ActionEv> actions = new List<ActionEv>(); if (game.IsValidAction(ActionType.Stand)) actions.Add(new ActionEv() { Action = ActionType.Stand, Ev = SuperEval.StandEv() }); if (game.IsValidAction(ActionType.Hit)) actions.Add(new ActionEv() { Action = ActionType.Hit, Ev = SuperEval.HitEv() }); if (game.IsValidAction(ActionType.Double)) actions.Add(new ActionEv() { Action = ActionType.Double, Ev = SuperEval.DoubleEv() }); if (game.IsValidAction(ActionType.Surrender)) actions.Add(new ActionEv() { Action = ActionType.Surrender, Ev = SuperEval.SurrenderEv() }); if (game.IsValidAction(ActionType.Split)) actions.Add(new ActionEv() { Action = ActionType.Split, Ev = SuperEval.SplitEv(split_card, game.Rules.Splits - game.SplitCount) }); actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return ae2.Ev.CompareTo(ae1.Ev); }); return actions; }
public override ActionType GetBestAction(Game game) { List<ActionEv> actions = Evaluate(game.Upcard(), game.PlayerHandSet.ActiveHand); foreach (ActionEv ae in actions) { if (game.IsValidAction(ae.Action)) return ae.Action; else { //Console.WriteLine("OMGGG " + ae.Action); } } Console.WriteLine("BIG FUCCCCKKK"); return ActionType.Split; }
public override List<ActionEv> GetActions(Game game) { List<ActionEv> actions = new List<ActionEv>(); int[] shoe = game.Shoe.Counts; /*int[] test = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int test_count = 0; foreach (Card card in game.Shoe) { test[card.PointValue - 1]++; test_count++; } for (int i = 0; i < 10; i++) { if (test[i] != shoe[i]) { Console.Write(game.Shoe.Count + "| "); for (int j = 0; j < 10; j++) Console.Write(shoe[j] + " "); Console.WriteLine(); Console.Write(test_count + "| "); for (int j = 0; j < 10; j++) Console.Write(test[j] + " "); Console.WriteLine(); Console.ReadLine(); break; } }*/ shoe[game.DealerHand[1].PointValue - 1]++; SHand shand; int soft_total = game.PlayerHandSet.ActiveHand.SoftTotal(); if (soft_total <= 21 && game.PlayerHandSet.ActiveHand.HasAce()) { shand.Total = soft_total; shand.Soft = true; } else { shand.Total = game.PlayerHandSet.ActiveHand.HardTotal(); shand.Soft = false; } int upcard = game.DealerHand[0].PointValue; int split_card = game.PlayerHandSet.ActiveHand[0].PointValue; BjEval.Eval.CacheDealerProbs(upcard, shoe); /* for (int i = 0; i < 10; i++) Console.Write(shoe[i] + " "); Console.WriteLine(); Console.WriteLine("SHand: " + shand.Total + " soft=" + shand.Soft); */ if (game.IsValidAction(ActionType.Stand)) actions.Add(new ActionEv() { Action = ActionType.Stand, Ev = BjEval.Eval.StandEv(shand, upcard, shoe) }); if (game.IsValidAction(ActionType.Hit)) actions.Add(new ActionEv() { Action = ActionType.Hit, Ev = BjEval.Eval.HitEv(shand, upcard, shoe) }); if (game.IsValidAction(ActionType.Double)) actions.Add(new ActionEv() { Action = ActionType.Double, Ev = BjEval.Eval.DoubleEv(shand, upcard, max_bet, shoe) }); if (game.IsValidAction(ActionType.Surrender)) actions.Add(new ActionEv() { Action = ActionType.Surrender, Ev = BjEval.Eval.SurrenderEv() }); if (game.IsValidAction(ActionType.Split)) actions.Add(new ActionEv() { Action = ActionType.Split, Ev = BjEval.Eval.SplitEv(split_card, upcard, max_bet, game.Rules.Splits - game.SplitCount, shoe) }); actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return ae2.Ev.CompareTo(ae1.Ev); }); return actions; }
public override List <ActionEv> GetActions(Game game) { List <ActionEv> actions = new List <ActionEv>(); int[] shoe = game.Shoe.Counts; /*int[] test = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; * int test_count = 0; * foreach (Card card in game.Shoe) * { * test[card.PointValue - 1]++; * test_count++; * } * for (int i = 0; i < 10; i++) * { * if (test[i] != shoe[i]) * { * Console.Write(game.Shoe.Count + "| "); * for (int j = 0; j < 10; j++) * Console.Write(shoe[j] + " "); * Console.WriteLine(); * Console.Write(test_count + "| "); * for (int j = 0; j < 10; j++) * Console.Write(test[j] + " "); * Console.WriteLine(); * * Console.ReadLine(); * break; * } * }*/ shoe[game.DealerHand[1].PointValue - 1]++; SHand shand; int soft_total = game.PlayerHandSet.ActiveHand.SoftTotal(); if (soft_total <= 21 && game.PlayerHandSet.ActiveHand.HasAce()) { shand.Total = soft_total; shand.Soft = true; } else { shand.Total = game.PlayerHandSet.ActiveHand.HardTotal(); shand.Soft = false; } int upcard = game.DealerHand[0].PointValue; int split_card = game.PlayerHandSet.ActiveHand[0].PointValue; BjEval.Eval.CacheDealerProbs(upcard, shoe); /* * for (int i = 0; i < 10; i++) * Console.Write(shoe[i] + " "); * Console.WriteLine(); * * Console.WriteLine("SHand: " + shand.Total + " soft=" + shand.Soft); */ if (game.IsValidAction(ActionType.Stand)) { actions.Add(new ActionEv() { Action = ActionType.Stand, Ev = BjEval.Eval.StandEv(shand, upcard, shoe) }); } if (game.IsValidAction(ActionType.Hit)) { actions.Add(new ActionEv() { Action = ActionType.Hit, Ev = BjEval.Eval.HitEv(shand, upcard, shoe) }); } if (game.IsValidAction(ActionType.Double)) { actions.Add(new ActionEv() { Action = ActionType.Double, Ev = BjEval.Eval.DoubleEv(shand, upcard, max_bet, shoe) }); } if (game.IsValidAction(ActionType.Surrender)) { actions.Add(new ActionEv() { Action = ActionType.Surrender, Ev = BjEval.Eval.SurrenderEv() }); } if (game.IsValidAction(ActionType.Split)) { actions.Add(new ActionEv() { Action = ActionType.Split, Ev = BjEval.Eval.SplitEv(split_card, upcard, max_bet, game.Rules.Splits - game.SplitCount, shoe) }); } actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return(ae2.Ev.CompareTo(ae1.Ev)); }); return(actions); }
private List<ActionEv> Evaluate(Game game) { shell.StandardInput.WriteLine("h"); for (int i = 0; i < 9; i++) shell.StandardInput.WriteLine(32 - counts[i]); shell.StandardInput.WriteLine(128 - counts[9]); shell.StandardInput.WriteLine(game.Upcard().PointValue); shell.StandardInput.WriteLine(game.PlayerHandSet.ActiveHand.Count); foreach (Card card in game.PlayerHandSet.ActiveHand) shell.StandardInput.WriteLine(card.PointValue); List<ActionEv> actions = new List<ActionEv>(); if (game.IsValidAction(ActionType.Hit)) actions.Add(Ev("h")); if (game.IsValidAction(ActionType.Stand)) actions.Add(Ev("t")); if (game.IsValidAction(ActionType.Double)) actions.Add(Ev("d")); if (game.IsValidAction(ActionType.Split)) actions.Add(Ev("s")); if (game.IsValidAction(ActionType.Surrender)) actions.Add(Ev("S")); shell.StandardInput.WriteLine("q"); actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return ae2.Ev.CompareTo(ae1.Ev); }); /*Console.WriteLine("Upcard: " + upcard + " Hand: " + hand); foreach (ActionEv ae in actions) Console.WriteLine(ae.Action + " " + ae.Ev); Console.ReadKey();*/ return actions; }
public override ActionType GetBestAction(Game game) { Console.WriteLine("Upcard: " + game.Upcard() + " | Hand: " + game.PlayerHandSet.ActiveHand + " (" + game.PlayerHandSet.ActiveHand.PointCount() + ")"); if (game.IsValidAction(ActionType.Hit)) Console.Write("(H)it "); if (game.IsValidAction(ActionType.Stand)) Console.Write("(S)tand "); if (game.IsValidAction(ActionType.Surrender)) Console.Write("Sur(r)ender "); if (game.IsValidAction(ActionType.Split)) Console.Write("S(p)lit "); if (game.IsValidAction(ActionType.Double)) Console.Write("(D)ouble "); string input = Console.ReadLine(); if (input[0] == 'h') return ActionType.Hit; if (input[0] == 's') return ActionType.Stand; if (input[0] == 'r') return ActionType.Surrender; if (input[0] == 'p') return ActionType.Split; if (input[0] == 'd') return ActionType.Double; Console.WriteLine("Ops"); return ActionType.Surrender; }