#!/usr/local/bin/tt

EXT_SHELL="/usr/bin/gnuplot -p 2> /dev/null"

# シミュレーションのパラメーター
global grid=256					# SPACE_GRID_SIZE
global ps=8						# PIXEL_SIZE(byte) - double
global vs=8						# VISUALIZATION_STEP
f = dbl(shift(0.04))
k = dbl(shift(0.06))
p(f,k)

# シミュレーションの実行
pu = NULL
pv = NULL
loop( cnt<INT_MAX ){
	grayscott(pu,pv,grid,f,k)
	if( cnt%vs==0 ) dplot("${cnt}",pu)
}

# プロット
def dplot(title,ptr){
	!set size square
	!set cbrange [0:3]
	!set title "${title}"
	!plot '-' bin array=${grid}x${grid} format='%double' with image not
	write(EXT_SHELL,ptr,grid*grid*ps)
}
