forked from anubhav-gres/libff_parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.c
More file actions
124 lines (93 loc) · 2.1 KB
/
utility.c
File metadata and controls
124 lines (93 loc) · 2.1 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <string.h>
#include "utility.h"
#include "ff.h"
#include "output.h"
extern Bool artificial_gtt;
float MAX( float a, float b) {
if( (a == INFINITY) || (b == INFINITY)) return INFINITY;
if( a > b ) return a;
return b;
}
float MIN( float a, float b) {
if(a == INFINITY) return b;
if(b == INFINITY) return a;
if(a < b) return a;
return b;
}
float PLUS( float a, float b )
{
if (( a == INFINITY ) || ( b == INFINITY )) {
return INFINITY;
}
return ( a + b );
}
float get_cost(int effect) {
return gef_conn[effect].cost + gtt;
/*
if ( artificial_gtt ) {
return gop_conn[gef_conn[effect].op].cost;
}
else {
return gop_conn[gef_conn[effect].op].cost + gtt;
}
*/
}
void print_state( State *S )
{
int i;
printf("\n{");
for ( i = 0; i < S->num_F; i++ ) {
print_ft_name( S->F[i] );
printf(", ");
}
printf("}\n");
}
char *COLLECT_REWARD_STRING = "COLLECT";
char *FORGO_REWARD_STRING = "FORGO";
SG_ACTION_TYPE get_action_type(int op) {
Action *a = gop_conn[op].action;
if(strcmp(a->name, COLLECT_REWARD_STRING) == SAME) {
return SG_AT_COLLECT_REWARD;
}
else if(strcmp(a->name, FORGO_REWARD_STRING) == SAME) {
return SG_AT_FORGO_REWARD;
}
return SG_AT_OTHER;
}
Bool effect_deletes_fact(int effect, int fact) {
int i;
for(i = 0; i < gef_conn[effect].num_D; i++) {
if(gef_conn[effect].D[i] == fact)
return TRUE;
}
return FALSE;
}
Bool effect_adds_fact(int effect, int fact) {
int i;
for(i = 0; i < gef_conn[effect].num_A; i++) {
if(gef_conn[effect].A[i] == fact)
return TRUE;
}
return FALSE;
}
void add_fact(State *S, int fact) {
int i;
for(i = 0; i < S->num_F; i++) {
if (S->F[i] == fact) {
return;
}
}
S->F[S->num_F++] = fact;
}
void remove_fact(State *S, int fact) {
int i, j;
for(i = 0; i < S->num_F; i++) {
if (S->F[i] == fact) {
for (j = i; j + 1 < S->num_F; j++) {
S->F[j] = S->F[j + 1];
}
S->num_F--;
return;
}
}
}