array addition prob

Blitz3D Forums/Blitz3D Programming/array addition prob

I am having a problem in my array addition routines. Being slightly numerically dyslexic I cannot figure out where I went wrong. The whole game code is here minus check routines to change row/col... I took them out since they weren't working well... anyway... nothing else is needed to run this except I may have not taken out the music code... add an ogg of your own :]

; SNARF is only a working title... SNAFU would be better
; Color changing timed(eventually timed) game
; score more for higher colors
; Ralph Dunn
Graphics3D 800,600,16,2
SetBuffer BackBuffer()

SeedRnd(MilliSecs())
player=CreatePivot()
camera=CreateCamera(player)
light=CreateLight()
RotateEntity light,45,45,0
AmbientLight 48,48,48    ; was 32,32,32

EntityType camera,1
PositionEntity camera,0,90,8
RotateEntity camera,90,0,0

Dim boardarea(9,9)
Dim boardx(9)
Dim boardz(9)
Dim turnpiecex(9)
Dim turnpiecez(9)

Global square
Global xx
Global zz
Global what
Global wp
Global bp
Global musicflag
Global dis
Global dat
Global que
Global kolor$
Global strike

; now create an array called boardarea of 10 by 10 and
; fill in the entire matrix with 0
For fillx = 0 To 9
	For fillz=0 To 9
		boardarea(fillx,fillz)=0
	Next
Next
; ################################## Initial Pieces Start Location
boardarea(4,4)=1
boardarea(4,5)=2
boardarea(5,4)=2
boardarea(5,5)=1

strike=5

boardx(0)=-45
boardx(1)=-35
boardx(2)=-25
boardx(3)=-15
boardx(4)=-5
boardx(5)=5
boardx(6)=15
boardx(7)=25
boardx(8)=35
boardx(9)=45

boardz(0)=-45
boardz(1)=-35
boardz(2)=-25
boardz(3)=-15
boardz(4)=-5
boardz(5)=5
boardz(6)=15
boardz(7)=25
boardz(8)=35
boardz(9)=45

annoy=LoadSound("anoy1.ogg")
LoopSound annoy
Global play_annoy=PlaySound(annoy)

; #######################################  Load Mesh Objects
;gameboard=LoadMesh("board.b3d")
;UpdateNormals gameboard
;ScaleEntity gameboard,5.5,5.5,5.5
;EntityShininess gameboard,1

;Global empty=LoadMesh("square.b3d")
Global empty=CreateCube()
ScaleEntity empty,5,5,5
EntityPickMode empty,2
HideEntity empty

;Global bomb=LoadMesh("bomb.b3d")
;EntityShininess bomb,1
;HideEntity bomb

;Global clearpiece=LoadMesh("piece3.b3d"); was piece
Global clearpiece=CreateSphere(12)
ScaleEntity clearpiece,2,2,2
EntityShininess clearpiece,1
HideEntity clearpiece

;Global redpiece=LoadMesh("piece3.b3d")
Global redpiece=CreateSphere(12)
ScaleEntity redpiece,2,2,2
EntityColor redpiece,192,0,0
EntityShininess redpiece,1
HideEntity redpiece

Global blupiece=CopyMesh(redpiece)
EntityColor blupiece,0,0,255
ScaleEntity blupiece,2,2,2
EntityShininess blupiece,1
HideEntity blupiece

Global yellopiece=CopyMesh(redpiece)
EntityColor yellopiece,180,180,0
ScaleEntity yellopiece,2,2,2
EntityShininess yellopiece,1
HideEntity yellopiece

Global violetpiece=CopyMesh(redpiece)
EntityColor violetpiece,138,1,255
ScaleEntity violetpiece,2,2,2
EntityShininess violetpiece,1
HideEntity violetpiece

Global redvioletpiece=CopyMesh(redpiece)
EntityColor redvioletpiece,180,1,180
ScaleEntity redvioletpiece,2,2,2
EntityShininess redvioletpiece,1
HideEntity redvioletpiece

Global orangepiece=CopyMesh(redpiece)
EntityColor orangepiece,255,153,51
ScaleEntity orangepiece,2,2,2
EntityShininess orangepiece,1
HideEntity orangepiece

Global bluvioletpiece=CopyMesh(redpiece)
EntityColor bluvioletpiece,51,0,103
ScaleEntity bluvioletpiece,2,2,2
EntityShininess bluvioletpiece,1
HideEntity bluvioletpiece

Global greenpiece=CopyMesh(redpiece)
EntityColor greenpiece,0,102,0
ScaleEntity greenpiece,2,2,2
EntityShininess greenpiece,1
HideEntity greenpiece

Global redorangepiece=CopyMesh(redpiece)
EntityColor redorangepiece,255,51,1
ScaleEntity redorangepiece,2,2,2
EntityShininess redorangepiece,1
HideEntity redorangepiece

Global yellogreenpiece=CopyMesh(redpiece)
EntityColor yellogreenpiece,51,255,102
EntityShininess yellogreenpiece,1
ScaleEntity yellogreenpiece,2,2,2
HideEntity yellogreenpiece

Global blugreenpiece=CopyMesh(redpiece)
EntityColor blugreenpiece,0,102,102
EntityShininess blugreenpiece,1
ScaleEntity blugreenpiece,2,2,2
HideEntity blugreenpiece

Global yelloorangepiece=CopyMesh(redpiece)
EntityColor yelloorangepiece,255,153,1
EntityShininess yelloorangepiece,1
ScaleEntity yelloorangepiece,2,2,2
HideEntity yelloorangepiece

Global brownpiece=CopyMesh(redpiece)
EntityColor brownpiece,94,53,53
EntityShininess brownpiece,1
ScaleEntity brownpiece,2,2,2
HideEntity brownpiece

; ######################################  Plunk Tiles
For xx=0 To 9
	For zz=0 To 9
		e=CopyEntity (empty)
		PositionEntity e,boardx(xx),-5,boardz(zz) ; was 1 for me
	Next
Next
; ############################################## Start of Game Loop
ShowPointer 

musicflag=1 ; For the rasta othello player in each of us!
get_piece()
init_board()
setup_board()

While Not KeyDown(1)

x=MouseX()
y=MouseY()

e=CameraPick(camera,x,y)
	If e<>entity#
		If entity Then EntityColor entity,255,255,255 
		entity#=e
	EndIf
	
If KeyHit(29)=True Then
	PositionEntity camera,0,53,-69
	RotateEntity camera,35,0,0
EndIf

If KeyHit(50)>=1 Then musicflag=1-musicflag

If KeyHit(56)=True Then
	PositionEntity camera,0,90,8
	RotateEntity camera,90,0,0
EndIf

If MouseHit(1) = True Then
	hat=CameraPick(camera,x,y)
	If hat=0 Then Goto outme
		Select empty 
			Case empty
			xx=EntityX(entity)
			zz=EntityZ(entity) 
			Default 
			pp=0
		End Select
put_piece()
setup_board()
make_new()
get_piece()
.outme

EndIf

If entity#
	EntityColor entity,254,80,232
; 73,253,146 lime 254,216,38 gold 254,80,232 magenta 54,80,252
EndIf

If musicflag=1 Then ChannelVolume play_annoy,0.4 Else ChannelVolume play_annoy,0


UpdateWorld
RenderWorld

Text 0,10,"X: "+x
Text 0,20,"Y: "+y
Text 0,30,"Z: "+z

xp=turnpiecex(0)
zp=turnpiecez(0)

Text 0,100,"XP: "+xp
Text 0,110,"ZP: "+zp

Text 0,120,"DIS: "+kolor$
Text 0,130,"DAT: "+strike

Flip

Wend


End

Function get_piece()

dis=Rand(17)

		Select dis
		Case dis >=0 And dis =< 4
		nub = 7
		kolor$="RED"
		Case 5
		nub=12
		kolor$="BLUE"
		Case 6
		nub=19
		kolor$="VIOLET"
		Case 7
		nub=20
		kolor$="YELLOW"
		Case 8
		nub=26
		kolor$="RED-VIOLET"
		Case 9
		nub=27
		kolor$="ORANGE"
		Case 10
		nub=31
		kolor$="BLUE-VIOLET"
		Case 11
		nub=32
		kolor$="GREEN"
		Case 12
		nub=34
		kolor$="RED-ORANGE"
		Case 13
		nub=39
		kolor$="BROWN"
		Case 14
		nub=42
		kolor$="YELLOW-GREEN"
		Case 15
		nub=44
		kolor$="BLUE-GREEN"
		Case 16
		nub=47
		kolor$="YELLOW-ORANGE"
		Case 17
		nub=0
		kolor$="CLEAR"
		End Select
dis=nub

End Function

Function put_piece()

;###################################### CHECK IF ITS LEGAL
; check and see if its same color :: do nada BAD MOVE
; check If it is brown :: If piececolor = 0 then change to 0
; check if it is white :: change to piececolor

Select xx
	Case -45
	row=0
	Case -35
	row=1
	Case -25
	row=2
	Case -15
	row=3
	Case -5
	row=4
	Case 5
	row=5
	Case 15
	row=6
	Case 25
	row=7
	Case 35
	row = 8
	Case 45
	row=9
End Select

Select zz
	Case -45
	col=0
	Case -35
	col=1
	Case -25
	col=2
	Case -15
	col=3
	Case -5
	col=4
	Case 5
	col=5
	Case 15
	col=6
	Case 25
	col=7
	Case 35
	col= 8
	Case 45
	col=9
End Select

que=boardarea(row,col)

If dis=0 Then ; clear clears any color
	qu=0
	Goto outme
EndIf

If que = dis Then
	strike=strike-1
	; playnoise BOO!
	qu=dis
	Goto outme
EndIf

qu=que+dis

If qu > 45 Then qu = 0 ; this is a weird rule but necessary for GIGO collection

.outme

boardarea(row,col)=qu

End Function

Function setup_board()
Cls
For row=0 To 9
	For col=0 To 9
		what=boardarea(row,col)

			Select what
			Case 7
				red=CopyEntity (redpiece)
				PositionEntity red,boardx(row),4,boardz(col)
			Case 12
				blue=CopyEntity (blupiece)
				PositionEntity blue,boardx(row),4,boardz(col)
			Case 19
				violet=CopyEntity (violetpiece)
				PositionEntity violet,boardx(row),4,boardz(col)
			Case 20
				yellow=CopyEntity (yellopiece)
				PositionEntity yellow,boardx(row),4,boardz(col)
			Case 26
				redviolet=CopyEntity (redvioletpiece)
				PositionEntity redviolet,boardx(row),4,boardz(col)
			Case 27
				orange=CopyEntity (orangepiece)
				PositionEntity orange,boardx(row),4,boardz(col)
			Case 31
				bluviolet=CopyEntity (bluvioletpiece)
				PositionEntity bluviolet,boardx(row),4,boardz(col)
			Case 32
				green=CopyEntity (greenpiece)
				PositionEntity green,boardx(row),4,boardz(col)
			Case 34
				redorange=CopyEntity (redorangepiece)
				PositionEntity redorange,boardx(row),4,boardz(col)
			Case 39
				brown=CopyEntity (brownpiece)
				PositionEntity brown,boardx(row),4,boardz(col)
			Case 42
				yellogreen=CopyEntity (yellogreenpiece)
				PositionEntity yellogreen,boardx(row),4,boardz(col)
			Case 44
				blugreen=CopyEntity (blugreenpiece)
				PositionEntity blugreen,boardx(row),4,boardz(col)
			Case 47
				yelloorange=CopyEntity (yelloorangepiece)
				PositionEntity yelloorange,boardx(row),4,boardz(col)
			Default
			clear=CopyEntity (clearpiece)
				PositionEntity clear,boardx(row),4,boardz(col)
			End Select
	Next
Next

End Function

Function make_new()

dis=Rand(17)

		Select dis
		Case dis >=0 And dis =< 4
		nub = 7
		Case 5
		nub=12
		Case 6
		nub=19
		Case 7
		nub=20
		Case 8
		nub=26
		Case 9
		nub=27
		Case 10
		nub=31
		Case 11
		nub=32
		Case 12
		nub=34
		Case 13
		nub=39
		Case 14
		nub=42
		Case 15
		nub=44
		Case 16
		nub=47
		Case 17
		nub=0
		End Select
dis=nub

End Function

Function init_board()

For row = 0 To 9
	For col = 0 To 9
	i=Rand(17)
	Select i
	Case i >=0 And i =< 4
	numb=7
	Case 5
	numb=12
	Case 6
	numb=19
	Case 7
	numb=20
	Case 8
	numb=26
	Case 9
	numb=27
	Case 10
	numb=31
	Case 11
	numb=32
	Case 12
	numb=34
	Case 13
	numb=39
	Case 14
	numb=42
	Case 15
	numb=44
	Case 16
	numb=47
	Case 17
	numb=0
	End Select	
		boardarea(row,col) = numb
	Next
Next

End Function
I suppose there are several better ways to write this. I kluged it together how I know how. Still a frightful noob to B3D etc.

The idea is you put a colored piece on to the other piece and change the color. If you put a combination (caled tertiary color) like blue-green or red-orange on to another tertairy color it turns white.

If you put ANY color on a white it turns to that color.

The only thing you can put to clear a brown is a white (well it should be onlyy)

If you put a color on its own color you should loose a strike.

It all works SOME OF THE TIME!!! but not all of the time... What did I do wrong??

-Rook

I assume the problem is the error 'entity does not exist' because thats the error I get when I run it.

Anyway, to fix this just do a search and replace for 'entity#' and replace with just 'entity'. Entities should just be stored as integers.

nope... I never had that problem. What version of B3D are you on??? I got the latest... my prob is that the color doesn't always change.

oic, I think actually that is a win2000/xp issue with entities being assigned as floats.

I think there a few issues with this code that are stopping tiles from changing:

1) where you have "Case dis >=0 And dis =< 4" to asign red it isn't actually working for some reason. Personally I never realised you could write case statements like this but it seems to be there in the manual. Neverless I replaced this with 'case 0,1,2,3,4' (in all functions where u use this) and from then on red could be selected. I think before it would only select red if the random number equalled 1. Pretty strange:)

2) The condition 'If qu > 45 Then qu = 0' would ignore if the piece is Yellow Orange, where dis=47, so if you have a clear tile and try to lay down a yellow orange piece it wouldn't change. (unless this is by design?)

3) Lastly, the main reason why tiles aren't sometimes changing is because when 'que+dis' adds up to a tile that doesn't exist, the tile is made clear but the array that stores what the tiles are remains invalid, so the next time u try and change the tile, it doesn't change. So I simply added boardarea(row,col)=0 to the default case in function 'setup_board'

Anyway, heres the modified code:

; SNARF is only a working title... SNAFU would be better
; Color changing timed(eventually timed) game
; score more for higher colors
; Ralph Dunn
Graphics3D 800,600,16,2
SetBuffer BackBuffer()

SeedRnd(MilliSecs())
player=CreatePivot()
camera=CreateCamera(player)
light=CreateLight()
RotateEntity light,45,45,0
AmbientLight 48,48,48    ; was 32,32,32

EntityType camera,1
PositionEntity camera,0,90,8
RotateEntity camera,90,0,0

Dim boardarea(9,9)
Dim boardx(9)
Dim boardz(9)
Dim turnpiecex(9)
Dim turnpiecez(9)

Global square
Global xx
Global zz
Global what
Global wp
Global bp
Global musicflag
Global dis
Global dat
Global que
Global kolor$
Global strike

; now create an array called boardarea of 10 by 10 and
; fill in the entire matrix with 0
For fillx = 0 To 9
	For fillz=0 To 9
		boardarea(fillx,fillz)=0
	Next
Next
; ################################## Initial Pieces Start Location
boardarea(4,4)=1
boardarea(4,5)=2
boardarea(5,4)=2
boardarea(5,5)=1

strike=5

boardx(0)=-45
boardx(1)=-35
boardx(2)=-25
boardx(3)=-15
boardx(4)=-5
boardx(5)=5
boardx(6)=15
boardx(7)=25
boardx(8)=35
boardx(9)=45

boardz(0)=-45
boardz(1)=-35
boardz(2)=-25
boardz(3)=-15
boardz(4)=-5
boardz(5)=5
boardz(6)=15
boardz(7)=25
boardz(8)=35
boardz(9)=45

;annoy=LoadSound("anoy1.ogg")
;LoopSound annoy
;Global play_annoy=PlaySound(annoy)

; #######################################  Load Mesh Objects
;gameboard=LoadMesh("board.b3d")
;UpdateNormals gameboard
;ScaleEntity gameboard,5.5,5.5,5.5
;EntityShininess gameboard,1

;Global empty=LoadMesh("square.b3d")
Global empty=CreateCube()
ScaleEntity empty,5,5,5
EntityPickMode empty,2
HideEntity empty

;Global bomb=LoadMesh("bomb.b3d")
;EntityShininess bomb,1
;HideEntity bomb

;Global clearpiece=LoadMesh("piece3.b3d"); was piece
Global clearpiece=CreateSphere(12)
ScaleEntity clearpiece,2,2,2
EntityShininess clearpiece,1
HideEntity clearpiece

;Global redpiece=LoadMesh("piece3.b3d")
Global redpiece=CreateSphere(12)
ScaleEntity redpiece,2,2,2
EntityColor redpiece,192,0,0
EntityShininess redpiece,1
HideEntity redpiece

Global blupiece=CopyMesh(redpiece)
EntityColor blupiece,0,0,255
ScaleEntity blupiece,2,2,2
EntityShininess blupiece,1
HideEntity blupiece

Global yellopiece=CopyMesh(redpiece)
EntityColor yellopiece,180,180,0
ScaleEntity yellopiece,2,2,2
EntityShininess yellopiece,1
HideEntity yellopiece

Global violetpiece=CopyMesh(redpiece)
EntityColor violetpiece,138,1,255
ScaleEntity violetpiece,2,2,2
EntityShininess violetpiece,1
HideEntity violetpiece

Global redvioletpiece=CopyMesh(redpiece)
EntityColor redvioletpiece,180,1,180
ScaleEntity redvioletpiece,2,2,2
EntityShininess redvioletpiece,1
HideEntity redvioletpiece

Global orangepiece=CopyMesh(redpiece)
EntityColor orangepiece,255,153,51
ScaleEntity orangepiece,2,2,2
EntityShininess orangepiece,1
HideEntity orangepiece

Global bluvioletpiece=CopyMesh(redpiece)
EntityColor bluvioletpiece,51,0,103
ScaleEntity bluvioletpiece,2,2,2
EntityShininess bluvioletpiece,1
HideEntity bluvioletpiece

Global greenpiece=CopyMesh(redpiece)
EntityColor greenpiece,0,102,0
ScaleEntity greenpiece,2,2,2
EntityShininess greenpiece,1
HideEntity greenpiece

Global redorangepiece=CopyMesh(redpiece)
EntityColor redorangepiece,255,51,1
ScaleEntity redorangepiece,2,2,2
EntityShininess redorangepiece,1
HideEntity redorangepiece

Global yellogreenpiece=CopyMesh(redpiece)
EntityColor yellogreenpiece,51,255,102
EntityShininess yellogreenpiece,1
ScaleEntity yellogreenpiece,2,2,2
HideEntity yellogreenpiece

Global blugreenpiece=CopyMesh(redpiece)
EntityColor blugreenpiece,0,102,102
EntityShininess blugreenpiece,1
ScaleEntity blugreenpiece,2,2,2
HideEntity blugreenpiece

Global yelloorangepiece=CopyMesh(redpiece)
EntityColor yelloorangepiece,255,153,1
EntityShininess yelloorangepiece,1
ScaleEntity yelloorangepiece,2,2,2
HideEntity yelloorangepiece

Global brownpiece=CopyMesh(redpiece)
EntityColor brownpiece,94,53,53
EntityShininess brownpiece,1
ScaleEntity brownpiece,2,2,2
HideEntity brownpiece

; ######################################  Plunk Tiles
For xx=0 To 9
	For zz=0 To 9
		e=CopyEntity (empty)
		PositionEntity e,boardx(xx),-5,boardz(zz) ; was 1 for me
	Next
Next
; ############################################## Start of Game Loop
ShowPointer 

musicflag=0 ; For the rasta othello player in each of us!
get_piece()
init_board()
setup_board()

While Not KeyDown(1)

x=MouseX()
y=MouseY()

e=CameraPick(camera,x,y)
	If e<>entity
		If entity Then EntityColor entity,255,255,255 
		entity=e
	EndIf
	
If KeyHit(29)=True Then
	PositionEntity camera,0,53,-69
	RotateEntity camera,35,0,0
EndIf

If KeyHit(50)>=1 Then musicflag=1-musicflag

If KeyHit(56)=True Then
	PositionEntity camera,0,90,8
	RotateEntity camera,90,0,0
EndIf

If MouseHit(1) = True Then
	hat=CameraPick(camera,x,y)
	If hat=0 Then Goto outme
		Select empty 
			Case empty
			xx=EntityX(entity)
			zz=EntityZ(entity) 
			Default 
			pp=0
		End Select
put_piece()
setup_board()
make_new()
get_piece()
.outme

EndIf

If entity
	EntityColor entity,254,80,232
; 73,253,146 lime 254,216,38 gold 254,80,232 magenta 54,80,252
EndIf

If musicflag=1 Then ChannelVolume play_annoy,0.4 Else ChannelVolume play_annoy,0


UpdateWorld
RenderWorld

Text 0,10,"X: "+x
Text 0,20,"Y: "+y
Text 0,30,"Z: "+z

xp=turnpiecex(0)
zp=turnpiecez(0)

Text 0,100,"XP: "+xp
Text 0,110,"ZP: "+zp

Text 0,120,"DIS: "+kolor$
Text 0,130,"DAT: "+strike

Flip

Wend


End

Function get_piece()

dis=Rand(17)

		Select dis
		Case dis>=0 And dis=<4
		nub = 7
		kolor$="RED"
		Case 5
		nub=12
		kolor$="BLUE"
		Case 6
		nub=19
		kolor$="VIOLET"
		Case 7
		nub=20
		kolor$="YELLOW"
		Case 8
		nub=26
		kolor$="RED-VIOLET"
		Case 9
		nub=27
		kolor$="ORANGE"
		Case 10
		nub=31
		kolor$="BLUE-VIOLET"
		Case 11
		nub=32
		kolor$="GREEN"
		Case 12
		nub=34
		kolor$="RED-ORANGE"
		Case 13
		nub=39
		kolor$="BROWN"
		Case 14
		nub=42
		kolor$="YELLOW-GREEN"
		Case 15
		nub=44
		kolor$="BLUE-GREEN"
		Case 16
		nub=47
		kolor$="YELLOW-ORANGE"
		Case 17
		nub=0
		kolor$="CLEAR"
		End Select
dis=nub

End Function

Function put_piece()

;###################################### CHECK IF ITS LEGAL
; check and see if its same color :: do nada BAD MOVE
; check If it is brown :: If piececolor = 0 then change to 0
; check if it is white :: change to piececolor

Select xx
	Case -45
	row=0
	Case -35
	row=1
	Case -25
	row=2
	Case -15
	row=3
	Case -5
	row=4
	Case 5
	row=5
	Case 15
	row=6
	Case 25
	row=7
	Case 35
	row = 8
	Case 45
	row=9
End Select

Select zz
	Case -45
	col=0
	Case -35
	col=1
	Case -25
	col=2
	Case -15
	col=3
	Case -5
	col=4
	Case 5
	col=5
	Case 15
	col=6
	Case 25
	col=7
	Case 35
	col= 8
	Case 45
	col=9
End Select

que=boardarea(row,col)

If dis=0 Then ; clear clears any color
	qu=0
	Goto outme
EndIf

If que = dis Then
	strike=strike-1
	; playnoise BOO!
	qu=dis
	Goto outme
EndIf

qu=que+dis
DebugLog "Set Piece:" + DIS
DebugLog "Board Piece:" + Que
If qu > 45 Then qu = 0 ; this is a weird rule but necessary for GIGO collection

.outme

boardarea(row,col)=qu

End Function

Function setup_board()
Cls
For row=0 To 9
	For col=0 To 9
		what=boardarea(row,col)

			Select what
			Case 7
				red=CopyEntity (redpiece)
				PositionEntity red,boardx(row),4,boardz(col)
			Case 12
				blue=CopyEntity (blupiece)
				PositionEntity blue,boardx(row),4,boardz(col)
			Case 19
				violet=CopyEntity (violetpiece)
				PositionEntity violet,boardx(row),4,boardz(col)
			Case 20
				yellow=CopyEntity (yellopiece)
				PositionEntity yellow,boardx(row),4,boardz(col)
			Case 26
				redviolet=CopyEntity (redvioletpiece)
				PositionEntity redviolet,boardx(row),4,boardz(col)
			Case 27
				orange=CopyEntity (orangepiece)
				PositionEntity orange,boardx(row),4,boardz(col)
			Case 31
				bluviolet=CopyEntity (bluvioletpiece)
				PositionEntity bluviolet,boardx(row),4,boardz(col)
			Case 32
				green=CopyEntity (greenpiece)
				PositionEntity green,boardx(row),4,boardz(col)
			Case 34
				redorange=CopyEntity (redorangepiece)
				PositionEntity redorange,boardx(row),4,boardz(col)
			Case 39
				brown=CopyEntity (brownpiece)
				PositionEntity brown,boardx(row),4,boardz(col)
			Case 42
				yellogreen=CopyEntity (yellogreenpiece)
				PositionEntity yellogreen,boardx(row),4,boardz(col)
			Case 44
				blugreen=CopyEntity (blugreenpiece)
				PositionEntity blugreen,boardx(row),4,boardz(col)
			Case 47
				yelloorange=CopyEntity (yelloorangepiece)
				PositionEntity yelloorange,boardx(row),4,boardz(col)
			Default
			clear=CopyEntity (clearpiece)
				PositionEntity clear,boardx(row),4,boardz(col)
				boardarea(row,col)=0
			End Select
	Next
Next

End Function

Function make_new()

dis=Rand(17)

		Select dis
		Case 0,1,2,3,4
		nub = 7
		Case 5
		nub=12
		Case 6
		nub=19
		Case 7
		nub=20
		Case 8
		nub=26
		Case 9
		nub=27
		Case 10
		nub=31
		Case 11
		nub=32
		Case 12
		nub=34
		Case 13
		nub=39
		Case 14
		nub=42
		Case 15
		nub=44
		Case 16
		nub=47
		Case 17
		nub=0
		End Select

		DebugLog "RND:" + dis
		
dis=nub
		DebugLog "DIS:" + dis

End Function

Function init_board()

For row = 0 To 9
	For col = 0 To 9
	i=Rand(17)
	Select i
	Case 0,1,2,3,4
	numb=7
	Case 5
	numb=12
	Case 6
	numb=19
	Case 7
	numb=20
	Case 8
	numb=26
	Case 9
	numb=27
	Case 10
	numb=31
	Case 11
	numb=32
	Case 12
	numb=34
	Case 13
	numb=39
	Case 14
	numb=42
	Case 15
	numb=44
	Case 16
	numb=47
	Case 17
	numb=0
	End Select	
		boardarea(row,col) = numb
	Next
Next

End Function


I left the debuglog commands in there that I used to figure out what was going on.