"""
This script will setup the directory for using the simulator
All code is released under the MIT License and is (C) copyright 2016 Jay Valentine
"""

from setup_functions import *
import os
import time

print('creating required directories...')
#test if rules path exists and create it if not
if not os.path.exists('rules/'):
	os.mkdir('rules/')
	
#test if images path exists and create it if not
if not os.path.exists('images/'):
	os.mkdir('images/')
	
#prompt user to select which rules they wish to generate

valid = False
while not valid:
	elementary_choice = input('generate rules for elementary 1-dimensional automata? (y/n) ')
	if elementary_choice.lower() == 'y':
		generate_elementary = True
		valid = True
	elif elementary_choice.lower() == 'n':
		generate_elementary = False
		valid = True
		
	else:
		print('enter either y or n')
		
valid = False
while not valid:
	conway_choice = input('generate rules for Conway\'s Game of Life? (y/n) ')
	if conway_choice.lower() == 'y':
		generate_conway = True
		valid = True
	elif conway_choice.lower() == 'n':
		generate_conway = False
		valid = True
		
	else:
		print('enter either y or n')
		
valid = False
while not valid:
	wireworld_choice = input('generate rules for Brian Silverman\'s Wireworld? (y/n) ')
	if wireworld_choice.lower() == 'y':
		generate_wireworld = True
		valid = True
	elif wireworld_choice.lower() == 'n':
		generate_wireworld = False
		valid = True
		
	else:
		print('enter either y or n')
		
files = []

#add elementary rules if required
if generate_elementary:
	print('generating elementary rules...')
	files += elementary_rules()
	
#add game of life rules if required
if generate_conway:
	print('generating rules for John Conway\'s Game of Life...')
	files += conway()
	
#add wireworld rules if required
if generate_wireworld:
	print('generating rules for Brian Silverman\'s Wireworld...')
	files += wire_world()

if files != []:
	print('writing files...')
	write_files(files)
	
print('setup complete')
time.sleep(1)
print('exiting')
