Wordle comparison: Difference between revisions
Content added Content deleted
(→{{header|FutureBasic}}: Replaced with more compact revised code) |
|||
Line 357: | Line 357: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
This compact |
This compact function returns a byte array (as a pstring) with 2, 1, 0, for matched, mismatched, unmatched. It is useful for games up to 15 chars wide, and is case sensitive as specified. |
||
<syntaxhighlight lang="futurebasic"> |
<syntaxhighlight lang="futurebasic"> |
||
⚫ | |||
⚫ | |||
⚫ | |||
str255 n : str15 c : c[0] = w2[0] : short r |
|||
⚫ | |||
⚫ | |||
if w2[r] = w1[r] then c[r] = 2 else n[w1[r]]++ |
|||
/* Returns colors in passed array "cArray()". */ |
|||
byte count(255) |
|||
short r |
|||
for r = 1 to wordle[0] |
|||
if guess[r] == wordle[r] then cArray(r) = fn colorGreen : continue |
|||
count(wordle[r])++ : cArray(r) = fn colorGray |
|||
next |
next |
||
⚫ | |||
if c[r] == 0 then if n[w2[r]] then n[w2[r]]-- : c[r] = 1 |
|||
⚫ | |||
if cArray(r) == fn colorGreen then continue |
|||
if count(guess[r]) then count(guess[r])-- : cArray(r) = fn colorYellow |
|||
next |
next |
||
⚫ | |||
</syntaxhighlight> |
|||
⚫ | |||
This function uses the array to display output mimicking the appearance of WORDLE. |
|||
<syntaxhighlight lang="futurebasic"> |
|||
⚫ | |||
mda(0) = {fn ColorDarkGray,fn ColorWithRGB(.7,.6,.3,1),fn ColorWithRGB(.3,.6,.3,1)} |
|||
colorref color(15) |
|||
⚫ | |||
short r |
|||
str15 color : short r |
|||
fn |
color = fn colorString( wordle, guess ) |
||
text @"menlo", |
text @"menlo bold", 14, fn colorLightGray |
||
text ,,fn |
print %( 20, y ) wordle : text ,,fn colorWhite |
||
for r = 1 to guess[0] |
for r = 1 to guess[0] |
||
rect fill ( x, y |
rect fill ( x, y, 24, 24 ), mda_object( color[r] ) |
||
print %( x + 5, y ) chr$(guess[r]); : x += |
print %( x + 7.5, y + 1 ) chr$( guess[r] ); : x += 28 |
||
next |
next |
||
x = 80 : y += 28 |
|||
end fn |
end fn |
||
window 1, @"Wordle Compare |
window 1, @"FB Wordle Compare", ( 0, 0, 265, 290 ) |
||
WindowSetBackgroundColor( 1, fn Colorblack ) |
|||
fn show( "ALLOW", "LOLLY" ) |
|||
fn |
fn wordleCompare( "ALLOW", "LOLLY" ) |
||
fn |
fn wordleCompare( "CHANT", "LATTE" ) |
||
fn |
fn wordleCompare( "ROBIN", "SONIC" ) |
||
fn |
fn wordleCompare( "PROUD", "LEAST" ) |
||
fn |
fn wordleCompare( "STEAL", "LEAST" ) |
||
fn |
fn wordleCompare( "LEAST", "LEAST" ) |
||
fn |
fn wordleCompare( "FULLY", "LABEL" ) |
||
fn |
fn wordleCompare( "We're", "She's" ) |
||
fn |
fn wordleCompare("LONGER", "STRING") |
||
handleevents |
handleevents |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[[File: |
[[File:Wordle Comparison in FutureBasic.png]] |
||
=={{header|Go}}== |
=={{header|Go}}== |