Kniffel Klon
Übersicht

![]() |
StepTigerBetreff: Kniffel Klon |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich dachte mir gerade so, dass ich mal einen kleinen Kniffel Klon mache.
Gab ja erst neulich einen, trotzdem bin ich mal so dreißt, einen neuen Thread aufzumachen ^^ Denn: Diesmal kann man gegen einen Computer spielen. Der Code ist natürlich extrem ausbaufähig und der Computer ist noch relativ dumm, auch wenn schon Ansätze von Intelligenz da sind. Wird noch ausgebaut. *edit* KI verbessert hier der code: Code: [AUSKLAPPEN] Graphics 800,600,32,2
SeedRnd MilliSecs() Global nul=0 Global mach[5],wurf[5] Global wurfed[6] Global players, dran, on Dim tp.player(4) players=Input("Wie viele Spieler? ") Graphics 200*players,500,0,2 players=players-1 Type player Field points[14] Field name$ Field computer End Type For x=1 To players+1 FlushKeys tp.player(x)=New player y$=Input$("Name Spieler "+x+"? ") tp(x)\name$=y$ Print "Spieler "+x+" Computer? (j,n) " FlushKeys Repeat:Delay 1:s=KeyHit(36):z=KeyHit(49):Until s Or z If s=1 Then Print "Ja" Else Print "Nein" If s=1 Then d=1 Else d=0 tp(x)\computer=d Next SetBuffer BackBuffer() While Not KeyDown(1) Cls comp=0 If tp(dran+1)\computer=0 If KeyHit(57) And on<3 Wuerfel(mach[1],mach[2],mach[3],mach[4],mach[5]) on=on+1 EndIf mh=MouseHit(1) InputAction(mh) Else on=on+1 Wuerfel(mach[1],mach[2],mach[3],mach[4],mach[5]) Computer() comp=1 If on=3 on=0 For x=1 To 5 mach[x]=0 wurf[x]=0 Next EndIf EndIf For x=1 To 6 Text x*40,420,wurfed[x] Next ch=0 DrawPlayers() DrawWuerfel(mh) Flip If comp=1 Then Delay 1500 Wend End Function InputAction(mh) mx=MouseX() my=MouseY() yplus=0 For x=1 To 14 yplus=yplus+20 If x=6 Or x=7 Then yplus=yplus+10 x1=100+dran*200 x2=200+dran*200 y1=yplus y2=yplus+20 If mx>x1 And mx<x2 And my>y1 And my<y2 And mh=1 And tp(dran+1)\points[x]=0 And x<>7 tp(dran+1)\points[x]=Punkte(x) on=0 dran=dran+1 For x=1 To 5 mach[x]=0 wurf[x]=0 Next If dran>players Then dran=0 EndIf Next End Function Function Computer() Local sammel[14] Local maxp[14] maxp[1]=5 maxp[2]=10 maxp[3]=15 maxp[4]=20 maxp[5]=25 maxp[6]=30 maxp[7]=0 maxp[8]=30 maxp[9]=30 maxp[10]=25 maxp[11]=30 maxp[12]=40 maxp[13]=50 maxp[14]=30 If on=3 best=0 bestpoint=0 bestper#=0 For x=1 To 14 If x<>7 per#=Punkte(x)/maxp[x] If (Punkte(x)>=bestpoint And Punkte(x)<1000) And tp(dran+1)\points[x]=0 And (Abs(bestper#-per#)<10 Or bestper#=0) best=x bestpoint=Punkte(x) EndIf EndIf Next If best=0 low=0 lowpoint=1000 For x=1 To 14 If x<>7 If tp(dran+1)\points[x]=0 If maxp[x]<lowpoint low=x lowpoint=maxp[x] EndIf EndIf EndIf Next best=low EndIf tp(dran+1)\points[best]=Punkte(best) dran=dran+1 If dran>players Then dran=0 Else entsch=0 entschpunk=0 entschdo#=0 wich#=.1 wichloss#=.6 For x=1 To 14 If tp(dran+1)\points[x]=0 And x<>7 makeit#=((theper#(x)*wich#+(1.-wich#))*maxp[x])-((theper#(entsch)*wich#+(1.-wich#))*maxp[entsch]) If x<14 makeit#=((makeit#) *((maxp[x]*theper#(x))/(maxp[x])))*wichloss#+(makeit#*(1.-wichloss#)) Else makeit#=((makeit#) *(Punkte(14))/(maxp[x])*wichloss#)+(makeit#*(1.-wichloss#)) EndIf If makeit#>.8 Or entsch=0 entsch=x entschpunk=maxp[x] EndIf EndIf Next dothem(x) EndIf End Function Function dothem(fu) Local ww[6] fu2=fu If fu>0 And fu<7 Then fu2=1 For x=1 To 5 mach[x]=0 Next Select fu2 Case 1 For x=1 To 5 If wurf[x]=fu Then mach[x]=1 Next Case 8 max=0 tmax=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>max Then max=ww[x]:tmax=x Next max=3 For x=1 To 5 d=wurf[x] If d=tmax And max>0 Then mach[x]=1:max=max-1 Next Case 9 max=0 tmax=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>max Then max=ww[x]:tmax=x Next max=4 For x=1 To 5 d=wurf[x] If d=tmax And max>0 Then mach[x]=1:max=max-1 Next Case 10 eins=0 zwei=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>teins tzwei=teins zwei=eins eins=x teins=ww[x] ElseIf ww[x]>tzwei zwei=x tzwei=ww[x] EndIf Next If teins>3 Then teins=3 If tzwei>2 Then tzwei=2 For x=1 To 5 d=wurf[x] If d=eins And teins>0 Then teins=teins-1:mach[x]=1 If d=zwei And tzwei>0 Then tzwei=tzwei-1:mach[x]=1 Next Case 11 ranf=0 rlan=0 nlan=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[d]>0 ww[d]=1 nlan=nlan+1 If nlan>rlan rlan=nlan ranf=x-nlan+1 EndIf Else ww[d]=0 nlan=0 EndIf Next For x=1 To 5 d=wurf[x] If ww[d]>0 Then mach[x]=1:ww[d]=0 Next Case 12 ranf=0 rlan=0 nlan=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[d]>0 ww[d]=1 nlan=nlan+1 If nlan>rlan rlan=nlan ranf=x-nlan+1 EndIf Else ww[d]=0 nlan=0 EndIf Next For x=1 To 5 d=wurf[x] If ww[d]>0 Then mach[x]=1:ww[d]=0 Next Case 13 max=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 If ww[d]>ww[max] Then max=d Next For x=1 To 5 If wurf[x]=max Then mach[x]=1 Next Case 14 For x=1 To 5 d=wurf[x] If d>4 Then mach[x]=1 Next End Select End Function Function theper#(fu) per#=0 Local ww[6] fu2=fu If fu>0 And fu<7 Then fu2=1 Select fu2 Case 1 p=0 For x=1 To 5 If wurf[x]=fu Then p=p+1 Next per#=(1./(5.-p)/6.)*(4.-on) horoskop#=.2 chang=0 For x=1 To 6 chang=chang+wurfed[x] Next per#=per#*(1.-horoskop#)+(wurfed[fu]/chang*horoskop#) Case 8 max=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>max Then max=ww[x] Next per#=1./(3.-max)/6.*(4.-on) Case 9 max=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>max Then max=ww[x] Next per#=1./(4.-max)*(4.-on)/6. Case 10 eins=0 zwei=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>eins zwei=eins eins=ww[x] ElseIf ww[x]>zwei zwei=ww[x] EndIf Next If eins>3 Then eins=3 If zwei>2 Then zwei=2 per#=1./(19.-eins*6.)/(13.-zwei*6.)*(4.-on) Case 11 row=0 langrow=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>0 row=row+1 If row>langrow Then langrow=row Else row=0 EndIf Next If langrow>4 Then langrow=4 per#=1./(4.-langrow)/6.*(4.-on) Case 12 row=0 langrow=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>0 row=row+1 If row>langrow Then langrow=row Else row=0 EndIf Next If langrow>5 Then langrow=5 per#=1./(5.-langrow)/6.*(4.-on) Case 13 max=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>max Then max=ww[x] Next per#=1./(31.-max*6.)*(4.-on) Case 14 per#=1 End Select If per#>1 Then per#=1 Return per# End Function Function Punkte(num) Local ww[6] p=0 If num=1 For x=1 To 5 If wurf[x]=1 Then p=p+1 Next ElseIf num=2 For x=1 To 5 If wurf[x]=2 Then p=p+2 Next ElseIf num=3 For x=1 To 5 If wurf[x]=3 Then p=p+3 Next ElseIf num=4 For x=1 To 5 If wurf[x]=4 Then p=p+4 Next ElseIf num=5 For x=1 To 5 If wurf[x]=5 Then p=p+5 Next ElseIf num=6 For x=1 To 5 If wurf[x]=6 Then p=p+6 Next ElseIf num=8; dreierpasch drei=0 y=0 For x=1 To 5 d=wurf[x] y=y+d ww[d]=ww[d]+1 If ww[d]>=3 Then drei=1 Next If drei=1 Then p=y ElseIf num=9; viererpasch vier=0 y=0 For x=1 To 5 d=wurf[x] y=y+d ww[d]=ww[d]+1 If ww[d]>=4 Then vier=1 Next If vier=1 Then p=y ElseIf num=10; full house zwei=0 drei=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next For x=1 To 6 If ww[x]>=3 Then drei=1 ElseIf ww[x]>=2 Then zwei=1 Next If zwei=1 And drei=1 Then p=25 ElseIf num=11; kleine Straße For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next If (ww[3]>0 And ww[4]>0) And ((ww[2]>0 And ww[5]>0) Or (ww[1]>0 And ww[2]>0) Or (ww[5]>0 And ww[6]>0)) Then p=30 ElseIf num=12; große Straße For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 Next If (ww[2] And ww[3] And ww[4] And ww[5]) And (ww[1] Or ww[6]) Then p=40 ElseIf num=13; Kniffel kniffel=0 For x=1 To 5 d=wurf[x] ww[d]=ww[d]+1 If ww[d]>=5 Then kniffel=1 Next If kniffel=1 Then p=50 ElseIf num=14; Chance For x=1 To 5 p=p+wurf[x] Next EndIf If p=0 Then p=1000 Return p End Function Function Wuerfel(t1,t2,t3,t4,t5) If t1=0 Or wurf[1]=0 wurf[1]=Rnd(5)+1 d=wurf[1] wurfed[d]=wurfed[d]+1 EndIf If t2=0 Or wurf[2]=0 wurf[2]=Rnd(5)+1 d=wurf[2] wurfed[d]=wurfed[d]+1 EndIf If t3=0 Or wurf[3]=0 wurf[3]=Rnd(5)+1 d=wurf[3] wurfed[d]=wurfed[d]+1 EndIf If t4=0 Or wurf[4]=0 wurf[4]=Rnd(5)+1 d=wurf[4] wurfed[d]=wurfed[d]+1 EndIf If t5=0 Or wurf[5]=0 wurf[5]=Rnd(5)+1 d=wurf[5] wurfed[d]=wurfed[d]+1 EndIf End Function Function DrawWuerfel(d) For x=1 To 5 If mach[x]=0 Then Color 64,64,255 Else Color 255,0,0 Rect x*40+15,395,20,20 Color 255,255,255 Text x*40+20,400,wurf[x] If d tx=MouseX() ty=MouseY() If tx>x*40+15 And tx<x*40+35 And ty>395 And ty<415 mach[x]=1-mach[x] EndIf EndIf Next End Function Function DrawPlayers() xtip=0 xversch=200 For b.player=Each player Color 0,0,0 Rect xtip*xversch,0,200,20 Rect xtip*xversch,20,200,20 Rect xtip*xversch,40,200,20 Rect xtip*xversch,60,200,20 Rect xtip*xversch,80,200,20 Rect xtip*xversch,100,200,20 Rect xtip*xversch,120,200,20 Rect xtip*xversch,140,200,40 Rect xtip*xversch,180,200,20 Rect xtip*xversch,200,200,20 Rect xtip*xversch,220,200,20 Rect xtip*xversch,240,200,20 Rect xtip*xversch,260,200,20 Rect xtip*xversch,280,200,20 Rect xtip*xversch,300,200,20 Rect xtip*xversch,320,200,20 Rect xtip*xversch,340,200,20 Rect xtip*xversch,360,200,20 gr=127 Color gr,gr,gr If dran=xtip Color 255,0,0 Rect xtip*xversch+1,1,198,18 Color gr,gr,gr Else Rect xtip*xversch+1,1,198,18 EndIf Rect xtip*xversch+1,21,198,18 Rect xtip*xversch+1,41,198,18 Rect xtip*xversch+1,61,198,18 Rect xtip*xversch+1,81,198,18 Rect xtip*xversch+1,101,198,18 Rect xtip*xversch+1,121,198,18 Rect xtip*xversch+1,141,198,38 Rect xtip*xversch+1,181,198,18 Rect xtip*xversch+1,201,198,18 Rect xtip*xversch+1,221,198,18 Rect xtip*xversch+1,241,198,18 Rect xtip*xversch+1,261,198,18 Rect xtip*xversch+1,281,198,18 Rect xtip*xversch+1,301,198,18 Rect xtip*xversch+1,321,198,18 Rect xtip*xversch+1,341,198,18 Rect xtip*xversch+1,361,198,18 Color 255,255,255 Text xtip*xversch+10,1,b\name$ Text xtip*xversch,20,"1" Text xtip*xversch,40,"2" Text xtip*xversch,60,"3" Text xtip*xversch,80,"4" Text xtip*xversch,100,"5" Text xtip*xversch,120,"6" Text xtip*xversch,150,"Bonus" Text xtip*xversch,180,"3er Pasch" Text xtip*xversch,200,"4er Pasch" Text xtip*xversch,220,"Full House" Text xtip*xversch,240,"Kleine Straße" Text xtip*xversch,260,"Große Straße" Text xtip*xversch,280,"Kniffel" Text xtip*xversch,300,"Chance" Text xtip*xversch,320,"Obere Punktzahl" Text xtip*xversch,340,"Untere Punktzahl" Text xtip*xversch,360,"Gesamt" yplus=3 xtip=xtip+1 s=0 For da=1 To 6 If b\points[da]<1000 Then s=s+b\points[da] Next If s>=63 Then b\points[7]=35 s=s+b\points[7] s2=0 For da=8 To 14 If b\points[da]<1000 Then s2=s2+b\points[da] Next Text xtip*xversch-xversch/3,320,s Text xtip*xversch-xversch/3,340,s2 Text xtip*xversch-xversch/3,360,s+s2 For points=1 To 14 yplus=yplus+20 If points=7 Or points=8 Then yplus=yplus+10 If b\points[points] If b\points[points]<1000 Text xtip*xversch-xversch/3,yplus,b\points[points] Else Text xtip*xversch-xversch/3,yplus,"0" EndIf Else Text xtip*xversch-xversch/3,yplus,"-" EndIf Next Next End Function |
||
Noch gestern standen wir am Abgrund, doch heute sind wir schon einen Schritt weiter.
Computer: AMD Sempron 3000+; ATI Radeon 9800 Pro; 512 MB DDR RAM 400Mhz; Asus E7N8X-E Deluxe; Samsung 200GB HD 5.4ns acces t Gewinner: BP Code Compo #2 Π=3.141592653589793238...<--- und das aus dem kopf ![]() Seit der Earthlings-Diskussion überzeugter Fleisch(fr)esser. |
- Zuletzt bearbeitet von StepTiger am Mi, Sep 13, 2006 17:33, insgesamt 4-mal bearbeitet
![]() |
SpionAtom |
![]() Antworten mit Zitat ![]() |
---|---|---|
Du meinst doch nicht etwas DIESEN Thread?!
Ich find meins schöner. Naja die KI ist noch etwas unbeholfen. Und ohne Anleitung weiß man auch gar nicht so recht, was man wie machen soll. Aber wenn du das mit der KI richtig hinbekommst, dann wirst du mir noch ein richtiger Konkurrent ![]() ![]() |
||
os: Windows 10 Home cpu: Intel Core i7 6700K 4.00Ghz gpu: NVIDIA GeForce GTX 1080 |
![]() |
StepTiger |
![]() Antworten mit Zitat ![]() |
---|---|---|
Dekorativer ist deines auf jeden Fall, aber meins hat eine KI ^^
ich kümmer mich heute mal ein bisschen darum, die KI intelligenter werden zu lassen. Doch immerhin: Ich hab die KI nur mit 10 Punkten Vorsprung geschlagen ^^ Zur Tastenbelegung: Space: Würfeln sonst Maus Freue mich über Kritik und natürlich auch über Lob SO! Hab die KI mal wesentlich verbessert, wird aber noch einiges folgen ^^ Bisher: Wahrscheinlichkeitsberechnung, Sammelverfahren, Durchschnittserrechner (steht sich jedoch leider alles ein bissl gegenseitig im Weg) Code siehe oben |
||
Noch gestern standen wir am Abgrund, doch heute sind wir schon einen Schritt weiter.
Computer: AMD Sempron 3000+; ATI Radeon 9800 Pro; 512 MB DDR RAM 400Mhz; Asus E7N8X-E Deluxe; Samsung 200GB HD 5.4ns acces t Gewinner: BP Code Compo #2 Π=3.141592653589793238...<--- und das aus dem kopf ![]() Seit der Earthlings-Diskussion überzeugter Fleisch(fr)esser. |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group