-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAgentAction.cpp
54 lines (40 loc) · 1.2 KB
/
AgentAction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "Domain.h"
void AgentAction::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) {
s << "( :ACTION " << name << "\n";
TokenStruct< std::string > astruct;
std::stringstream ss;
ss << "?" << d.types[params[0]]->name;
astruct.insert( ss.str() );
s << " :AGENT " << astruct[0];
if ( d.typed ) s << " - " << d.types[params[0]]->name;
s << "\n";
s << " :PARAMETERS ";
printParams( 1, s, astruct, d );
s << " :PRECONDITION\n";
if ( pre ) pre->PDDLPrint( s, 1, astruct, d );
else s << "\t()";
s << "\n";
s << " :EFFECT\n";
if ( eff ) eff->PDDLPrint( s, 1, astruct, d );
else s << "\t()";
s << "\n";
s << ")\n";
}
void AgentAction::parse( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
TokenStruct< std::string > astruct;
f.next();
f.assert( ":AGENT" );
astruct.insert( f.getToken() );
if ( d.typed ) {
f.next();
f.assert( "-" );
astruct.types.push_back( f.getToken( d.types ) );
}
else astruct.types.push_back( "OBJECT" );
f.next();
f.assert( ":PARAMETERS" );
f.assert( "(" );
astruct.append( f.parseTypedList( true, d.types ) );
params = d.convertTypes( astruct.types );
parseConditions( f, astruct, d );
}