package org.ggp.base.util.statemachine;

import java.util.Set;
import org.ggp.base.util.gdl.grammar.GdlSentence;

public class MachineState {
    public MachineState() {
        this.contents = null;
    }
    
    /**
     * Starts with a simple implementation of a MachineState. StateMachines that
     * want to do more advanced things can subclass this implementation, but for
     * many cases this will do exactly what we want.
     */
    private final Set<GdlSentence> contents;
    public MachineState(Set<GdlSentence> contents)
    {
        this.contents = contents;
    }

    /**
     * getContents returns the GDL sentences which determine the current state
     * of the game being played. Two given states with identical GDL sentences
     * should be identical states of the game.
     */
	public Set<GdlSentence> getContents()
	{
        return contents;
    }

	/* Utility methods */
    public int hashCode()
    {
        return getContents().hashCode();
    }

    public String toString()
    {
    	Set<GdlSentence> contents = getContents();
    	if(contents == null)
    		return "(MachineState with null contents)";
    	else
    		return contents.toString();
    }	

    public boolean equals(Object o)
    {
        if ((o != null) && (o instanceof MachineState))
        {
            MachineState state = (MachineState) o;
            return state.getContents().equals(getContents());
        }

        return false;
    }
}
@@ -36,16 +36,43 @@
 ine;%0D%0A%0D%0A
+import java.util.HashSet;%0D%0A
 import j
@@ -928,16 +928,119 @@
 %0D%0A    %7D%0D
+%0A%09%0D%0A%09public MachineState clone() %7B%0D%0A%09%09return new MachineState(new HashSet%3CGdlSentence%3E(contents));%0D%0A%09%7D%0D
 %0A%0D%0A%09/* U

Add a proper implementation for clone for MachineState.