/************************************************************************\ |* gtf is a framework for analyzing two-player zero-sum games *| |* Copyright (C) 2005 Troels Bjerre Sorensen *| |* *| |* This program is free software; you can redistribute it and/or modify *| |* it under the terms of the GNU General Public License as published by *| |* the Free Software Foundation; either version 2 of the License, or *| |* (at your option) any later version. *| |* *| |* This program is distributed in the hope that it will be useful, but *| |* WITHOUT ANY WARRANTY; without even the implied warranty of *| |* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *| |* General Public License for more details. *| |* *| |* You should have received a copy of the GNU General Public License *| |* along with this program; if not, write to the *| |* Free Software Foundation, Inc., 59 Temple Place - Suite 330, *| |* Boston, MA 02111-1307, USA. *| \************************************************************************/ package gtf; import gtf.game.*; import gtf.util.*; import java.io.*; import java.util.*; import java.lang.reflect.*; public class Analyze { public static void main(String[] args) { List processors = new ArrayList(); ExtensiveForm ef = null; try { int i = 0; while (i < args.length) { Class nextarg = Class.forName(args[i].replace('/', '.')); if ( ! Processor.class.isAssignableFrom(nextarg)) break; processors.add((Processor) nextarg.getConstructor(new Class[0]).newInstance(new Object[0])); i++; } if (i == 0) throw new UsageException("No analysis to do.");//processors.add(new ValidationVisitor()); if (i >= args.length) throw new UsageException("Missing a game to analyze."); Class clas = Class.forName(args[i].replace('/', '.')); if( ! ExtensiveForm.class.isAssignableFrom(clas)) throw new UsageException(clas.getName() + " is not a proper game."); Class[] constypes = new Class[args.length - 1 - i]; Arrays.fill(constypes, String.class); Constructor cons = clas.getConstructor(constypes); Object[] consargs = new Object[args.length - 1 - i]; System.arraycopy(args, i + 1, consargs, 0, args.length - 1 - i); ef = (ExtensiveForm) cons.newInstance(consargs); } catch (Exception e) { System.err.println(e + "\nUsage: java Analyze + []"); System.exit(1); } Iterator processit = processors.iterator(); System.out.println(); while (processit.hasNext()) { Processor process = (Processor) processit.next(); System.out.println(process.getClass().getName()); System.out.println(); process.process(ef, System.out); System.out.println(); } } }