체크포인트 저장 주기 1레벨로 변경
This commit is contained in:
18
Program.cs
18
Program.cs
@@ -195,8 +195,7 @@ internal static class Program
|
||||
void SaveCheckpoint(List<GeneratedLevel> snapshot, int lastId)
|
||||
{
|
||||
if (!checkpointEnabled) return;
|
||||
// 10단위(또는 마지막 레벨)마다 누적 JSON을 디스크에 기록한다.
|
||||
if (lastId % 10 != 0 && lastId != endId) return;
|
||||
// 매 레벨마다(또는 마지막 레벨) 누적 JSON을 디스크에 기록한다.
|
||||
try
|
||||
{
|
||||
var json = JsonSerializer.Serialize(snapshot, options);
|
||||
@@ -288,6 +287,7 @@ internal static class Program
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = true
|
||||
};
|
||||
|
||||
@@ -484,6 +484,7 @@ internal sealed class LevelGenerator
|
||||
{
|
||||
var band = ResolveBand(id);
|
||||
var level = BuildSingle(id, band);
|
||||
level = TrimLevel(level);
|
||||
output.Add(level);
|
||||
onCheckpoint?.Invoke(output, id);
|
||||
}
|
||||
@@ -830,6 +831,19 @@ internal sealed class LevelGenerator
|
||||
if (sink == null) return;
|
||||
sink[reason] = sink.TryGetValue(reason, out var count) ? count + 1 : 1;
|
||||
}
|
||||
|
||||
// 생성된 레벨을 자동으로 트림하여 외곽 void(0) 패딩을 제거한다.
|
||||
private static GeneratedLevel TrimLevel(GeneratedLevel level)
|
||||
{
|
||||
var trimmed = LevelTrimmer.Trim(level.Grid);
|
||||
return new GeneratedLevel
|
||||
{
|
||||
Id = level.Id,
|
||||
Grid = trimmed,
|
||||
LowestPush = level.LowestPush,
|
||||
PushLimit = level.PushLimit
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal static class LevelTrimmer
|
||||
|
||||
Reference in New Issue
Block a user