Mastermind: Difference between revisions

151 bytes removed ,  4 years ago
m
(→‎{{header|Python}}: Edited Python example to match rules as discussed under the section about the Julia implementation)
Line 244:
for j range 2
for c range 2
move c * 3 + 6776.5 r * 11.5 + 1210.65 + j * 3
if black > 0
color 000
Line 270:
.
.
func next_rowdraw_guess . .
for i range 4
guess[i] = -1
.
for c range 4
move c * 912 + 3225 row * 11.5 + 1412
color 900col[guess[c]]
circle 23.8
color 420
circle 1.7
.
.
func next_row . .
call draw_guess
move 6478 row * 11.5 + 1112
color 420
circle 14.75
move 6475 row * 11.5 + 119.9
color 642
text "OK"
.
func rate . .
move 64.278 row * 11.5 + 11.212
test[] = code[]
color 642
circle 34.28
testc[] = code[]
g[] = guess[]
for i range 4
if guessc[i] = testg[i]
black += 1
testc[i] = -21
guessg[i] = -12
.
.
for i range 4
for j range 4
if guessc[i] = testg[j]
white += 1
testc[ji] = -21
guessg[ij] = -12
.
.
.
move 64 row * 11 + 11
color 642
rect 9 6
#
call draw_rate row black white
row -= 1
Line 321 ⟶ 325:
.
color 642
move 15 010
rect 70 10080
linewidth 0.810
move 2710 05
line 10 95
line 90 95
line 90 5
line 10 5
color 420
linewidth 7
move 27 0
rectmove 4633 83.5
moveline 3563 23.5
move 2535 101
color 864
textsize 4.5
text "Mastermind"
color 420
linewidth 0.5
move 25 10
linemove 2515 9410
moveline 7515 1096
linemove 7572 9410
line 72 96
move 85 10
line 85 96
for r range 8
for c range 4
move c * 912 + 3225 r * 11.5 + 1412
circle 2
.
call draw_rate r 0 0
.
for i range 4
guess[i] = -1i
.
call next_row
.
#
func do_move . .
c = trunc ((mouse_x - 27.520) / 912)
move c * 9 + 32 row * 11 + 14
guess[c] = (guess[c] + 1) mod 6
call draw_guess
color col[guess[c]]
circle 3.2
#
if guess[0] > -1 and guess[1] > -1 and guess[2] > -1 and guess[3] > -1
move 64 row * 11 + 11
color 900
rect 8.6 6
move 64.2 row * 11 + 11.2
color 642
rect 8.2 5.6
color 420
move 64.6 row * 11 + 11.6
text "OK"
.
.
on mouse_down
if row = -1
call new
elif mouse_y > row * 11.5 + 97 and mouse_y < row * 11.5 + 1917
if mouse_x > 2820 and mouse_x < 63.566
call do_move
elif mouse_x > 6572 and mouse_x < 7785
call rate
if guess[0] > -1 and guess[1] > -1 and guess[2] > -1 and guess[3] > -1
call rate
.
.
.
.
textsize 5
linewidth 0.8
call new</lang>
 
1,973

edits