/// <summary> /// Returns a SabberStoneAction for the current state. /// </summary> /// <param name="state">The current game state.</param> /// <returns>SabberStoneAction</returns> public SabberStoneAction Act(SabberStoneState state) { // Check to make sure the player to act in the game-state matches our player. if (state.CurrentPlayer() != Player.Id) { return(null); } SabberStoneAction selectedAction; // When we have to act, check which policy we are going to use switch (Selection) { case SelectionType.UCB: selectedAction = SelectUCB(state); break; case SelectionType.EGreedy: selectedAction = SelectEGreedy(state); break; case SelectionType.Random: selectedAction = RandomPlayoutBot.CreateRandomAction(state); break; default: throw new InvalidEnumArgumentException($"SelectionType `{Selection}' is not supported."); } // Remember the action that was selected. ActionsTaken.Add(selectedAction); return(selectedAction); }
public IDbStatement Prepare2(IDbHandle db, string query) { ActionsTaken.Add("Prepare2"); return(new MockDbStatement() { Query = query }); }
public Result Step(IDbStatement stmt) { string query = ((MockDbStatement)stmt).Query; if (query.StartsWith("Create", StringComparison.CurrentCultureIgnoreCase)) { CreateStatementsExecuted.Add(query); } else if (query.StartsWith("Delete", StringComparison.CurrentCultureIgnoreCase)) { DeleteStatementsExecuted.Add(query); } else if (query.StartsWith("Insert or replace", StringComparison.CurrentCultureIgnoreCase)) { InsertOrReplaceStatementsExecuted.Add(query); } else if (query.StartsWith("Insert", StringComparison.CurrentCultureIgnoreCase)) { InsertStatementsExecuted.Add(query); } else if (query.StartsWith("Update", StringComparison.CurrentCultureIgnoreCase)) { UpdateStatementsExecuted.Add(query); } else if (query.StartsWith("Drop", StringComparison.CurrentCultureIgnoreCase)) { DropStatementsExecuted.Add(query); } else if (query.StartsWith("Select", StringComparison.CurrentCultureIgnoreCase)) { SelectStatementsExecuted.Add(query); } else { throw new NotImplementedException(query); } ActionsTaken.Add("Step"); if (((MockDbStatement)stmt).Query.StartsWith("select") && ((MockDbStatement)stmt).ResultsStepCount == 0) { ((MockDbStatement)stmt).ResultsStepCount++; return(Result.Row); } else { ((MockDbStatement)stmt).ResultsStepCount = 0; return(Result.Done); } }
public Result Open(byte[] filename, out IDbHandle db, int flags, IntPtr zvfs) { ActionsTaken.Add(string.Concat(filename.ToString(), "-Opened")); db = new MockDbHandle(); CreateStatementsExecuted = new List <string> (); DeleteStatementsExecuted = new List <string> (); InsertOrReplaceStatementsExecuted = new List <string> (); InsertStatementsExecuted = new List <string> (); UpdateStatementsExecuted = new List <string> (); DropStatementsExecuted = new List <string> (); SelectStatementsExecuted = new List <string> (); return(Result.OK); }
public int Changes(IDbHandle db) { ActionsTaken.Add("Changes"); return(1); }
public Result BusyTimeout(IDbHandle db, int milliseconds) { ActionsTaken.Add("BusyTimeoutSet"); return(Result.Done); }
public Result Close(IDbHandle db) { ActionsTaken.Add("Close"); return(Result.Done); }
public int BindBlob(IDbStatement stmt, int index, byte[] val, int n, IntPtr free) { ActionsTaken.Add("BindBlob"); return(0); }
public int BindText16(IDbStatement stmt, int index, string val, int n, IntPtr free) { ActionsTaken.Add("BindText16"); return(0); }
public int BindDouble(IDbStatement stmt, int index, double val) { ActionsTaken.Add("BindDouble"); return(0); }
public int BindInt64(IDbStatement stmt, int index, long val) { ActionsTaken.Add("BindInt64"); return(0); }
public int BindInt(IDbStatement stmt, int index, int val) { ActionsTaken.Add("BindInt"); return(0); }
public int BindNull(IDbStatement stmt, int index) { ActionsTaken.Add("BindNull"); return(0); }
public string Errmsg16(IDbHandle db) { ActionsTaken.Add("Errmsg16"); return("Errmsg16"); }
public Result Finalize(IDbStatement stmt) { ActionsTaken.Add("Finalize"); return(Result.Done); }