pub struct RunOwnAll<W: Wrap = WrapXY, F: ForbidPattern = ForbidNothing> { /* private fields */ }
Expand description
Represents a running instance of wfc which allocates and owns its resources including a copy of the GlobalStats
Implementations§
source§impl<F> RunOwnAll<WrapXY, F>where
F: Clone + Sync + Send + ForbidPattern,
impl<F> RunOwnAll<WrapXY, F>where
F: Clone + Sync + Send + ForbidPattern,
pub fn new_forbid<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
forbid: F,
rng: &mut R
) -> Self
source§impl<W: Wrap, F> RunOwnAll<W, F>where
F: Clone + Sync + Send + ForbidPattern,
impl<W: Wrap, F> RunOwnAll<W, F>where
F: Clone + Sync + Send + ForbidPattern,
sourcepub fn new_wrap_forbid<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
wrap: W,
forbid: F,
rng: &mut R
) -> Self
pub fn new_wrap_forbid<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
wrap: W,
forbid: F,
rng: &mut R
) -> Self
Examples found in repository?
src/wfc.rs (line 1370)
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
pub fn new<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
rng: &mut R,
) -> Self {
Self::new_wrap_forbid(output_size, global_stats, WrapXY, ForbidNothing, rng)
}
}
impl<W: Wrap> RunOwnAll<W> {
pub fn new_wrap<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
wrap: W,
rng: &mut R,
) -> Self {
Self::new_wrap_forbid(output_size, global_stats, wrap, ForbidNothing, rng)
}
}
impl<F: ForbidPattern> RunOwnAll<WrapXY, F>
where
F: Clone + Sync + Send,
{
pub fn new_forbid<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
forbid: F,
rng: &mut R,
) -> Self {
Self::new_wrap_forbid(output_size, global_stats, WrapXY, forbid, rng)
}
source§impl<W: Wrap, F> RunOwnAll<W, F>where
F: Clone + Sync + Send + ForbidPattern,
impl<W: Wrap, F> RunOwnAll<W, F>where
F: Clone + Sync + Send + ForbidPattern,
sourcepub fn borrow_mut(&mut self) -> RunBorrow<'_, W, ForbidRef<'_, F>>
pub fn borrow_mut(&mut self) -> RunBorrow<'_, W, ForbidRef<'_, F>>
Examples found in repository?
src/wfc.rs (line 1420)
1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
pub fn new_wrap_forbid<R: Rng>(
output_size: Size,
global_stats: GlobalStats,
wrap: W,
forbid: F,
rng: &mut R,
) -> Self {
let _ = wrap;
let wave = Wave::new(output_size);
let context = Context::new();
let mut s = Self {
context,
wave,
global_stats,
output_wrap: PhantomData,
forbid,
};
s.borrow_mut().reset(rng);
s
}
}
impl<W: Wrap, F: ForbidPattern> RunOwnAll<W, F>
where
F: Clone + Sync + Send,
{
pub fn borrow_mut(&mut self) -> RunBorrow<W, ForbidRef<F>> {
let core = RunBorrowCore {
context: &mut self.context,
wave: &mut self.wave,
global_stats: &self.global_stats,
output_wrap: self.output_wrap,
};
RunBorrow {
core,
forbid: ForbidRef(&mut self.forbid),
}
}
pub fn step<R: Rng>(&mut self, rng: &mut R) -> Result<Observe, PropagateError> {
self.borrow_mut().step(rng)
}
pub fn collapse<R: Rng>(&mut self, rng: &mut R) -> Result<(), PropagateError> {
self.borrow_mut().collapse(rng)
}
pub fn step<R: Rng>(&mut self, rng: &mut R) -> Result<Observe, PropagateError>
sourcepub fn collapse<R: Rng>(&mut self, rng: &mut R) -> Result<(), PropagateError>
pub fn collapse<R: Rng>(&mut self, rng: &mut R) -> Result<(), PropagateError>
Examples found in repository?
src/retry.rs (line 135)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
fn retry<W, F, R>(&mut self, mut run: RunOwnAll<W, F>, rng: &mut R) -> Self::Return
where
W: Wrap + Clone + Sync + Send,
F: ForbidPattern + Clone + Sync + Send,
R: Rng,
{
loop {
match run.collapse(rng) {
Ok(()) => (),
Err(PropagateError::Contradiction) => continue,
}
return run.into_wave();
}
}
}
impl RetryOwnAll for NumTimes {
type Return = Result<Wave, PropagateError>;
fn retry<W, F, R>(&mut self, mut run: RunOwnAll<W, F>, rng: &mut R) -> Self::Return
where
W: Wrap + Clone + Sync + Send,
F: ForbidPattern + Clone + Sync + Send,
R: Rng,
{
loop {
match run.collapse(rng) {
Ok(()) => return Ok(run.into_wave()),
Err(e) => {
if self.0 == 0 {
return Err(e);
} else {
self.0 -= 1;
}
}
}
}
}
pub fn wave_cell_ref(&self, coord: Coord) -> WaveCellRef<'_>
pub fn wave_cell_ref_iter(&self) -> impl Iterator<Item = WaveCellRef<'_>>
pub fn wave_cell_ref_enumerate(
&self
) -> impl Iterator<Item = (Coord, WaveCellRef<'_>)>
sourcepub fn into_wave(self) -> Wave
pub fn into_wave(self) -> Wave
Examples found in repository?
src/retry.rs (line 139)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
fn retry<W, F, R>(&mut self, mut run: RunOwnAll<W, F>, rng: &mut R) -> Self::Return
where
W: Wrap + Clone + Sync + Send,
F: ForbidPattern + Clone + Sync + Send,
R: Rng,
{
loop {
match run.collapse(rng) {
Ok(()) => (),
Err(PropagateError::Contradiction) => continue,
}
return run.into_wave();
}
}
}
impl RetryOwnAll for NumTimes {
type Return = Result<Wave, PropagateError>;
fn retry<W, F, R>(&mut self, mut run: RunOwnAll<W, F>, rng: &mut R) -> Self::Return
where
W: Wrap + Clone + Sync + Send,
F: ForbidPattern + Clone + Sync + Send,
R: Rng,
{
loop {
match run.collapse(rng) {
Ok(()) => return Ok(run.into_wave()),
Err(e) => {
if self.0 == 0 {
return Err(e);
} else {
self.0 -= 1;
}
}
}
}
}