24 package org.lightjason.agentspeak.generator;
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
41 import javax.annotation.Nonnull;
42 import javax.annotation.Nullable;
43 import java.io.InputStream;
44 import java.util.Collection;
45 import java.util.Collections;
46 import java.util.LinkedHashSet;
47 import java.util.Objects;
49 import java.util.stream.Collectors;
50 import java.util.stream.IntStream;
51 import java.util.stream.Stream;
57 @SuppressFBWarnings(
"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" )
73 @SuppressWarnings(
"unchecked" )
90 this( p_stream, p_actions, Collections.emptySet(), p_variablebuilder );
103 @Nonnull
final Set<IPlanBundle> p_planbundle, @Nonnull
final IVariableBuilder p_variablebuilder )
throws Exception
106 m_configuration = this.configuration(
111 p_planbundle.stream().flatMap( i -> i.initialbeliefs().stream() )
112 ).collect( Collectors.toCollection( LinkedHashSet::new ) ),
115 l_visitor.
plans().stream(),
116 p_planbundle.parallelStream().flatMap( i -> i.plans().stream() )
117 ).collect( Collectors.toSet() ),
120 l_visitor.
rules().stream(),
121 p_planbundle.parallelStream().flatMap( i -> i.rules().stream() )
122 ).collect( Collectors.toSet() ),
145 @Nonnull
final Set<IPlan> p_plans, @Nonnull
final Set<IRule> p_rules,
162 public final Stream<T>
generatemultiple(
final int p_number, @Nullable
final Object... p_data )
164 return IntStream.range( 0, p_number )
166 .mapToObj( i -> this.generatesingle( p_data ) )
167 .filter( Objects::nonNull );
IBaseAgentGenerator( @Nonnull final InputStream p_stream, @Nonnull final Set< IAction > p_actions, @Nonnull final IVariableBuilder p_variablebuilder)
ctor
IAgentConfiguration< T > configuration( @Nonnull final IFuzzyBundle< Boolean > p_fuzzy, @Nonnull final Collection< ILiteral > p_initalbeliefs, @Nonnull final Set< IPlan > p_plans, @Nonnull final Set< IRule > p_rules, @Nullable final ILiteral p_initialgoal, @Nonnull final IUnifier p_unifier, @Nonnull final IVariableBuilder p_variablebuilder)
builds the configuraion, configuration runs cloning of objects if needed
generator interface to create agents
ILiteral initialgoal()
returns the initial goal
final IASTVisitorAgent parse(final InputStream p_stream)
interface of logical rule
interface of an unification algorithm
visitor interface of the abstract-syntax-tree (AST) for an agent
external action interface
default agent configuration
Set< IRule > rules()
returns the rules / principles
interface to define the agent configuration
Set< IPlan > plans()
get a multimap with event-plan matching
interface for a variable builder which is called on each plan / rule execution
IBaseAgentGenerator( @Nonnull final InputStream p_stream, @Nonnull final Set< IAction > p_actions, @Nonnull final Set< IPlanBundle > p_planbundle, @Nonnull final IVariableBuilder p_variablebuilder)
ctor
Set< ILiteral > initialbeliefs()
returns initial beliefs
final Stream< T > generatemultiple(final int p_number, @Nullable final Object... p_data)
IVariableBuilder EMPTY
empty variable builder
final IAgentConfiguration< T > m_configuration
configuration of an agent