-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathHTNOperator.cpp
80 lines (64 loc) · 1.58 KB
/
HTNOperator.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "Domain.h"
void HTNOperator::SHOPPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) {
s << "( :OPERATOR (" << name << " ";
//params
TokenStruct< std::string > astruct;
std::stringstream ss;
printParams( 0, s, astruct, d );
s<<")\n";
//preconds
if ( pre ) pre->PDDLPrint( s, 1, astruct, d );
else s << "\t()";
s << "\n";
//del effects
if ( deleff ) deleff->PDDLPrint( s, 1, astruct, d );
else s << "\t()";
s << "\n";
//add effects
if ( eff ) eff->PDDLPrint( s, 1, astruct, d );
else s << "\t()";
s << "\n";
s << ")\n";
}
void HTNOperator::SHOPparse( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
TokenStruct< std::string > astruct = f.parseTypedList( false );
params = d.convertTypes( astruct.types );
parseSHOPConditions( f, astruct, d );
}
void HTNOperator::parseSHOPConditions( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
f.next();
f.assert( "(" );
if ( f.getChar() != ')' ) {
if(f.getChar() == '('){
pre = new And;
}
else
pre = createSHOPCondition( f, d );
pre->SHOPparse( f, ts, d );
}
else ++f.c;
f.next();
f.assert( "(" );
if ( f.getChar() != ')' ) {
if(f.getChar() == '('){
deleff = new And;
}
else
deleff = createSHOPCondition( f, d );
deleff->SHOPparse( f, ts, d );
}
else ++f.c;
f.next();
f.assert( "(" );
if ( f.getChar() != ')' ) {
if(f.getChar() == '('){
eff = new And;
}
else
eff = createSHOPCondition( f, d );
eff->SHOPparse( f, ts, d );
}
else ++f.c;
f.next();
f.assert( ")" );
}