private void buttonDouble_Click(object sender, EventArgs e) { watch.Stop(); GameStateTurnAction gsta = new GameStateTurnAction(currentGameState.Clone(), watch.ElapsedMilliseconds, TurnAction.Double); turns.Add(gsta); textBoxLog.Text += "Turn action added" + " " + watch.ElapsedMilliseconds + "ms." + Environment.NewLine; textBoxLog.SelectionStart = textBoxLog.Text.Length; textBoxLog.ScrollToCaret(); currentGameState.Double(); Render(); this.Refresh(); DoubleResponseHint hint = gnubg.DoubleResponseHint(currentGameState); Thread.Sleep(thinker.TimeOnDoubleOffer(currentGameState, hint)); if (hint.Response == DoubleResponse.Pass) { status = GameStatus.GameOver; return; } if (hint.Response == DoubleResponse.Take) { currentGameState.Take(); } UpdateControls(); }
public override int TimeOnDoubleOffer(GameState gamestate, DoubleResponseHint hint) { // Parameter Values // Mean 2000 ms // Minimum 1000 ms // Maximum 20000 ms // Deviation 2.0 (95.4% are within 5000 ms from mean) return((int)(coefficient * Gaussian.Next(2000, 1000, 20000, 2000, 2.0))); }
public override DoubleResponseHint DoubleResponseHint(GameState gamestate) { Stopwatch sw = Stopwatch.StartNew(); DoubleResponseHint hint = gnubg.DoubleResponseHint(gamestate); Console.WriteLine("[DoubleResponse Hint] " + sw.ElapsedMilliseconds + "ms."); return(hint); }
// Where's the randomness? Possibilities: // Category the actions and pick one randomly from the cat's set of actions (or approximate by some probability distribution etc.) // Sort a list from best to worst distances and pick randomly from that list (top N candidates - uniform random or normal) public override int TimeOnDoubleOffer(GameState gamestate, DoubleResponseHint hint) { Vector v = ToDoubleInput(gamestate, hint); foreach (KeyValuePair <GameStateAction, Vector> gv in doubles) { gv.Value.Distance = Vector.ComputeDistance(gv.Value, v); } doubles.Sort(Compare); return((int)doubles[0].Key.Time); }
public override int TimeOnDoubleOffer(GameState gamestate, DoubleResponseHint hint) { int total = 0; if (random.Next(10) == 0) { total += random.Next(8000); } if (random.Next(5) == 0) { total += random.Next(4000); } return(random.Next(500, 1500)); }
public NeuralThinker(IEnumerable <GameStateMoveAction> moves, IEnumerable <GameStateDoubleAction> doubles, IEnumerable <GameStateResignAction> resigns, IEnumerable <GameStateTurnAction> turns) { GnuBgHintModule gnubg = new GnuBgHintModule(@"gnubg/ipoint.exe"); gnubg.Initialize(); foreach (GameStateMoveAction gsma in moves) { List <PlayHint> hints = gnubg.PlayHint(gsma.Original, 500); this.moves.Add(new KeyValuePair <GameStateAction, Vector>(gsma, ToMoveInput(gsma, hints))); } foreach (GameStateDoubleAction gsda in doubles) { DoubleResponseHint hint = gnubg.DoubleResponseHint(gsda.GameState); //Vector vector = new Vector(hint.TakeEq, hint.PassEq, System.Math.Abs(hint.PassEq - hint.TakeEq)); this.doubles.Add(new KeyValuePair <GameStateAction, Vector>(gsda, ToDoubleInput(gsda.GameState, hint))); } foreach (GameStateResignAction gsra in resigns) { ResignResponseHint hint = gnubg.ResignResponseHint(gsra.GameState); Vector vector = new Vector(); this.resigns.Add(new KeyValuePair <GameStateAction, Vector>(gsra, vector)); } foreach (GameStateTurnAction gsta in turns) { DoubleHint hint = null; if (gsta.GameState.CanDouble()) { hint = gnubg.DoubleHint(gsta.GameState); } this.turns.Add(new KeyValuePair <GameStateAction, Vector>(gsta, ToTurnInput(gsta.GameState, hint))); } random.Next(); random.Next(); }
public override int TimeOnDoubleOffer(GameState gamestate, DoubleResponseHint hint) { return(random.Next(2000, 4000)); }
public abstract int TimeOnDoubleOffer(GameState gamestate, DoubleResponseHint hint);
public override int TimeOnDoubleOffer(GameState gamestate, DoubleResponseHint hint) { return(0); }
private Vector ToDoubleInput(GameState gs, DoubleResponseHint hint) { return(new Vector(hint.TakeEq, hint.PassEq, System.Math.Abs(hint.PassEq - hint.TakeEq))); }