Skip to content

Commit

Permalink
Stop on timeout fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
gsvgit committed Aug 14, 2023
1 parent 86293c8 commit a569f0c
Showing 1 changed file with 50 additions and 51 deletions.
101 changes: 50 additions & 51 deletions VSharp.SILI/SILI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -358,61 +358,60 @@ type public SILI(options : SiliOptions) =
if searcher :? BidirectionalSearcher && (searcher :?> BidirectionalSearcher).ForwardSearcher :? AISearcher && ((searcher :?> BidirectionalSearcher).ForwardSearcher :?> AISearcher).InAIMode
then stepsPlayed <- stepsPlayed + 1u
if statistics.CurrentExplorationTime.TotalMilliseconds >= timeout
then x.Stop()
if shouldReleaseBranches() then
releaseBranches()
match action with
| GoFront s ->
try
let statisticsBeforeStep =
match searcher with
| :? BidirectionalSearcher as s ->
match s.ForwardSearcher with
| :? AISearcher as s -> Some s.LastCollectedStatistics
then x.Stop()
else
match action with
| GoFront s ->
try
let statisticsBeforeStep =
match searcher with
| :? BidirectionalSearcher as s ->
match s.ForwardSearcher with
| :? AISearcher as s -> Some s.LastCollectedStatistics
| _ -> None
| _ -> None
| _ -> None
let statistics1 =
if options.serialize
then Some(dumpGameState s.currentLoc (System.IO.Path.Combine(folderToStoreSerializationResult , string firstFreeEpisodeNumber)))
else None
x.Forward(s)
match searcher with
| :? BidirectionalSearcher as searcher ->
match searcher.ForwardSearcher with
| :? AISearcher as searcher ->
let gameState, statisticsAfterStep = collectGameState s.currentLoc
searcher.LastGameState <- gameState
searcher.LastCollectedStatistics <- statisticsAfterStep
let reward = computeReward statisticsBeforeStep.Value statisticsAfterStep
if searcher.InAIMode
then searcher.ProvideOracleFeedback (Feedback.MoveReward reward)
let statistics1 =
if options.serialize
then Some(dumpGameState s.currentLoc (System.IO.Path.Combine(folderToStoreSerializationResult , string firstFreeEpisodeNumber)))
else None
x.Forward(s)
match searcher with
| :? BidirectionalSearcher as searcher ->
match searcher.ForwardSearcher with
| :? AISearcher as searcher ->
let gameState, statisticsAfterStep = collectGameState s.currentLoc
searcher.LastGameState <- gameState
searcher.LastCollectedStatistics <- statisticsAfterStep
let reward = computeReward statisticsBeforeStep.Value statisticsAfterStep
if searcher.InAIMode
then searcher.ProvideOracleFeedback (Feedback.MoveReward reward)
| _ -> ()
| _ -> ()
| _ -> ()
if options.serialize
then
let _,statistics2 = collectGameState s.currentLoc
saveExpectedResult fileForExpectedResults s.id statistics1.Value statistics2
with
| e ->
match searcher with
| :? BidirectionalSearcher as searcher ->
match searcher.ForwardSearcher with
| :? AISearcher as searcher ->
if searcher.InAIMode
then searcher.ProvideOracleFeedback (Feedback.MoveReward (Reward(0u<coverageReward>,0u<_>,0u<_>)))
if options.serialize
then
let _,statistics2 = collectGameState s.currentLoc
saveExpectedResult fileForExpectedResults s.id statistics1.Value statistics2
with
| e ->
match searcher with
| :? BidirectionalSearcher as searcher ->
match searcher.ForwardSearcher with
| :? AISearcher as searcher ->
if searcher.InAIMode
then searcher.ProvideOracleFeedback (Feedback.MoveReward (Reward(0u<coverageReward>,0u<_>,0u<_>)))
| _ -> ()
| _ -> ()
| _ -> ()
reportStateInternalFail s e
| GoBack(s, p) ->
try
x.Backward p s
with
| e -> reportStateInternalFail s e
| Stop -> __unreachable__()
if searcher :? BidirectionalSearcher && (searcher :?> BidirectionalSearcher).ForwardSearcher :? AISearcher && (options.stepsToPlay = stepsPlayed)
then x.Stop()
reportStateInternalFail s e
| GoBack(s, p) ->
try
x.Backward p s
with
| e -> reportStateInternalFail s e
| Stop -> __unreachable__()
if searcher :? BidirectionalSearcher && (searcher :?> BidirectionalSearcher).ForwardSearcher :? AISearcher && (options.stepsToPlay = stepsPlayed)
then x.Stop()

System.IO.File.AppendAllLines ("Steps.out", [sprintf $"Steps: {stepsCount}"])
//System.IO.File.AppendAllLines ("Steps.out", [sprintf $"Steps: {stepsCount}"])

member private x.AnswerPobs initialStates =
statistics.ExplorationStarted()
Expand Down

0 comments on commit a569f0c

Please sign in to comment.