Jump to content

Mastermind: Difference between revisions

m (syntax highlighting fixup automation)
Line 1,028:
[https://easylang.online/apps/mastermind.html Run it]
 
<syntaxhighlight lang="text">col[] = [ 802 990 171 229 950 808 ]
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 range= 20 to 1
for c range= 20 to 1
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 531532
move 22 0
rect 46 8
for i range= 1 to 4
move i * 8 + 2820 3
color col[code[i]]
circle 2
Line 1,065 ⟶ 1,066:
.
func draw_guess . .
for c range= 1 to 4
move c * 12 + 208 row * 11.5 + 12
color col[guess[c]]
circle 3.8
Line 1,072 ⟶ 1,073:
.
func next_row . .
color 420643
linewidth 11
move 1718.5 row * 11.5 + 12
line 6057.5 row * 11.5 + 12
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 + 8.59
textsize 7
text "✓"
Line 1,087 ⟶ 1,088:
func rate . .
move 73.5 row * 11.5 + 12
color 531532
circle 5.2
c[] = code[]
g[] = guess[]
for i range= 1 to 4
if c[i] = g[i]
black += 1
Line 1,098 ⟶ 1,099:
.
.
for i range= 1 to 4
for j range= 1 to 4
if c[i] = g[j]
white += 1
Line 1,108 ⟶ 1,109:
.
call draw_rate row black white
color 531532
linewidth 12
move 17 row * 11.5 + 12
Line 1,129 ⟶ 1,130:
func new . .
call init_vars
for i range= 1 to 4
code[i] = random 6
.
color 531532
move 10 10
rect 70 80
Line 1,144 ⟶ 1,145:
linewidth 7
move 28 3.5
line 5856 3.5
move 30 1.58
color 864
textsize 4
Line 1,157 ⟶ 1,158:
move 80 10
line 80 96
for r range= 80 to 7
for c range= 40 to 3
move c * 12 + 20 r * 11.5 + 12
circle 2
Line 1,164 ⟶ 1,165:
call draw_rate r 0 0
.
guess[01] = 01
guess[1] = 0
guess[2] = 1
guess[3] = 12
guess[14] = 02
call next_row
.
func do_move . .
c = (mouse_x - 15) div 12 + 1
guess[c] = (guess[c] + 1) mod 6 + 1
call draw_guess
.
Line 1,186 ⟶ 1,187:
.
.
call new</syntaxhighlight>
</syntaxhighlight>
 
=={{header|FreeBASIC}}==
2,053

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.