//prints board void print_board(char * b) { int i, j; printf("Score1: %d, Score2: %d\n", score(b,color1), score(b,color2)); printf("Frontier1: %d, Frontier2: %d\n", frontier(b,color1), frontier(b,color2)); for (i=0; i<BOARD_SIZE; i++) { for (j=0; j<BOARD_SIZE; j++) printf("%c ", get_cell(i, j, b)+97); printf("\n"); } }
void Assembler::li64 (const Reg64& rt, int64_t imm64, bool fixedSize) { // li64 always emits 5 instructions i.e. 20 bytes of instructions. // Assumes that 0 bytes will be missing in the end. uint8_t missing = 0; // for assert purposes DEBUG_ONLY CodeAddress li64StartPos = frontier(); if (HPHP::jit::deltaFits(imm64, HPHP::sz::word)) { // immediate has only low 16 bits set, use simple load immediate li(rt, static_cast<int16_t>(imm64)); if (imm64 & (1ULL << 15) && !(imm64 & (1ULL << 16))) { // clear extended sign that should not be set // (32bits number. Sets the 16th bit but not the 17th, it's not negative!) clrldi(rt, rt, 48); missing = kLi64Len - 2 * instr_size_in_bytes; } else { missing = kLi64Len - 1 * instr_size_in_bytes; } } else if (HPHP::jit::deltaFits(imm64, HPHP::sz::dword)) { // immediate has only low 32 bits set lis(rt, static_cast<int16_t>(imm64 >> 16)); ori(rt, rt, static_cast<int16_t>(imm64 & UINT16_MAX)); if (imm64 & (1ULL << 31) && !(imm64 & (1ULL << 32))) { // clear extended sign // (64bits number. Sets the 32th bit but not the 33th, it's not negative!) clrldi(rt, rt, 32); missing = kLi64Len - 3 * instr_size_in_bytes; } else { missing = kLi64Len - 2 * instr_size_in_bytes; } } else if (imm64 >> 48 == 0) {
void SSAPass::_run(IRManager& irm) { OptPass::computeDominators(irm); DominatorTree* dominatorTree = irm.getDominatorTree(); ControlFlowGraph& flowGraph = irm.getFlowGraph(); DomFrontier frontier(irm.getNestedMemoryManager(),*dominatorTree,&flowGraph); SSABuilder ssaBuilder(irm.getOpndManager(),irm.getInstFactory(),frontier,&flowGraph, irm.getOptimizerFlags()); ssaBuilder.convertSSA(irm.getMethodDesc()); irm.setInSsa(true); irm.setSsaUpdated(); }
void parser_t::parse_netlist(const pstring &nlname) { while (true) { token_t token = get_token(); if (token.is_type(ENDOFFILE)) return; require_token(m_tok_param_left); m_setup.log().debug("Parser: Device: {1}\n", token.str()); if (token.is(m_tok_ALIAS)) net_alias(); else if (token.is(m_tok_DIPPINS)) dippins(); else if (token.is(m_tok_NET_C)) net_c(); else if (token.is(m_tok_FRONTIER)) frontier(); else if (token.is(m_tok_PARAM)) netdev_param(); else if (token.is(m_tok_HINT)) netdev_hint(); else if (token.is(m_tok_NET_MODEL)) net_model(); else if (token.is(m_tok_SUBMODEL)) net_submodel(); else if (token.is(m_tok_INCLUDE)) net_include(); else if (token.is(m_tok_LOCAL_SOURCE)) net_local_source(); else if (token.is(m_tok_TRUTHTABLE_START)) net_truthtable_start(nlname); else if (token.is(m_tok_LOCAL_LIB_ENTRY)) { m_setup.register_lib_entry(get_identifier(), "parser: " + nlname); require_token(m_tok_param_right); } else if (token.is(m_tok_NETLIST_END)) { netdev_netlist_end(); return; } else device(token.str()); } }
//default constructor Maze::Maze(int rows, int cols) { width = cols; height = rows; grid = new Cell*[rows]; for(int i = 0; i < rows; ++i) { grid[i] = new Cell[cols]; for(int j = 0; j < cols; ++j)//initialize all cells as "out" { grid[i][j].inMaze = CellState::out; grid[i][j].x = i; grid[i][j].y = j; } } std::vector<Cell> frontier(cols*rows); }
//run A* from the closest node to Blinky to the closest node that Pacman is occupying Direction::Enum aStar(const World& in_ourWorld, PathNode* currentNode, PathNode* targetNode) { std::priority_queue<std::shared_ptr<ScoredNode>, std::vector<std::shared_ptr<ScoredNode>>, std::function<bool(std::shared_ptr<ScoredNode>, std::shared_ptr<ScoredNode>)>> frontier(NodeComparer); std::map<PathNode*, std::shared_ptr<ScoredNode>> processedNodes; std::map<PathNode*, std::shared_ptr<ScoredNode>> frontierMap; std::vector<const Pawn* const> ghosts; ghosts.push_back(&in_ourWorld.GetBlinky()); ghosts.push_back(&in_ourWorld.GetInky()); ghosts.push_back(&in_ourWorld.GetPinky()); ghosts.push_back(&in_ourWorld.GetClyde()); std::shared_ptr<ScoredNode> rootNode = std::make_shared<ScoredNode>(currentNode, 0.f, huristic(*currentNode, *targetNode), Direction::Invalid, nullptr); frontier.push(rootNode); frontierMap.insert(std::pair<PathNode*, std::shared_ptr<ScoredNode>>(currentNode, rootNode)); while (frontier.size() > 0 && frontier.top()->node != targetNode) { std::shared_ptr<ScoredNode> topNode = frontier.top(); frontier.pop(); auto frontierEntry = frontierMap.find(topNode->node); //If we are not in the frontier map then this is just garbage to be collected if (frontierEntry == frontierMap.end()) continue; frontierMap.erase(frontierEntry); processedNodes.insert(std::pair<PathNode*, std::shared_ptr<ScoredNode>>(topNode->node, topNode)); Expand(in_ourWorld, topNode, *targetNode, ghosts, frontier, frontierMap, processedNodes); } if (frontier.size() > 0) { ScoredNode* rootConnection = frontier.top()->GetRootConnection(); if (rootConnection) return rootConnection->connectionDirection; } return Direction::Invalid; }
//mixing score and frontier int mix(char * b, char color) { return score(b,color) + frontier(b,color); }
void match_tree(const int id, const hypergraph_type& graph_in, IteratorTree tree_iter) { if (graph_in.nodes[id].edges.empty()) return; //std::cerr << "node: " << id << std::endl; queue_type queue; for (size_t grammar_id = 0; grammar_id != tree_grammar.size(); ++ grammar_id) { const tree_transducer_type& transducer = tree_grammar[grammar_id]; //std::cerr << "transducer: " << grammar_id << std::endl; const symbol_type cat = graph_in.edges[graph_in.nodes[id].edges.front()].rule->lhs; const tree_transducer_type::edge_type edge_id = transducer.edge(cat); if (edge_id == tree_transducer_type::edge_type()) continue; const tree_transducer_type::edge_type edge_epsilon = transducer.edge(vocab_type::EPSILON); const tree_transducer_type::edge_type edge_none = transducer.edge(vocab_type::NONE); tree_transducer_type::id_type node = transducer.next(transducer.root(), edge_id); if (node == transducer.root()) continue; node = transducer.next(node, edge_none); if (node == transducer.root()) continue; //std::cerr << "grammar cat: " << cat << " id: " << edge_id << std::endl; queue.clear(); queue.push_back(state_type(frontier_type(1, id), node)); while (! queue.empty()) { const state_type& state = queue.front(); frontier_queue_type frontiers(1, frontier_type()); frontier_queue_type frontiers_next; node_queue_type nodes(1, state.node); node_queue_type nodes_next; feature_queue_type features(1, state.features); feature_queue_type features_next; attribute_queue_type attributes(1, state.attributes); attribute_queue_type attributes_next; edge_set_type edges; frontier_type::const_iterator niter_end = state.frontier.end(); for (frontier_type::const_iterator niter = state.frontier.begin(); niter != niter_end; ++ niter) { frontiers_next.clear(); nodes_next.clear(); features_next.clear(); attributes_next.clear(); edges.clear(); hypergraph_type::node_type::edge_set_type::const_iterator eiter_end = graph_in.nodes[*niter].edges.end(); for (hypergraph_type::node_type::edge_set_type::const_iterator eiter = graph_in.nodes[*niter].edges.begin(); eiter != eiter_end; ++ eiter) { const hypergraph_type::edge_type& edge = graph_in.edges[*eiter]; edges.push_back(transducer.edge(edge.rule->rhs)); } frontier_queue_type::const_iterator fiter = frontiers.begin(); feature_queue_type::const_iterator siter = features.begin(); attribute_queue_type::const_iterator aiter = attributes.begin(); node_queue_type::const_iterator titer_end = nodes.end(); for (node_queue_type::const_iterator titer = nodes.begin(); titer != titer_end; ++ titer, ++ fiter, ++ siter, ++ aiter) { const tree_transducer_type::id_type node_epsilon = transducer.next(*titer, edge_epsilon); if (node_epsilon != transducer.root()) { frontier_type frontier(*fiter); frontier.push_back(*niter); frontiers_next.push_back(frontier); nodes_next.push_back(node_epsilon); features_next.push_back(*siter); attributes_next.push_back(*aiter); } edge_set_type::const_iterator eiter_begin = edges.begin(); edge_set_type::const_iterator eiter_end = edges.end(); for (edge_set_type::const_iterator eiter = eiter_begin; eiter != eiter_end; ++ eiter) if (*eiter != tree_transducer_type::edge_type()) { const tree_transducer_type::edge_type& edge_id = *eiter; const tree_transducer_type::id_type node_edge = transducer.next(*titer, edge_id); if (node_edge != transducer.root()) { const hypergraph_type::edge_type& edge = graph_in.edges[graph_in.nodes[*niter].edges[eiter - eiter_begin]]; frontier_type frontier(*fiter); frontier.insert(frontier.end(), edge.tails.begin(), edge.tails.end()); frontiers_next.push_back(frontier); nodes_next.push_back(node_edge); features_next.push_back(*siter + edge.features); attributes_next.push_back(*aiter + edge.attributes); } } } frontiers.swap(frontiers_next); nodes.swap(nodes_next); features.swap(features_next); attributes.swap(attributes_next); frontiers_next.clear(); nodes_next.clear(); features_next.clear(); attributes_next.clear(); } //std::cerr << "finished loop: " << frontiers.size() << std::endl; // frontiers and nodes contain new frontier! // in addition, we need to traverse transducer.next() with edge_none! frontier_queue_type::const_iterator fiter = frontiers.begin(); feature_queue_type::const_iterator siter = features.begin(); attribute_queue_type::const_iterator aiter = attributes.begin(); node_queue_type::const_iterator titer_end = nodes.end(); for (node_queue_type::const_iterator titer = nodes.begin(); titer != titer_end; ++ titer, ++ fiter, ++ siter, ++ aiter) { const tree_transducer_type::id_type node_none = transducer.next(*titer, edge_none); if (node_none == transducer.root()) continue; queue.push_back(state_type(*fiter, node_none)); const tree_transducer_type::rule_pair_set_type& rules = transducer.rules(node_none); if (rules.empty()) continue; // try match with rules with *fiter == frontier-nodes and generate graph_out! tree_transducer_type::rule_pair_set_type::const_iterator riter_end = rules.end(); for (tree_transducer_type::rule_pair_set_type::const_iterator riter = rules.begin(); riter != riter_end; ++ riter) { *tree_iter = *riter; ++ tree_iter; } } queue.pop_front(); } } }