Java Code Examples for skadistats.clarity.processor.runner.SimpleRunner

The following examples show how to use skadistats.clarity.processor.runner.SimpleRunner. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void run(String[] args) throws Exception {
    final Context ctx = new SimpleRunner(new MappedFileSource(args[0])).runWith(this).getContext();
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                MainWindow window = new MainWindow();
                window.getClassTree().setModel(new DefaultTreeModel(new TreeConstructor(ctx.getProcessor(DTClasses.class)).construct()));
                window.getFrame().setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

}
 
Example #2
Source Project: parser   Author: odota   File: Parse.java    License: MIT License 5 votes vote down vote up
public Parse(InputStream input, OutputStream output) throws IOException
{
  greevilsGreedVisitor = new GreevilsGreedVisitor(name_to_slot);
  trackVisitor = new TrackVisitor();
	
  is = input;
  os = output;
  isPlayerStartingItemsWritten = new ArrayList<>(Arrays.asList(new Boolean[numPlayers]));
  Collections.fill(isPlayerStartingItemsWritten, Boolean.FALSE);
  long tStart = System.currentTimeMillis();
  new SimpleRunner(new InputStreamSource(is)).runWith(this);
  long tMatch = System.currentTimeMillis() - tStart;
  System.err.format("total time taken: %s\n", (tMatch) / 1000.0);
}
 
Example #3
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void runSeek(String[] args) throws Exception {
    Runner runner = new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    StringTables st = runner.getContext().getProcessor(StringTables.class);
    for (String name : names) {
        StringTable t = st.forName(name);
        System.out.println(t.toString());
    }
}
 
Example #4
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void run(String[] args) throws Exception {
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    System.out.println("LOADED " + loaded);
    System.out.println("COMPLETED " + complete);
    System.out.println("CREATED " + created);

    HashSet<Integer> lbnc = new HashSet<>(loaded);
    lbnc.removeAll(created);
    System.out.println("LOADED BUT NOT CREATED " + lbnc);

    lbnc = new HashSet<>(loaded);
    lbnc.removeAll(complete);
    System.out.println("LOADED BUT NOT COMPLETED " + lbnc);

}
 
Example #5
Source Project: clarity-examples   Author: skadistats   File: AllChatProcessor.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // 1) create an input source from the replay
    Source source = new MappedFileSource("replay.dem");
    // 2) create a simple runner that will read the replay once
    SimpleRunner runner = new SimpleRunner(source);
    // 3) create an instance of your processor
    AllChatProcessor processor = new AllChatProcessor();
    // 4) and hand it over to the runner
    runner.runWith(processor);
}
 
Example #6
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void run(String[] args) throws Exception {
    String srcFile = args[0];
    String dstFile = args[1];
    createWriterThread(srcFile, dstFile);

    LiveSource source = new LiveSource(dstFile, 5, TimeUnit.SECONDS);
    new SimpleRunner(source).runWith(new Object() {
        @OnMessage
        public void onMessage(GeneratedMessage msg) {
            System.out.println(msg.getClass().getSimpleName());
        }
    });
}
 
Example #7
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    SimpleRunner r = null;
    try {
        r = new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    } finally {
        long tMatch = System.currentTimeMillis() - tStart;
        log.info("total time taken: {}s", (tMatch) / 1000.0);
        if (r != null) {
            r.getSource().close();
        }
    }
}
 
Example #8
Source Project: clarity   Author: skadistats   File: LiveSourceTest.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(enabled = false)
@Parameters({"srcFile", "dstFile"})
public void demoLiveSource(final String srcFile, final String dstFile) throws Exception {
    createWriterThread(srcFile, dstFile);

    LiveSource source = new LiveSource(dstFile, 5, TimeUnit.SECONDS);
    new SimpleRunner(source).runWith(new Object() {
        @OnMessage
        public void onMessage(GeneratedMessage msg) {
            System.out.println(msg.getClass().getSimpleName());
        }
    });
}
 
Example #9
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #10
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
}
 
Example #11
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #12
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    SimpleRunner runner = new SimpleRunner(new MappedFileSource(args[0]));
    runner.runWith(this);
}
 
Example #13
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();

    String demoName = args[0];

    SimpleRunner r = new SimpleRunner(new MappedFileSource(demoName)).runWith(this);

    Context ctx = r.getContext();

    File dir = new File(String.format("baselines%s%s", File.separator, ctx.getBuildNumber() == -1 ? "latest" : ctx.getBuildNumber()));
    if (!dir.exists()) {
        dir.mkdirs();
    }

    FieldReader fieldReader = ctx.getEngineType().getNewFieldReader();

    StringTables stringTables = ctx.getProcessor(StringTables.class);
    DTClasses dtClasses = ctx.getProcessor(DTClasses.class);
    StringTable baselines = stringTables.forName("instancebaseline");

    for (int i = 0; i < baselines.getEntryCount(); i++) {
        DTClass dtClass = dtClasses.forClassId(Integer.valueOf(baselines.getNameByIndex(i)));
        String fileName = String.format("%s%s%s.txt", dir.getPath(), File.separator, dtClass.getDtName());
        log.info("writing {}", fileName);
        fieldReader.DEBUG_STREAM = new PrintStream(new FileOutputStream(fileName), true, "UTF-8");
        BitStream bs = BitStream.createBitStream(baselines.getValueByIndex(i));
        try {
            fieldReader.readFields(bs, dtClass, dtClass.getEmptyState(), null, true);
            if (bs.remaining() < 0 || bs.remaining() > 7) {
                log.info("-- OFF: {} remaining", bs.remaining());
            }
        } catch (Exception e) {
            log.info("-- FAIL: {}", e.getMessage());
            e.printStackTrace(fieldReader.DEBUG_STREAM);
        } finally {
        }
    }

    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #14
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #15
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #16
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #17
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #18
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #19
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
Example #20
Source Project: clarity-examples   Author: skadistats   File: Main.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();
    new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}