Behavior Tree Implementations [closed] - algorithm

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for behavior tree implementations in any language, I would like to learn more about how they are implemented and used so can roll my own but I could only find one
Owyl, unfortunately, it does not contain examples of how it is used.
Any one know any other open source ones that I can browse through the code see some examples of how they are used etc?
EDIT: Behavior tree is the name of the data structure.

Here's a few I've found:
C# - https://github.com/netgnome/BehaviorLibrary (free)
C++ - http://aigamedev.com/insider/tutorial/second-generation-bt/ ($10)
C# - http://code.google.com/p/treesharp/ (free)
C# - https://github.com/ArtemKoval/Simple-Behavior-Tree-Library
Java - http://code.google.com/p/daggame/ DAG AI Code
C# - http://www.sgtconker.com/affiliated-projects/brains/
This Q on GameDev could be helpful, too.

Take a look at https://skill.codeplex.com/. this is a BehaviorTree code generator for unity. you can download source code and see if it is useful.

I did my own behavior tree implementation in C++ and used some modified code from the Protothreads Library. Coroutines in C is also a good read. Using this one can implement a coroutine system that allows one to run multiple behaviors concurrently without the use of multiple threads. Basically each tree node would have its own coroutine.

I don't know that I understand you right but I think to implement a tree you'r better choice is to use an formal language such as F# or Haskell. With Haskell you can use flexible and fast tree-structures and with F# you have an multiparadigm Language to parse and handle tree structures in oo Code.
I hope that helps you.

You can find behavior trees implemented in .NET in the YVision framework. We found them to be particularly suited for the development of Natural User Interface (NUI) applications.
It's not open-source but it's free to use and you can find information on how we implemented them in the tutorials: http://www.yvision.com/support/tutorials/
EDIT: Let me add that we use behavior trees for a lot more than just AI. Even the synchronization of the subsystem in the game loop is define by them.
Check the cases page to find the range of applications we are using them: robotics, camera-based interaction, augmented reality, etc.
Download the framework, try the samples and please give us feedback on our implementation.

https://github.com/TencentOpen/behaviac is a really excellent one.
behaviac supports the behavior tree, finite state machine and hierarchical task network.
Behaviors can be designed and debugged in the designer, exported and executed by the game.
The C++ version is suitable for the client and server side.
and, it is open sourced!

Related

RxJs good tutorials [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am trying to learn ReactiveX. I have spent almost a whole day and I am not able to understand it properly. I tried to look the official documentation but is is very difficult to understand. Something like this:
"Rx.Observable.prototype.flatMapLatest(selector, [thisArg])
Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence."
How a new person is able to understand it. So if someone knows the good resource then please mention
As a commenter has said, Brian Troncone's page is a good place: https://www.learnrxjs.io/.
The reality is that learning Rx is not a snap. The hard part isn't learning the library, the operators, etc. Rx requires at least a little bit of investment in thinking differently, at least for most people (myself included).
The best way to start understanding it is to play with it. For RxJS, the interactive examples in rx-book are a great place to start. They use jsbin, so you can run the sample code to see the output, then tweak the code to see what difference it makes.
From a .Net angle, playing with Linqpad is the best way to start getting a feel for how Rx works.
Ultimately you'll need to combine different aspects of learning:
Some theory reading
Some practical examples (which is where rx-book is useful)
Some practical application to a demo or real system of your own
I have a list of helpful resources that I've compiled here. But there is so much being put out there, especially on rxjs, that it's hard to keep up.
What's not common is true examples of real world usage of Rx. Partly this is because Rx is typically applied to larger scale problems, so it's not easy to just fabricate a good use case to make a demo from.
ReactiveTrader is one example of a large scale demonstration of applying Rx. It's a good example of an app making heavy use of Rx to build a complex web app that deals with streaming data and UI events.
I've also given a talk on how to apply Rx to tweet streams to analyze the data. This is oriented around real-time manipulation, aggregation and filtering of streaming data. There's a full video of the talk, plus articles discussing the approach and results here.
Ultimately it will take you time to learn Rx, but it will be worth the effort if you follow through.
The best way to learn RxJs to play with it by going through the api reference.
Besides that you can go through the following resources:
Video courses on Egghead.io
Awesome explanation: The introduction to Reactive Programming
you've been missing
Hot vs Cold Observables ( Also All Ben Lesh Articles on Medium)
Tutorials on youtube like : Adding Even More Fun to Functional
Programming With RXJS - Ryan Anklam
Explanatory tutorial with example on
https://auth0.com/blog/understanding-reactive-programming-and-rxjs/

Prolog - high-level purpose of WAM [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to understand the purpose of the WAM at a conceptual high level, but all the sources I have consulted so far assume that I know more than I currently do at this juncture, and they approach the issue from the bottom (details). They start with throwing trees at me, where as right now I am concerned with seeing the whole forest.
The answers to the following questions would help me in this endeavor:
Pick any group of accomplished, professional Prolog implementers - the SISCtus people, the YAP people, the ECLiPSe people - whoever. Now, give them the goal of implementing a professional, performant, WAM-based Prolog on an existing virtual machine - say the Erlang VM or Java VM. To eliminate answers such as "it depends on what your other goals are," lets say that any other goals they have besides the one I just gave are the ones they had when they developed their previous implementations.
Would they (typically) implement a virtual machine (the WAM) inside of a VM (Erlang/JVM), meaning would you have a virtual machine running on top of, or being simulated by, another virtual machine?
If the answer to 1 is no, does that mean that they would try to somehow map the WAM and its associated instructions and execution straight onto the underlying Erlang/Java VM, in order to make the WAM 'disappear' so to speak and only have one VM running (Erlang/JVM)? If so, does this imply that any WAM heaps, stacks, memory operations, register allocations, instructions, etc. would actually be Erlang/Java ones (with some tweaking or massaging)?
If the answer to 1 is yes, does that mean that any WAM heaps, stacks, memory ops, etc. would simply be normal arrays or linked lists in whatever language (Erlang or Java, or even Clojure running on the JVM for that matter) the developers were using?
What I'm trying to get at is this. Is the WAM merely some abstraction or tool to help the programmer organize code, understand what is going on, map Prolog to the underlying machine, perhaps provide portability, etc. or is it seen as an (almost) necessary, or at least quite useful "end within itself" in order to implement a Prolog?
Thanks.
I'm excited to see what those more knowledgeable than I are able to say in response to this interesting question, but in the unlikely event that I actually know more than you do, let me outline my understanding. We'll both benefit when the real experts show up and correct me and/or supply truer answers.
The WAM gives you a procedural description of a way of implementing Prolog. Prolog as specified does not say how exactly it must be implemented, it just talks about what behavior should be seen. So WAM is an implementation approach. I don't think any of the popular systems follow it purely, they each have their own version of it. It's more like an architectural pattern and algorithm sketch than a specification like the Java virtual machine. If it were firmer, the book Warren's Abstract Machine: A Tutorial Reconstruction probably wouldn't need to exist. My (extremely sparse) understanding is that the principal trick is the employment of two stacks: one being the conventional call/return stack of every programming language since Algol, and the other being a special "trail" used for choice points and backtracking. (edit: #false has now arrived and stated that WAM registers are the principal trick, which I have never heard of before, demonstrating my ignorance.) In any case, to implement Prolog you need a correct way of handling the search. Before WAM, people mostly used ad-hoc methods. I wouldn't be surprised to learn that there are newer and/or more sophisticated tricks, but it's a sound architecture that is widely used and understood.
So the answer to your three-part question is, I think, both. There will be a VM within the VM. The VM within the VM will, of course, be implemented in the appropriate language and will therefore use that language's primitives for handling the invisible parts of the VM (the stack and the trail). Clojure might provide insight into the ways a language can share things with its own implementation language. You would be free to intermix as desired.
The answer to your final question, what you're trying to get at, is that the WAM is merely an abstraction for the purposes you describe and not an end to itself. There is not, for instance, such a thing as "portable WAM bytecode" the way compiled Java becomes portable JVM bytecode which might justify it absent the other benefits. If you have a novel way of implementing Prolog, by all means try it and forget all about WAM.

Javascript data structures library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'd like to ask for recommendation of JavaScript library/libraries that supply an implementation of some basic data structures such as a priority queue, map with arbitrary keys, tries, graphs, etc. along with some algorithms that operate on them.
I'm mostly interested in:
The set of features covered,
Flexibility of the solution - this mostly applies to graphs. For example do I have to use a supplied graph implementation,
Use of functional features of the language - again it sometimes gives greater flexibility,
Performance of the implementation
I'd like to point out that I'm aware that it's possible to implement using JavaScript the following data structures:
A map, if key values are either strings or numbers,
A set, (using a map implementation),
A queue, although as was pointed out below, it's inefficient on some browsers,
At the moment I'm mostly interested in priority queues (not to confuse with regular queues), graph implementations that aren't very intrusive as to the format of the input graph. For example they could use callbacks to traverse the structure of the graph rather than access some concrete properties with fixed names.
I recommend to use Closure Library (especially with closure compiler).
Here you have a library with data structures goog.structs.
The library contains:
goog.structs.AvlTree
goog.structs.CircularBuffer
goog.structs.Heap
goog.structs.InversionMap
goog.structs.LinkedMap
goog.structs.Map
goog.structs.PriorityQueue
goog.structs.Set
As example you can use unit test: goog.structs.PriorityQueueTest.
If you need to work on arrays, there's also an array lib: goog.array.
As noted in comments, the source has moved to github.com/google/closure and the documentation's new location is: google.github.io/closure-library.
You can try Buckets is a very complete JavaScript data structure library that includes:
Linked List
Dictionary
Multi Dictionary
Binary Search Tree
Stack
Queue
Set
Bag
Binary Heap
Priority Queue
Probably most of what you want is built-in to Javascript in one way or another, or easy to put together with built-in functionality (native Javascript data structures are incredibly flexible). You might like JSClass.
As for the functional features of the language, underscore.js is where it's at..
I can help you with the maps with arbitrary keys: my jshashtable does this, and there is also a hash set implementation built on top of it.
Efficient queue.
If you find more of these, could you please add them to jswiki. Thanks. :)
Especially for graph-like structures, i find graphlib very convenient:
https://github.com/cpettitt/graphlib/wiki/API-Reference
It is very straight-forward, faster than other implementations I tried, has all the basic features, popular graph-algorithms and a JSON data export.
Adding a link to a custom javascript library which provides Priority Queues, Tries, Basic Graph processing and other implementation, for future reference of the visitors to this thread . Check out dsjslib
data.js.
I don't believe it's as feature rich as you want but it has graphs, hashes and collections.
I would take this a lightweight start that you can extend on.
As for what it does offer, it's well written, efficient and documented.
Is your javascript in an application, or a web page? If it's for an application, why not outsource the data structures to Redis? There's a client for nodejs
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Tell a web programmer how to write a very very simple GUI program [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am a web developer and server systems engineer.
But now my brother asked me if I could provide a little program for a very trivial demand.
Its just a form where the user can rate for factors on a scale from 1 to 7.
Based on these 4 values a final value from 1-10 is calculated. And this is done very easily with simple formulas like:
if(a>5 || b>3) { final = 4; }
else if ...
(just some basic formulas that can be expressed using logical operators and comparisions)
I told him he could just do this in excel or google docs, or a simple .html file with embedded javascript in it.
But this is a research project with a pharma company behind, and they may be willing to pay a few bucks for a little program.
There should be the option to later extend it with a 2nd survey where the result of the 1st is taken into account as a factor.
This is a very trivial program and the logic is safe and sound, but I have never done any gui programming.
I have done a lot in java, but only command line stuff, and php.
It should run easily on every system.
So I thought about using PHP-GTK, where it looks like you can compile binary executables that need no external interpreter.
But Java should also be fine.
Any recommendations?
I am also willing to look into other languages, it shouldn't be too hard.
So
What language/environment is the easiest way to do very, very simple Gui programs that run on every system?
For me, hands down the easiest is tcl/tk. It takes one line of code to create a label widget, another line of code for an entry widget. One line of code for a button. A few lines of code to do a calculation, and a few lines of code to lay the widgets out on the screen. If you want to get fancy, a few lines of code to guarantee the user only inputs digits and not some other characters.
Many people might vote this answer down because they hate tcl/tk. Don't let that sway you from at least considering it. It's a lot more mature than most people realize. And while the syntax of Tcl isn't everyone's cup of tea, it's trivially easy to learn.
For more information on tk, and to see the variety of languages you can use it on, see http://www.tkdocs.com
I would recommend using Adobe AIR (http://www.adobe.com/products/air/) and It is fairly straightforward to develop (since you know Java) and will have all the nice stuff you are looking for. :)
Java can do desktop - use Swing. NetBeans is supposed to have a pretty good GUI drag & drop capability, but I haven't used it myself. (I don't do desktop, either.)
For windows you can consider C#, The visual studio express editions are fee. All you need are a couple of text boxes and buttons etc. And if you know java, doing a bit of Dot Netting should be very trivial. I am also a java guy and i do a bit of c# for personal utils etc because they are so similar.

Templates of Technical and Functional Specs [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
So basically I am looking for good templates for writing both technical and functional specs on a project or work request.
What do you use? How deep do you get while writing the specs? Any additional general tips you could provide would be appreciated.
My company needs these badly. I work for a contractor and right now we do not use these documents at all.
EDIT: I have read Joel's take about Painless Specification, I really liked it, but are there any other opinions :)
On general tips;
We are implementing a process of
1) Business Requirements Statement (BRS)
2) Functional Specification
3) Technical specification
The BRS covers what the business problems are, and what the requirements are around solutions, testing, security, reliability and delivery. This defines what would make a successful solution.
The functional spec details what is needed, how it should look, how long fields should be, etc.
The technical spec details where the data comes from, any tricky code that may need to be considered.
The customer owns the requirements. The developers own the tech specs, and the functional spec is a middle ground. Testing is done against the tech specs (usually unit testing) then against the functional specs (usually system testing) and then against the requirements (UAT).
The important part of this (and we are struggling with) is that the developers still need to deliver to the functional spec, and the original business requirements. In reality the functional and tech specs are just there for clarity.
In short, my main tip is to first work out the process you wish to implement. Then seek agreement from all parties involved in your proposed process, then work on the templates to fit. The templates themselves are only are a small part of the change you want to make.
Not a template, but Joel has written a couple of articles on writing a functional spec. He also has sample here.
You can buy templates from ieee and other places, but I have always ended up making my own.
For a technical spec, "Code Complete" by Steve McDonnell has a good checklist, you can draw some info from that. At my last job, I just made a template out of his section headers, and tweaked it from there.
As far as a functional spec, the important thing is to define all the interfaces:
UI (screen mockups)
Software interfaces (plugins, etc.)
Hardware interfaces (if appropriate)
Communications interfaces (Services, email, messaging, etc.)
There should also be a section for business rules, things that are important functionally that are not covered in any interface definition.
If you want to purchase a book, Software Requirements by Karl Wiegers has templates for a few documents as an appendix. Unfortunately, I'm at work and that particular book is at home. If someone has it handy, they might be able to confirm that.
I happen to like this one, among others: ReadySet.
He sells a pro version too.
This is the best one I have found: http://www.jiludwig.com/templates/FRDTemplate.doc
Start off simple, and work your way from there. Since this is your first experience working with this, use a word document with bullet points. Write it, re-read it and provide enough detail that it makes sense. For technical specifications, you may want to lead the developer toward a solution, but for functional specifications the "how" should be completely missing.
I would suggest to have a look at the Roberston's Volere template here. They are part of the Atlantic Systems Guild, together with people like Tom DeMarco and Timothy Lister of "Peopleware" fame.
As the template is copyrighted, I will not reproduce it here, but give you some of the main headers:
The Purpose of the Project
The Stakeholders
Mandated Constraints
Naming Conventions and Terminology
Relevant Facts and Assumptions
The Scope of the Work
Business Data Model and Data Dictionary
The Scope of the Product
Functional Requirements
Look and Feels Requirements
...
There are many more, but this should give you an idea. The most interesting part of the template is the requirements shell that lists functional requirements on a kind of cue card. Again copyrighted, but truly valuable.
Look here in chapter 9.

Resources