Greed: Difference between revisions
m
syntax highlighting fixup automation
(Added Wren header.) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 22:
Windows console version.
[[File:newGreedCpp.png|200px|thumb|right]]
<
#include <windows.h>
#include <iostream>
Line 143:
greed g; g.play(); return 0;
}
</syntaxhighlight>
=={{header|Factor}}==
This uses Factor's own user interface vocabularies. Use hjkl-bnyu (vi-keys) to move.
<
combinators.short-circuit fry grouping io io.styles kernel lexer
literals make math math.matrices math.parser math.vectors random
Line 321:
] with-ui ;
MAIN: greed-window</
{{out}}
[https://i.imgur.com/3IEo8cC.png Screenshot of the game after a loss]
Line 333:
Note that this version uses the Z key (rather than the Y key) to move diagonally downwards to the left. A leave key, L, has also been added in case one wants to end the game prematurely.
<
import (
Line 557:
}
}
}</
=={{header|Kotlin}}==
Line 563:
{{works with|Windows 10}}
Note that this version uses the Z key (rather than the Y key) to move diagonally downwards to the left.
<
import kotlinx.cinterop.*
Line 760:
srand(time(null).toInt())
Greed().play()
}</
=={{header|Java}}==
Line 770:
=={{header|Julia}}==
GUI version. Click a square adjacent to the "@" symbol to move.
<
struct BState
Line 871:
# greedapp(22, 79) # This would be per task, though a smaller game board is nicer
greedapp(12, 29)
</syntaxhighlight>
=={{header|Nim}}==
Line 883:
And we also added a score field to the BState object in order to restore the correct score when undoing a move.
<
import gintro/[gobject, glib, gtk, gio]
Line 1,031:
let app = newApplication(Application, "Rosetta.greed")
discard app.connect("activate", activate)
discard app.run()</
=={{header|Perl}}==
{{trans|Raku}}
<
use warnings;
use feature 'say';
Line 1,100:
if ($c eq 'c') { execute( 1, 0) if $Y < $h } # South
if ($c eq 'v') { execute( 1, 1) if $X < $w and $Y < $h } # South-East
}</
=={{header|Phix}}==
{{trans|C++}}
<
sequence board
Line 1,209:
end while
end procedure
play()</
=={{header|PicoLisp}}==
Computer play by selecting random road. [https://asciinema.org/a/369181 Demo] is here.
<syntaxhighlight lang="picolisp">
(load "@lib/simul.l")
(seed (in "/dev/urandom" (rd 8)))
Line 1,311:
(=: A 0) ) )
(display) ) )
(bye)</
=={{header|Raku}}==
{{trans|Phix}}
<syntaxhighlight lang="raku"
srand 123456;
Line 1,367:
when 'v' { execute( 1, 1) if X < w and Y < h } # South-East
}
}</
=={{header|REXX}}==
Line 1,375:
Pointers (above and to the right of) the grid are included to help identify where the current location is.
<
parse arg sw sd @ b ?r . /*obtain optional argumenst from the CL*/
if sw=='' | sw=="," then sw= 79 /*cols specified? Then use the default*/
Line 1,451:
if r==!r then _= _ '◄' /*indicate row of current position. */
if tell then say _ /*display a row of grid to screen. */
end /*r*/; say; return # /*SHOW also counts # of blanks (score).*/</
A note on the OUTPUT sections: each (cleared) screen displayed is shown below as a separate OUTPUT section.
|