fb:porticula NoPaste
Frontend.bas
Uploader: | Muttonhead |
Datum/Zeit: | 03.09.2015 08:06:20 |
#include once "KUI.bas"
declare sub DrawBoard
declare sub DirDot(index as integer,direction as integer)
type boardposition
x as integer
y as integer
stonecolor as integer'0=kein Stein,1=weiss,2=schwarz
end type
dim as Kuenstliche_UnIntelligenz kui
'******************************************************************************
'******************************************************************************
'******************************************************************************
screen 19,32
dim shared as boardposition Board(23)
restore pdata
for i as integer=0 to 23
read Board(i).x
read Board(i).y
Board(i).x +=597
board(i).y +=22
Board(i).stonecolor=0
next i
DrawBoard
dim as integer mx,my,dx,dy,ff,rp2,mb,lmb,oldlmb
dim as string key
rp2=14*14'Quadrat des Check-Radius um eine Spielposition herum
oldlmb=0
do
sleep 1
'Maus****************************************************
'Steine setzen
getmouse mx,my,,mb
lmb=mb and 1
if (oldlmb>0) and (lmb=0) then'wenn linke Maustaste wieder losgelassen = Klick
for i as integer=0 to 23
dx=Board(i).x - mx
dy=Board(i).y - my
if (dx*dx + dy*dy) <= rp2 then'wenn Maus über einer Brettposition, also auf oder innerhalb des Checkradius
Board(i).stonecolor= (Board(i).stonecolor+1) mod 3'Stein setzen / Rotation der Farbe
DrawBoard
end if
next i
end if
oldlmb=lmb
'Keyboard************************************************
key=inkey
'Board laden/speichern
select case key
case "s"
ff=freefile
open "Boardsave" for output as ff
for i as integer=0 to 23
print #ff,Board(i).stonecolor
next i
close ff
case "l"
ff=freefile
open "Boardsave" for input as ff
for i as integer=0 to 23
input #ff,Board(i).stonecolor
next i
close ff
DrawBoard
case " "
'Übertragen des Spielfeldes in die Statistikabteilung
for i as integer=0 to 23
kui.Setze_Farbe( i , Board(i).stonecolor)
next i
kui.Erstelle_Statistik
cls
DrawBoard
kui.Drucke_Statistik
case "1"
'Übertragen des Spielfeldes in die Statistikabteilung
for i as integer=0 to 23
kui.Setze_Farbe( i , Board(i).stonecolor)
next i
kui.Berechne_Zug(1)
cls
DrawBoard
DirDot(kui.SteinIndex,kui.ZugRichtung)
print kui.Score
case "2"
for i as integer=0 to 23
kui.Setze_Farbe( i , Board(i).stonecolor)
next i
kui.Berechne_Zug(2)
cls
DrawBoard
DirDot(kui.SteinIndex,kui.ZugRichtung)
print kui.Score
end select
loop until key=chr(27)
'******************************************************************************
'******************************************************************************
'******************************************************************************
sub DrawBoard
screenlock
'Holz
line ( Board(0).x-20,Board(0).y-20 ) - ( Board(4).x+20,Board(4).y+20 ),&HFF6600,bf
'Linien
line( Board(0).x , Board(0).y )-( Board(4).x , Board(4).y ),&HFFFFFF,b
line( Board(8).x , Board(8).y )-( Board(12).x , Board(12).y ),&HFFFFFF,b
line( Board(16).x , Board(16).y )-( Board(20).x , Board(20).y ),&HFFFFFF,b
line( Board(1).x , Board(1).y )-( Board(17).x , Board(17).y ),&HFFFFFF,b
line( Board(3).x , Board(3).y )-( Board(19).x , Board(19).y ),&HFFFFFF,b
line( Board(5).x , Board(5).y )-( Board(21).x , Board(21).y ),&HFFFFFF,b
line( Board(7).x , Board(7).y )-( Board(23).x , Board(23).y ),&HFFFFFF,b
'Steine
for i as integer=0 to 23
if Board(i).stonecolor=1 then circle(Board(i).x,Board(i).y),8,&HFFFFFF,,,,f
if Board(i).stonecolor=2 then circle(Board(i).x,Board(i).y),8,&H000000,,,,f
next i
screenunlock
end sub
sub DirDot(index as integer,direction as integer)
dim as integer ox,oy
select case direction
case 0'hoch
ox=0
oy=-6
case 1'rechts
ox=6
oy=0
case 2'unten
ox=0
oy=6
case 3'links
ox=-6
oy=0
end select
if Board(index).stonecolor=1 then
circle(Board(index).x+ox,Board(index).y+oy),3,&H008800,,,,f
circle(Board(index).x,Board(index).y),8,&H008800
end if
if Board(index).stonecolor=2 then
circle(Board(index).x+ox,Board(index).y+oy),3,&H00FF00,,,,f
circle(Board(index).x,Board(index).y),8,&H00FF00
end if
end sub
'Positionen
' 0-----------1-----------2
' | | |
' | 8-------9------10 |
' | | | | |
' | | 16--17--18 | |
' | | | | | |
' 7--15--23 19--11---3
' | | | | | |
' | | 22--21--20 | |
' | | | | |
' | 14------13------12 |
' | | |
' 6-----------5-----------4
pdata:
'äusseres Viereck 0-7
data 0,0, 90,0, 180,0, 180,90, 180,180, 90,180, 0,180, 0,90
'mittleres Viereck 8-15
data 30,30, 90,30, 150,30, 150,90, 150,150, 90,150, 30,150, 30,90
'inneres Viereck 16-23
data 60,60, 90,60, 120,60, 120,90, 120,120, 90,120, 60,120, 60,90