Post by timur77 on Apr 1, 2020 15:10:52 GMT -5
Game "Bull-Cow"
The computer makes a 4-digit number, the numbers in the number are not repeated. The player enters a number. If either a number is in the number, but it is not in its place, the program issues a 1-cow. If the figure stands in its place, then the program writes 1-bull. The result should be a 4-bull.
Here is the link
Bull_Cow_Setup.zip
Here is the code
The computer makes a 4-digit number, the numbers in the number are not repeated. The player enters a number. If either a number is in the number, but it is not in its place, the program issues a 1-cow. If the figure stands in its place, then the program writes 1-bull. The result should be a 4-bull.
Here is the link
Bull_Cow_Setup.zip
Here is the code
nomainwin
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
d=WindowWidth
sh=WindowHeight
WindowWidth = 700
WindowHeight = 400
UpperLeftX = d/2-350
UpperLeftY = sh/2-200
ListboxColor$ = "white"
TextboxColor$ = "white"
open "anecdot.dll" for input as #file
loadbmp "bg","BK.bmp"
dim ar$(1000)
dim b$(10)
dim zch(5)
dim c$(5)
dim an$(200)
sch=0
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
[new2]
playwave ""
playwave "fm.wav", loop
for i=0 to sch+1
ar$(i)=""
next i
sch=0
for i=0 to 9
b$(i)=str$(i)
next i
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
[m5]
i=1
for i=1 to 4
[m3]
zch(i)=int(rnd(1)*10)
if i=1 goto [m2]
for a=1 to i-1
if zch(a)=zch(i) goto [m3]
next a
[m2]
next i
for i=1 to 4
if i=1 goto [m6]
for a=1 to i-1
if zch(a)=zch(i) goto [m5]
next a
[m6]
next i
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
statictext #n.st1, "Число", 230, 0, 55, 25
textbox #n.tb1, 285, 0, 90, 25
button #n.start, "Проверить", [start], UL, 375, 0, 100, 25
button #n.new, "Заново", [new1], UL, 405, 25, 70, 25
listbox #n.lb1, ar$(),[m1], 230, 50, 245, 200
statictext #n.st2, "Отгадай числоХХХХ", 230, 25, 175, 25
graphicbox #n.g1, 0,0,700,400
texteditor #n.te1, 350, 250, 1, 1
OPEN "Бык-Корова" FOR window_nf AS #n
print #n.g1, "drawbmp bg ";0;" ";0
print #n.g1, "drawbmp bg ";0;" ";0
print #n, "font courier_new 12";
print #n.te1, "!font courier_new 8";
print #n.te1, "!hide"
print #n, "trapclose [exit]"
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
#n.te1 "!contents #file";
#n.te1 "!contents? filetext$";
print #n.te1, "!cls";
aa=0
lenf=len(filetext$)
for i=1 to lenf
if mid$(filetext$,i,3)="***" then goto [f1] else goto [f2]
[f1]
for a=i+1 to lenf
if mid$(filetext$,a,3)="***" then aa=aa+1:an$(aa)=mid$(filetext$,i+1,a-i-3):i=a-1:goto [f2]
next a
[f2]
next i
[f3]
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
#n.g1 "flush"
wait
'=========================================================
[new1]
close #n
goto [new2]
'=========================================================
[exit]
playwave ""
close #file
CLOSE #n
END
'=========================================================
[start]
print #n.te1, "!cls";
print #n.te1, an$(int(rnd(1)*aa+1))
print #n.te1, "!origin 1 1" ;
notice an$(int(rnd(1)*aa+1))
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
bb=0
kk=0
print #n.tb1, "!contents? chislo$"
print #n.st2, chislo$
if len(chislo$)<>4 then wait
for i=1 to 4
c$(i)=mid$(chislo$,i,1)
if asc(c$(i))<48 or asc(c$(i))>57 then wait
next i
for i=1 to 4
if i=1 goto [m4]
for a=1 to i-1
if c$(a)=c$(i) goto wait
next a
[m4]
next i
for i=1 to 4
if c$(i)=b$(zch(i)) then bb=bb+1
next i
for i=1 to 4
for a=1 to 4
if c$(i)=b$(zch(a)) and a<>i then kk=kk+1
next a
next i
'= = = = = = = = = = = = = = = = = = = = = = = = = = = =
sch=sch+1
buff$=str$(sch)+" "+chislo$+" Бык="+str$(bb)+" Корова="+str$(kk)
for i=sch to 1 step -1
ar$(i)=ar$(i-1)
next i
ar$(1)=buff$
print #n.lb1, "reload"
if bb=4 goto [finish]
wait
'=========================================================
[m1]
wait
'=========================================================
[finish]
print #n.st2, "УГАДАЛ!!!"
notice "Это Победа!"
goto [new1]
'=========================================================