view code/dotScanner.lm @ 12:1c6d4f2642d0

Fist progress toward a simple recursive dot scanner bot
author William Morgan <billjunk@mrgn.org>
date Fri, 25 Jul 2014 19:19:07 -0700
parents
children 5ded24518dc5 37158acf31e5
line wrap: on
line source

#{
    /*
	ListGet <- :cell idx {
		if: idx = 0 {cell value} else: {
        ListGet: (cell tail) (idx - 1)
		}
	}
	TupGet <- :cell depth size {
		if: idx = 0 {cell value} else: { 
        if: size = 1 {cell tail} else: {  // warning, out-of-bounds idx will return a value!
		TupGet: (cell tail) (idx - 1) (size - 1)
		}}
	}

	// rowmajor lists
	GridGet <- :x y w h{
		ListGet
		...
	}
    */
	//scanFor <- :target depth visited{
	//}
	counterLoad <- 4
	step <- :myState world {
		print: (world value)
		//myPos <- 
		path <- [3 1 3 1] //scanFor: 2 3 [myPos]
		move <- myState value
		counter <- (myState tail) - 1
		if: counter = 0 {
			move <- move + 1
			counter <- counterLoad
			if: move = 4 {
				move <- 0
			} else: {}
		} else: {}
		#[#[move counter] ((path tail) value)]
	}
	
	main <- :initWorld mystery {
		#[#[0 counterLoad] step]
	}
}

//does not work: 
//someListOrTup get: 0
//lambdaman program (step function) faulted TagMismatch