public static StateGraph CreateStateGraph(RoboBoard board) { ICollection> nodes = new HashIndexedList>(); for (int y = 0; y < board.Size.Height; y++) { for (int x = 0; x < board.Size.Width; x++) { nodes.Add(new FieldNode(Direction.Up, board.Fields[x, y])); nodes.Add(new FieldNode(Direction.Right, board.Fields[x, y])); nodes.Add(new FieldNode(Direction.Down, board.Fields[x, y])); nodes.Add(new FieldNode(Direction.Left, board.Fields[x, y])); } } StateGraph graph = new StateGraph(board, nodes); foreach (FieldNode node in nodes) { foreach (CardType cardType in Enum.GetValues(typeof(CardType))) { RoboPosition position = RoboManager.PlayCard(board, new RoboCard(cardType), new RoboPosition(node.Field.X, node.Field.Y, node.Direction)); if (position.IsDead) //der Hashcode des "Todesknoten" ist 0 graph.AddDirectedEdge(node, graph.GetNode(0), cardType); else graph.AddDirectedEdge(node, graph.GetNode(position.GetHashCode()), cardType); } } return graph; }