static = """statics:
	index(1)
	index(2)
	index(3)
	input_move(robot, 1, 1)
	input_move(robot, 1, 2)
	input_move(robot, 1, 3)
	input_move(robot, 2, 1)
	input_move(robot, 2, 2)
	input_move(robot, 2, 3)
	input_move(robot, 3, 1)
	input_move(robot, 3, 2)
	input_move(robot, 3, 3)
	role(robot)
	scoremap(26, 100)
	scoremap(27, 100)
	scoremap(28, 100)
	scoremap(29, 100)
	scoremap(30, 100)
	scoremap(31, 98)
	scoremap(32, 96)
	scoremap(33, 94)
	scoremap(34, 92)
	scoremap(35, 90)
	scoremap(36, 88)
	scoremap(37, 86)
	scoremap(38, 84)
	scoremap(39, 82)
	scoremap(40, 80)
	scoremap(41, 78)
	scoremap(42, 76)
	scoremap(43, 74)
	scoremap(44, 72)
	scoremap(45, 70)
	scoremap(46, 68)
	scoremap(47, 66)
	scoremap(48, 64)
	scoremap(49, 62)
	scoremap(50, 60)
	succ(1, 2)
	succ(2, 3)
	successor(0, 1)
	successor(1, 2)
	successor(10, 11)
	successor(11, 12)
	successor(12, 13)
	successor(13, 14)
	successor(14, 15)
	successor(15, 16)
	successor(16, 17)
	successor(17, 18)
	successor(18, 19)
	successor(19, 20)
	successor(2, 3)
	successor(20, 21)
	successor(21, 22)
	successor(22, 23)
	successor(23, 24)
	successor(24, 25)
	successor(25, 26)
	successor(26, 27)
	successor(27, 28)
	successor(28, 29)
	successor(29, 30)
	successor(3, 4)
	successor(30, 31)
	successor(31, 32)
	successor(32, 33)
	successor(33, 34)
	successor(34, 35)
	successor(35, 36)
	successor(36, 37)
	successor(37, 38)
	successor(38, 39)
	successor(39, 40)
	successor(4, 5)
	successor(40, 41)
	successor(41, 42)
	successor(42, 43)
	successor(43, 44)
	successor(44, 45)
	successor(45, 46)
	successor(46, 47)
	successor(47, 48)
	successor(48, 49)
	successor(49, 50)
	successor(5, 6)
	successor(6, 7)
	successor(7, 8)
	successor(8, 9)
	successor(9, 10)
	tile(1)
	tile(2)
	tile(3)
	tile(4)
	tile(5)
	tile(6)
	tile(7)
	tile(8)
	tile(b)

---"""


t_goal = """atoms:
	goal(robot, 1)
	goal(robot, 2)
	goal(robot, 3)
	goal(robot, 4)
	goal(robot, 5)
	goal(robot, 6)
	goal(robot, 7)
	goal(robot, 8)
	goal(robot, b)
	goal(robot, 0)
	goal(robot, 10)
	goal(robot, 11)
	goal(robot, 12)
	goal(robot, 13)
	goal(robot, 14)
	goal(robot, 15)
	goal(robot, 16)
	goal(robot, 17)
	goal(robot, 18)
	goal(robot, 19)
	goal(robot, 20)
	goal(robot, 21)
	goal(robot, 22)
	goal(robot, 23)
	goal(robot, 24)
	goal(robot, 25)
	goal(robot, 26)
	goal(robot, 27)
	goal(robot, 28)
	goal(robot, 29)
	goal(robot, 30)
	goal(robot, 31)
	goal(robot, 32)
	goal(robot, 33)
	goal(robot, 34)
	goal(robot, 35)
	goal(robot, 36)
	goal(robot, 37)
	goal(robot, 38)
	goal(robot, 39)
	goal(robot, 40)
	goal(robot, 41)
	goal(robot, 42)
	goal(robot, 43)
	goal(robot, 44)
	goal(robot, 45)
	goal(robot, 46)
	goal(robot, 47)
	goal(robot, 48)
	goal(robot, 49)
	goal(robot, 50)
	goal(robot, 9)
	goal(robot, 100)
	goal(robot, 60)
	goal(robot, 62)
	goal(robot, 64)
	goal(robot, 66)
	goal(robot, 68)
	goal(robot, 70)
	goal(robot, 72)
	goal(robot, 74)
	goal(robot, 76)
	goal(robot, 78)
	goal(robot, 80)
	goal(robot, 82)
	goal(robot, 84)
	goal(robot, 86)
	goal(robot, 88)
	goal(robot, 90)
	goal(robot, 92)
	goal(robot, 94)
	goal(robot, 96)
	goal(robot, 98)

---
"""

t_legal = """atoms:
	legal_move(robot, 1, 1)
	legal_move(robot, 2, 1)
	legal_move(robot, 3, 1)
	legal_move(robot, 1, 2)
	legal_move(robot, 2, 2)
	legal_move(robot, 3, 2)
	legal_move(robot, 1, 3)
	legal_move(robot, 2, 3)
	legal_move(robot, 3, 3)

---
"""

t_next = """atoms:
	next_cell(1, 1, 1)
	next_cell(2, 1, 1)
	next_cell(3, 1, 1)
	next_cell(1, 2, 1)
	next_cell(2, 2, 1)
	next_cell(3, 2, 1)
	next_cell(1, 3, 1)
	next_cell(2, 3, 1)
	next_cell(3, 3, 1)
	next_cell(1, 1, 2)
	next_cell(2, 1, 2)
	next_cell(3, 1, 2)
	next_cell(1, 2, 2)
	next_cell(2, 2, 2)
	next_cell(3, 2, 2)
	next_cell(1, 3, 2)
	next_cell(2, 3, 2)
	next_cell(3, 3, 2)
	next_cell(1, 1, 3)
	next_cell(2, 1, 3)
	next_cell(3, 1, 3)
	next_cell(1, 2, 3)
	next_cell(2, 2, 3)
	next_cell(3, 2, 3)
	next_cell(1, 3, 3)
	next_cell(2, 3, 3)
	next_cell(3, 3, 3)
	next_cell(1, 1, 4)
	next_cell(2, 1, 4)
	next_cell(3, 1, 4)
	next_cell(1, 2, 4)
	next_cell(2, 2, 4)
	next_cell(3, 2, 4)
	next_cell(1, 3, 4)
	next_cell(2, 3, 4)
	next_cell(3, 3, 4)
	next_cell(1, 1, 5)
	next_cell(2, 1, 5)
	next_cell(3, 1, 5)
	next_cell(1, 2, 5)
	next_cell(2, 2, 5)
	next_cell(3, 2, 5)
	next_cell(1, 3, 5)
	next_cell(2, 3, 5)
	next_cell(3, 3, 5)
	next_cell(1, 1, 6)
	next_cell(2, 1, 6)
	next_cell(3, 1, 6)
	next_cell(1, 2, 6)
	next_cell(2, 2, 6)
	next_cell(3, 2, 6)
	next_cell(1, 3, 6)
	next_cell(2, 3, 6)
	next_cell(3, 3, 6)
	next_cell(1, 1, 7)
	next_cell(2, 1, 7)
	next_cell(3, 1, 7)
	next_cell(1, 2, 7)
	next_cell(2, 2, 7)
	next_cell(3, 2, 7)
	next_cell(1, 3, 7)
	next_cell(2, 3, 7)
	next_cell(3, 3, 7)
	next_cell(1, 1, 8)
	next_cell(2, 1, 8)
	next_cell(3, 1, 8)
	next_cell(1, 2, 8)
	next_cell(2, 2, 8)
	next_cell(3, 2, 8)
	next_cell(1, 3, 8)
	next_cell(2, 3, 8)
	next_cell(3, 3, 8)
	next_cell(1, 1, b)
	next_cell(2, 1, b)
	next_cell(3, 1, b)
	next_cell(1, 2, b)
	next_cell(2, 2, b)
	next_cell(3, 2, b)
	next_cell(1, 3, b)
	next_cell(2, 3, b)
	next_cell(3, 3, b)
	next_step(1)
	next_step(2)
	next_step(3)
	next_step(4)
	next_step(5)
	next_step(6)
	next_step(7)
	next_step(8)
	next_step(b)
	next_step(0)
	next_step(10)
	next_step(11)
	next_step(12)
	next_step(13)
	next_step(14)
	next_step(15)
	next_step(16)
	next_step(17)
	next_step(18)
	next_step(19)
	next_step(20)
	next_step(21)
	next_step(22)
	next_step(23)
	next_step(24)
	next_step(25)
	next_step(26)
	next_step(27)
	next_step(28)
	next_step(29)
	next_step(30)
	next_step(31)
	next_step(32)
	next_step(33)
	next_step(34)
	next_step(35)
	next_step(36)
	next_step(37)
	next_step(38)
	next_step(39)
	next_step(40)
	next_step(41)
	next_step(42)
	next_step(43)
	next_step(44)
	next_step(45)
	next_step(46)
	next_step(47)
	next_step(48)
	next_step(49)
	next_step(50)
	next_step(9)

---
"""

t_terminal = """atoms:
	terminal()

---
"""

def write_prelude(file,pred):
	with open(file,'w') as f:
		if pred=="goal":
			f.write(t_goal + '\n' + static)
		elif pred=="legal":
			f.write(t_legal + '\n' + static)
		elif pred=="next":
			f.write(t_next + '\n' + static)
		elif pred=="terminal":
			f.write(t_terminal + '\n' + static)
		f.close()

if __name__ == "__main__":
	write_prelude('eightpuzzle-traces/goal_' + use + '.dat')
	write_prelude('eightpuzzle-traces/legal_' + use + '.dat')
	write_prelude('eightpuzzle-traces/next_' + use + '.dat')
	write_prelude('eightpuzzle-traces/terminal_' + use + '.dat')
	
	
	
	
