Add support+docs for easy dataset generation
[gostyle.git] / make_input_vector.py
blob3eb2aebf0738224d055349bec67190f802c60acd
1 #!/usr/bin/python
2 """
3 This script generates input vectors using the InputGenerator loaded from a file `pickle_filename'.
4 It then generates input vectors for each pat file specified as the script parameter.
6 Usage:
7 ./make_input_vector.py karel.pat john.pat
8 """
9 import sys
10 from gostyle import print_vector, load_object_from_file, InputVectorGenerator, Compose, PCA
12 if __name__ == '__main__':
13 # Name of filename with saved input generator (see make_train_set.py)
14 pickle_filename = 'input_gen.pickle'
15 # Loads the generator
16 input_generator = load_object_from_file(pickle_filename)
18 # For pat_file in argv
19 for pat_file in sys.argv[1:]:
20 try:
21 # Generate players input vector
22 input_vector = input_generator(pat_file)
23 # print it
24 print_vector(input_vector)
25 except IOError:
26 print >>sys.stderr, "Pat file %s missing. Skipping."%(pat_file)