From 082a37585bcd8ed7b5659951563956943212c722 Mon Sep 17 00:00:00 2001 From: Kumar-laxmi Date: Fri, 6 Oct 2023 07:05:46 +0530 Subject: [PATCH] AO Star in C++ added --- C++/Trees/AO_Star.cpp | 212 ++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 C++/Trees/AO_Star.cpp diff --git a/C++/Trees/AO_Star.cpp b/C++/Trees/AO_Star.cpp new file mode 100644 index 000000000..ec0bbd1f0 --- /dev/null +++ b/C++/Trees/AO_Star.cpp @@ -0,0 +1,212 @@ +#include +#define MAX 1000 +#define EDGE 5 +using namespace std; +bool or_map[MAX],and_map[MAX]; + +vector or_edges; +vector< vector > and_edges; + +vector adj[MAX]; + +int cost[MAX]; +bool isSolved[MAX],visited[MAX]; +int min(int a,int b){return a v;v.push_back(3);v.push_back(4); + and_map[3]=and_map[4]=true; + and_edges.push_back(v); v.clear(); + + v.push_back(5);v.push_back(6);v.push_back(7); + and_map[5]=and_map[6]=and_map[7]=true; + and_edges.push_back(v); v.clear(); + + for(int i=1;i<=21;i++) + if(and_map[i]==false) or_map[i]=true; + + cout<<"and_edges: "< temp_map; + for(int i=0;i temp_map1; + for(int i=0;icost[adj[head][i] ]+EDGE){ + bestCost=cost[adj[head][i] ]+EDGE; + bestMove=i;isAnd=false; + temp_map1[adj[head][i]]=1; + + //cout<<"or_edge: "<c && c!=0){ + bestCost=c;bestAndIndex=ii; + bestMove=i;isAnd=true; + } + } + cout<<"moving forward, finding the best move,i: <<"< temp_map; + for(int i=0;i