Package org.ggp.base.util.propnet.factory

Source Code of org.ggp.base.util.propnet.factory.LegacyPropNetFactory

package org.ggp.base.util.propnet.factory;

import java.util.List;

import org.ggp.base.util.gdl.grammar.Gdl;
import org.ggp.base.util.gdl.grammar.GdlRule;
import org.ggp.base.util.logging.GamerLogger;
import org.ggp.base.util.propnet.architecture.PropNet;
import org.ggp.base.util.propnet.factory.converter.PropNetConverter;
import org.ggp.base.util.propnet.factory.flattener.PropNetFlattener;
import org.ggp.base.util.statemachine.Role;


/**
* The LegacyPropNetFactory class defines the creation of PropNets from game
* descriptions. It has been superseded by the @OptimizingPropNetFactory
* which has a more sophisticated approach to creating PropNets.
*/
public final class LegacyPropNetFactory
{
  /**
   * Creates a PropNet from a game description using the following process:
   * <ol>
   * <li>Flattens the game description to remove variables.</li>
   * <li>Converts the flattened description into an equivalent PropNet.</li>
   * </ol>
   *
   * @param description
   *            A game description.
   * @return An equivalent PropNet.
   */
  public static PropNet create(List<Gdl> description)
  {
        try {
            List<GdlRule> flatDescription = new PropNetFlattener(description).flatten();
            GamerLogger.log("StateMachine", "Converting...");
            return new PropNetConverter().convert(Role.computeRoles(description), flatDescription);
        } catch(Exception e) {
            GamerLogger.logStackTrace("StateMachine", e);
            return null;
        }
  }
}
TOP

Related Classes of org.ggp.base.util.propnet.factory.LegacyPropNetFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.