CS计算机代考程序代写 #——————————————–

#——————————————–
# GoalStateSim’s runsim()

function runsim(sim::GoalStateSim, v::Verbosity)
runsim( sim, maxitr(sim), startstate(sim), v)
end

function runsim(sim::GoalStateSim, maxItr::Nothing, state, v)
error(“For a GoalState simulation, maxiter(sim) = user_supplied_int must be defined to protect against infinite runs \n” *
“If an infinite length run is not possible, or it is a chance the user is willing to risk,\n” *
“explicitly declare maxiter(sim) = Inf”)
end

function runsim(sim::GoalStateSim, maxItr::Float64, state, v)
if maxItr == Inf
runsim(sim, state, v)
else
error(“maxItr must be an Integer; $maxItr supplied instead”)
end
end

function runsim(sim::GoalStateSim, maxItr, state, v)
verbosefn(v, sim, state, 0)
for i = 1:maxItr
isfound(sim, state) && break
update!(sim, state)
verbosefn(v, sim, state, i)
end
measure(sim, state)
end

function runsim(sim::GoalStateSim, state, v)
i = 0
verbosefn(v, sim, state, i)
while !isfound(sim, state)
i += 1
update!(sim, state)
verbosefn(v, sim, state, i)
end
measure(sim, state)
end