package net.woodyfolsom.msproj.ann;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;

import net.woodyfolsom.msproj.GameRecord;
import net.woodyfolsom.msproj.Referee;

import org.antlr.runtime.RecognitionException;

public class PassLearner {
	private File[] getDataFiles(String dirName) {
		File file = new File(dirName);
		return file.listFiles(new FilenameFilter() {
			@Override
			public boolean accept(File dir, String name) {
				// TODO Auto-generated method stub
				return name.toLowerCase().endsWith(".sgf");
			}
		});
	}

	public static void main(String[] args) {
		new PassLearner().learnANN();
	}

	private void learnANN() {
		for (File sgfFile : getDataFiles("data/games/pro9x9")) {
			System.out.println("Parsing " + sgfFile.getPath() + "...");
			parseSGF(sgfFile);
		}
	}

	public void parseSGF(File sgfFile) {
		FileInputStream sgfInputStream;

		try {
			sgfInputStream = new FileInputStream(sgfFile);
			GameRecord gameRecord = Referee.replay(sgfInputStream);
			// ...
		} catch (FileNotFoundException fnfe) {
			fnfe.printStackTrace();
		} catch (RecognitionException re) {
			re.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}
}
