Mastermind: Difference between revisions
→{{header|EasyLang}}
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 1,028:
[https://easylang.online/apps/mastermind.html Run it]
<syntaxhighlight lang="text">
col[] = [ 802 990 171 229 940 808 ]
len code[] 4
len guess[] 4
Line 1,036 ⟶ 1,037:
.
func draw_rate r black white . .
for j
for c
move c * 3.5 + 71.5 r * 11.5 + 10.4 + j * 3.5
if black > 0
Line 1,055 ⟶ 1,056:
.
func show_code . .
color
move 22 0
rect 46 8
for i
move i * 8 +
color col[code[i]]
circle 2
Line 1,065 ⟶ 1,066:
.
func draw_guess . .
for c
move c * 12 +
color col[guess[c]]
circle 3.8
Line 1,072 ⟶ 1,073:
.
func next_row . .
color
linewidth 11
move
line
call draw_guess
move 73.5 row * 11.5 + 12
Line 1,081 ⟶ 1,082:
circle 5.0
color 753
move 71.5 row * 11.5 +
textsize 7
text "✓"
Line 1,087 ⟶ 1,088:
func rate . .
move 73.5 row * 11.5 + 12
color
circle 5.2
c[] = code[]
g[] = guess[]
for i
if c[i] = g[i]
black += 1
Line 1,098 ⟶ 1,099:
.
.
for i
for j
if c[i] = g[j]
white += 1
Line 1,108 ⟶ 1,109:
.
call draw_rate row black white
color
linewidth 12
move 17 row * 11.5 + 12
Line 1,129 ⟶ 1,130:
func new . .
call init_vars
for i
code[i] = random 6
.
color
move 10 10
rect 70 80
Line 1,144 ⟶ 1,145:
linewidth 7
move 28 3.5
line
move 30 1.
color 864
textsize 4
Line 1,157 ⟶ 1,158:
move 80 10
line 80 96
for r
for c
move c * 12 + 20 r * 11.5 + 12
circle 2
Line 1,164 ⟶ 1,165:
call draw_rate r 0 0
.
guess[
guess[1] = 0▼
guess[2] = 1
guess[3] =
call next_row
.
func do_move . .
c = (mouse_x - 15) div 12 + 1
guess[c] =
call draw_guess
.
Line 1,186 ⟶ 1,187:
.
.
call new
</syntaxhighlight>
=={{header|FreeBASIC}}==
|