Behold my advanced AI!

Miscellaneous Forums/Blitz Showcase/Behold my advanced AI!

For Blitz3D:
Global px,py,psp,ps#,pc
Global minerals,rawminerals,money,mineralcapacity

AppTitle "Mineral Miner"

Graphics 800,600,32,1

SetBuffer BackBuffer()
SeedRnd MilliSecs()

Type miner

	Field m.miner
	Field px,py,psp,ps#,pc
	Field minerals,mineralcapacity
	
End Type

mineramount=1

For ma=1 To mineramount
	m.miner=New miner
Next

For m.miner=Each miner
	m\px=Rnd(0,790)
	m\py=Rnd(0,590)
	m\psp=2
	m\minerals=0
	m\mineralcapacity=250
	m\ps#=10
	m\pc=Rnd(25,255)
Next

money=100
rawminerals=25000

upgrade1=False
upgrade2=False

While Not KeyHit(1)

	Display()
	Miner()

	Flip
	Cls
	
Wend

Function Display()

	;base
	Color 0,0,255
	Rect 0,500,100,100,1
	Color 0,0,0
	Text 30,540,"BASE"
	
	;minerals
	Color 255,0,0
	Rect 700,0,100,100,1
	Color 0,0,0
	Text 710,45,"MINERALS"
	Color 255,0,0
	Text 700,100,"Amount: "+rawminerals
	
	;info
	Color 200,200,200	
	Text 10,10,"Money: $"+money		

End Function

Function Miner()	
	
	For m.miner=Each miner
	
		If m\minerals=0 Then
			If m\px<750 Then m\px=m\px+1*m\psp
			If m\py>50 Then m\py=m\py-1*m\psp
		EndIf
	
		If m\minerals>=m\mineralcapacity Or rawminerals=0 Then
			If m\px>50 Then m\px=m\px-1*m\psp
			If m\py<550 Then m\py=m\py+1*m\psp
		EndIf
	
		If m\minerals>0 And m\px=<100 And m\py>500 Then	
		
			money=money+m\minerals*3.3
			m\minerals=0
			m\ps=10
					
		EndIf
	
		If m\minerals<=m\mineralcapacity And rawminerals>0 And m\px>700 And m\py<100 Then
			
			m\minerals=m\minerals+1	
			rawminerals=rawminerals-1
			m\ps#=m\ps#+0.05						
	
		EndIf	
		
		Color 0,m\pc,0
		Oval m\px,m\py,m\ps#,m\ps#,1
		Color 255,0,255
		Text m\px-8,m\py+12,m\minerals	
		
		;If KeyHit(2) And money>=10000 And m\mineralcapacity<400 Then money=money-10000:upgrade1=True
		;If upgrade1=True Then	m\mineralcapacity=400		
				
		;If KeyHit(3) And money>=12000 And m\psp<3 Then money=money-12000:upgrade2=True
		;If upgrade2=True m\psp=3		
	
	Next	
	
	If KeyHit(28) And money>1200 Then
		
		money=money-1200
		
		m.miner=New miner
		m\px=50
		m\py=550
		m\psp=2
		m\minerals=0
		m\mineralcapacity=250
		m\ps#=10
		m\pc=Rnd(25,255)
	
	EndIf	
	
End Function


Press enter to buy another miner if you have $1200.