//Закрывает историю, если надо то копирует новый файл public void CloseHistory() { try { if (SubHistory != null) { SubHistory.Dispose(); } if (History != null) { History.Dispose(); } if (SuperHistory != null) { SuperHistory.Dispose(); } if (ErrorsRec != null) { ErrorsRec.Dispose(); } if (HistoryDb != null) { HistoryDb.Dispose(); } SubHistory = null; History = null; SuperHistory = null; ErrorsRec = null; HistoryDb = null; } catch { } }
private static string TrainingInt(IList <GameInfo> rows) { StringBuilder res = new StringBuilder(); foreach (var row in rows) { row.TrimMoves(); if (!row.IsValid()) { continue; } res.Append($"GameId:{row.Game.Id} "); int machProfit = row.AreLastTwoMovesEqual() ? row.Game.Surplus - (int)row.Game.TurksProfit : row.Game.MachineDisValue; res.Append($"MProfit:{machProfit} "); res.Append($"MDis:{row.Game.MachineDisValue} "); res.Append($"MStarts:{(row.Game.MachineStarts ? 1 : 0)} "); int i; for (i = 0; i < row.Moves.Count; i++) { var move = row.Moves[i]; res.Append($"{move.MoveBy[0]}:{move.ProposedAmount} "); } res.AppendLine(); res.AppendLine("Moves TConc MConc TFirst MFirst TLast1 MLast1 TLast MLast TDisV"); Debug.Assert(row.Moves.Count > 0); i = row.Game.MachineStarts ? 0 : 1; for (; i < row.Moves.Count; i += 2) { var moves = row.MovesToFloat(); var s = SubHistory.GetSubHistory(i, row.Game.MachineDisValue, row.Game.ShowMachinesDisValue ? row.Game.TurksDisValue : -1, row.Game.MachineStarts, moves); res.AppendFormat("{0,4}", i); res.AppendFormat("{0,6}", s[SubHistory.TurksLastConcessionIndex]); res.AppendFormat("{0,7}", s[SubHistory.MachinesLastConcessionIndex]); res.AppendFormat("{0,7}", s[SubHistory.TurksFirstOfferIndex]); res.AppendFormat("{0,7}", s[SubHistory.MachinesFirstOfferIndex]); res.AppendFormat("{0,7}", s[SubHistory.TurksLastOfferIndex]); res.AppendFormat("{0,7}", s[SubHistory.MachinesLast1OfferIndex]); res.AppendFormat("{0,7}", s[SubHistory.TurksLastOfferIndex]); res.AppendFormat("{0,7}", s[SubHistory.MachinesLastOfferIndex]); res.AppendFormat("{0,7}", s[SubHistory.TurksDisValueIndex]); res.AppendLine(); } } return(res.ToString()); }
private static string TrainingNormalized(IList <GameInfo> rows) { StringBuilder res = new StringBuilder(); foreach (var row in rows) { row.TrimMoves(); if (!row.IsValid()) { continue; } int machProfit = row.AreLastTwoMovesEqual() ? row.Game.Surplus - (int)row.Game.TurksProfit : row.Game.MachineDisValue; int i; for (i = 0; i < row.Moves.Count; i++) { var move = row.Moves[i]; } Debug.Assert(row.Moves.Count > 0); i = row.Game.MachineStarts ? 0 : 1; for (; i < row.Moves.Count; i += 2) { res.Append($"{row.Game.MachineDisValue} "); res.Append($"{(row.Game.MachineStarts ? 1 : 0)} "); var moves = row.MovesToFloat(); var s = SubHistory.GetSubHistory(i, row.Game.MachineDisValue, row.Game.ShowMachinesDisValue ? row.Game.TurksDisValue : -1, row.Game.MachineStarts, moves); res.AppendFormat("{0} ", i); res.AppendFormat("{0} ", s[SubHistory.TurksLastConcessionIndex]); res.AppendFormat("{0} ", s[SubHistory.MachinesLastConcessionIndex]); res.AppendFormat("{0} ", s[SubHistory.TurksFirstOfferIndex]); res.AppendFormat("{0} ", s[SubHistory.MachinesFirstOfferIndex]); res.AppendFormat("{0} ", s[SubHistory.TurksLast1OfferIndex]); res.AppendFormat("{0} ", s[SubHistory.MachinesLast1OfferIndex]); res.AppendFormat("{0} ", s[SubHistory.TurksLastOfferIndex]); res.AppendFormat("{0} ", s[SubHistory.MachinesLastOfferIndex]); res.AppendFormat("{0} ", s[SubHistory.TurksDisValueIndex]); res.AppendFormat("{0} ", machProfit); res.AppendLine(); } } return(res.ToString()); }
//Записать результат комманды в SubHistory private void EndSubLogCommand() { if (SubHistory != null) { try { if (SubHistory.HasRows()) { SubHistory.MoveLast(); SubHistory.Put("Status", CommandSubLog.Status); SubHistory.Put("ProcessLength", CommandSubLog.FromStart); SubHistory.Update(); } } catch (Exception ex) { AddErrorAboutHistory(ex); } } }
//Запись комманды в SubHistory private void BeginSubLogCommand() { if (SubHistory != null) { try { SubHistory.AddNew(); SubHistory.Put("Command", CommandSubLog.Name); SubHistory.Put("Time", CommandSubLog.StartTime); SubHistory.Put("Status", CommandSubLog.Status); SubHistory.Put("PeriodBegin", CommandSubLog.PeriodBegin); SubHistory.Put("PeriodEnd", CommandSubLog.PeriodEnd); SubHistory.Put("Mode", CommandSubLog.Mode); SubHistory.Put("CalcName", CommandSubLog.CalcName); SubHistoryId = SubHistory.GetInt("SubHistoryId"); SubHistory.Update(); } catch (Exception ex) { AddErrorAboutHistory(ex); } } }
internal float[] GetSubHistory(int i) => SubHistory.GetSubHistory(i, Game.MachineDisValue, Game.ShowMachinesDisValue ? Game.TurksDisValue : -1, Game.MachineStarts, MovesToFloat());