Unity game development–Behavior tree (Part 2)

1. Behavior tree node code example The node implementation code connecting Part1 is as follows (simple framework) State type enumeration using System.Collections; using System.Collections.Generic; using UnityEngine; public enum E_NodeState {<!– –> Success,//success Failed,//Failed Running//In progress } Node base class namespace BT {<!– –> /// <summary> /// Behavior node base class /// </summary> public abstract class […]

Tree dp – a super practical data structure

? 1. Concept introduction Tree DP is dynamic programming based on trees as a model. Mainly use the substructure brought by the tree itself (the parent-child relationship on the tree) to perform state transfer. Generally, the DP value of the parent node is derived from the DP value of the child node. 2. Detailed explanation […]

Data structure red-black tree (RBTree)

Data structure red-black tree (RBTree) Article directory Data structure red-black tree (RBTree) 1. The concept of red-black trees 2. Properties of red-black trees 3. Definition of red-black tree nodes 4. Red-black tree structure 5. Insertion operation of red-black tree 1. Insert new nodes according to the tree rules of binary search 2. Check whether the […]

Data structure: Principle and implementation of red-black tree

Article directory Red black tree concept red black tree properties Simulation implementation of red-black tree Red-black tree balance problem Overall implementation and testing This article is used to disassemble and simulate the red-black tree, laying the foundation for subsequent map and set encapsulation. The concept of red-black trees The red-black tree is also a binary […]

Huffman trees and Huffman coding

1 //The structure of haffman tree 2 typedef struct 3 { 4 //Leaf node weight 5 unsigned int weight; 6 //Pointers to parents and child nodes 7 unsigned int parent; 8 unsigned int lChild; 9 unsigned int rChild; 10 } Node, *HuffmanTree; 11 12 //Dynamically allocate arrays to store Huffman codes 13 typedef char *HuffmanCode; […]

Pre-middle and post-order traversal (recursive and non-recursive) and level-order traversal of binary trees

Pre-middle and post-order traversal (recursive and non-recursive) and level-order traversal of binary trees Article directory Pre-middle and post-order traversal (recursive and non-recursive) and level-order traversal of binary trees Preface 1. Recursive implementation 1. Preorder traversal 2. In-order traversal 3. Post-order traversal 2. Non-recursive implementation 1. Preorder traversal 2. In-order traversal 3. Postorder traversal 3. Layer […]

[C language data structure——Binary tree]

Article directory Article directory 1. What is a tree? tree definition tree type tree depth Basic terminology for trees 2. Full binary tree definition Characteristics of a full binary tree 3. Complete binary tree definition Features 4. Properties of binary trees 5. Storage structure of binary tree sequential storage structure chain storage structure 6. Basic […]

vue3+element plus tree shuttle box

HTML <template> <div class=’tree-transfer’> <div class=”left-tree”> <div class=”tree-tit”>{<!– –>{leftTit || ‘Left column’}}</div> <div class=”list”> <el-tree ref=”treeRefL” v-if=”reLoad” :data=”leftData” show-checkbox default-expand-all :node-key=”nodeKey” highlight-current :props=”defaultProps” /> </div> </div> <div class=”btn-div”> <el-button :icon=”Back” type=”primary” :disabled=”disabled” @click=”toLeft()” /> <el-button :icon=”Right” type=”primary” :disabled=”disabled” @click=”toRight()” /> </div> <div class=”right-tree”> <div class=”tree-tit”>{<!– –>{rightTit || ‘right column’}}</div> <div class=”list”> <el-tree ref=”treeRefR” v-if=”reLoad” :data=”rightData” […]

PHP uses recursion to integrate its two-dimensional array into a hierarchical tree, where the hierarchical id is in a uuid format. The weird problem has been solved.

No more verbosity, just go directly to the source code. <?php function findChildren($list, $p_id){ $r = array(); foreach ($list as $k => $item) { if ($item[‘fid’] == $p_id) { unset($list[$k]); $length = count($r); $r[$length] = $item; if ($t = findChildren($list, $item[‘id’])) { $r[$length][‘children’] = $t; } } } return $r; } function findChildren2($list,$p_id, & amp;$sike=[]) […]