From dc49c0c521090f0eb4b9692b25a129537c07e19e Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 6 May 2005 18:56:52 +0000 Subject: [PATCH] it compiles --- action.cpp | 13 +++++++++---- action.h | 11 ++++++++--- node.cpp | 3 +-- node.h | 8 ++++---- planner.cpp | 17 +++++++++++++++++ planner.h | 45 +++++++++++++++++++++++++++++++++++++++++---- src.pro | 10 ++++++++++ 7 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 src.pro diff --git a/action.cpp b/action.cpp index 695c74f..3e9cddf 100644 --- a/action.cpp +++ b/action.cpp @@ -1,21 +1,26 @@ #include "action.h" Action::Action(std::string executable, literals preconditions, literals effects){ - _execututable = executable; + _executable = executable; _preconditions = preconditions; _effects = effects; } +Action::Action(const Action& action){ + _executable = action._executable; + _preconditions = action._preconditions; + _effects = action._effects; +} -const literals Action::effects(){ +literals Action::effects() const{ return _effects; } -const literals Action::preconditions(){ +literals Action::preconditions() const{ return _preconditions; } -int Action::execute(){ +int Action::execute() const{ return 0; } diff --git a/action.h b/action.h index 60206a3..35119c3 100644 --- a/action.h +++ b/action.h @@ -1,13 +1,18 @@ #ifndef __ACTION_H__ #define __ACTION_H__ -typedef literals std::vector; +#include +#include + +typedef std::vector literals; class Action { public: Action(std::string executable, literals preconditions, literals effects); - const literals effects() const; - const literals preconditions() const; + Action(const Action& action); + Action(){}; + literals effects() const; + literals preconditions() const; int execute() const; protected: diff --git a/node.cpp b/node.cpp index a9cb453..11fed08 100644 --- a/node.cpp +++ b/node.cpp @@ -1,6 +1,5 @@ #include "node.h" -Node::Node(Action action, std::vector children){ +Node::Node(Action action){ _action = action; - _children = children; } diff --git a/node.h b/node.h index db9fb09..55e34e6 100644 --- a/node.h +++ b/node.h @@ -6,13 +6,13 @@ class Node { - Node(Action action, std::vector children); - - addChild(Node& node); + public: + Node(Action action); + void addChild(Node* node); protected: Action _action; - std::vector _children; + std::vector _children; }; #endif diff --git a/planner.cpp b/planner.cpp index 159cb52..c5016a1 100644 --- a/planner.cpp +++ b/planner.cpp @@ -1,3 +1,20 @@ #include "planner.h" +#include "node.h" +using namespace std; +Planner::Planner(std::vector actions, literals init, literals goal){ + _start = new Node(Action("",init, literals())); + Node* finish = new Node(Action("",literals(),goal)); + + for(vector::iterator action = actions.begin(); action != actions.end(); ++action){ + literals preconds = action->preconditions(); + for (literals::iterator effect = preconds.begin(); effect != preconds.end(); ++effect){ + _actions[*effect] = *action; + } + } +} + + +void Planner::makePlan(Node* node){ +} diff --git a/planner.h b/planner.h index 1b4938b..7932eb9 100644 --- a/planner.h +++ b/planner.h @@ -1,14 +1,51 @@ #ifndef __PLANNER_H__ #define __PLANNER_H__ -#include -#include "node.h" +#include +#include +#include "action.h" + +class Node; + + + +namespace __gnu_cxx { + + template< typename CharT, typename Traits, typename Alloc > + struct hash< std::basic_string > { + size_t operator()(const std::basic_string& s) const { + + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); + +} + + }; + + template< typename CharT, typename Traits, typename Alloc > + struct hash< const std::basic_string > { //yes you need this version aswell! + +size_t operator()(const std::basic_string& s) const { + + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); + } + + }; +}; class Planner { public: + Planner(std::vector actions, literals init, literals goal); protected: - Node start; - std::hash_map addedNodes; + + void makePlan(Node* node); + + Node* _start; + __gnu_cxx::hash_map _addedNodes; + __gnu_cxx::hash_map _actions; }; #endif diff --git a/src.pro b/src.pro new file mode 100644 index 0000000..7446f02 --- /dev/null +++ b/src.pro @@ -0,0 +1,10 @@ +###################################################################### +# Automatically generated by qmake (1.07a) Fri May 6 20:04:49 2005 +###################################################################### + +TEMPLATE = app +INCLUDEPATH += . + +# Input +HEADERS += action.h node.h planner.h +SOURCES += action.cpp main.cpp node.cpp planner.cpp -- 2.39.2