Esempio n. 1
0
 private void checkFile() throws ErrorMessage {
   InputStream in = null;
   try {
     in = new FileInputStream(m_file);
   } catch (FileNotFoundException e) {
     throwError("file not found");
   }
   SgfReader reader = new SgfReader(in, m_file, null, 0);
   GameTree tree = reader.getTree();
   if (tree.getBoardSize() != m_size) throwError("size is not " + m_size);
   ConstNode root = tree.getRoot();
   GoColor toMove = BLACK;
   for (ConstNode node = root; node != null; node = node.getChildConst()) {
     if (node.hasSetup()) {
       if (m_allowSetup) {
         if (node == root) toMove = EMPTY;
         else throw new ErrorMessage("setup stones" + " in non-root position");
       } else throw new ErrorMessage("contains setup stones");
     }
     Move move = node.getMove();
     if (move != null) {
       if (toMove == EMPTY) toMove = move.getColor();
       if (move.getColor() != toMove) throwError("non-alternating moves");
       toMove = toMove.otherColor();
     }
   }
 }