! Copyright (C) 2021 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays calendar combinators combinators.extras
+USING: accessors arrays calendar combinators combinators.smart
continuations kernel math math.functions math.parser math.ranges
namespaces prettyprint random sequences system threads ;
IN: retries
] [
current-retries get _ retries-failed
] if
- ] loop1
+ ] smart-loop
] with-variable ; inline
: retries ( quot time-strategy n/seq -- result )
! Copyright © 2008 Reginald Keith Ford II
! 24, the Factor game!
-USING: accessors backtrack combinators continuations formatting fry io
-kernel math prettyprint quotations random sequences ;
+USING: accessors backtrack combinators combinators.smart
+continuations formatting fry io kernel math prettyprint
+quotations random sequences ;
IN: 24-game
: nop ( -- ) ;
4 [ 10 random ] replicate ;
: make-24 ( -- array )
- f [ dup first4 makes-24? ] [ drop random-4 ] do until ;
+ [ random-4 dup first4 makes-24? not ] smart-loop ;
: q ( -- obj ) "quit" ;
USING: accessors arrays assocs calendar circular
colors.constants combinators combinators.short-circuit
-destructors formatting fry images.loader kernel locals math
-math.order math.parser namespaces opengl opengl.textures random
-sequences timers ui ui.commands ui.gadgets ui.gadgets.toolbar
-ui.gadgets.tracks ui.gadgets.worlds ui.gestures ui.pens.solid
-ui.render ui.tools.browser words ;
+combinators.smart destructors formatting fry images.loader
+kernel locals math math.order math.parser namespaces opengl
+opengl.textures random sequences timers ui ui.commands
+ui.gadgets ui.gadgets.toolbar ui.gadgets.tracks
+ui.gadgets.worlds ui.gestures ui.pens.solid ui.render
+ui.tools.browser words ;
IN: minesweeper
[ #mines ] [ #flagged ] bi - ;
: unmined-cell ( cells -- cell )
- f [ dup mined?>> ] [ drop dup random random ] do while nip ;
+ '[ _ random random dup mined?>> ] smart-loop ;
: place-mines ( cells n -- cells )
[ dup unmined-cell t >>mined? drop ] times ;