A finite possibly non-deterministic state machine with dwell durations - java

after posting a somewhat ambiguous question, I believe I have nailed that what I am wondering (I am a complete novice in FSMs).
I would like to simulate a state space using finite state machines (possibly non-deterministic automata i.e. multiple next-state transitions allowed) in clojure.
This is essentially my problem:
Suppose we have these states Q={flying,cycling,running,driving} and we have the state durations for each during an average day D={120,30,30,60} - where for the sake of argument those are in minutes. How can one then create a possibly non-deterministic FSM (multiple destination states allowed) using clojure? I have looked at e.g. https://github.com/cdorrat/reduce-fsm and https://github.com/ztellman/automat but I do not believe it is quite what I want.
My end goal is to get a simulation looking something like S = {flying,flying,flying,flying,flying,cycling,cycling,running,driving,driving,driving}.
Effectively inducing heavy self-transition bias in the state machine. End and start state are not important.

The problem is not completely formulated to be answered unequivocally. Anyway:
If you just want to recognize a specific sequence of states, you can use a finite automaton, and you will have to write them in that order, like:
flying -> flying -> flying -> flying -> flying -> cycling -> cycling -> running -> driving -> driving -> driving
where I'm considering that the transitions are caused by the durations you refer.
However, I suspect that you possibly need something more elaborated. That, can not be elaborated here. In my opinion if this is for programming purposes, I suggest that you use state machine diagrams from UML. They are powerful enough for your problem.

I would recommend:
Draw the picture with states, transitions, and conditions for transitions.
Check the picture for consistency, dead loops, etc.
Implement FSM for yourself using maps and vectors. Do not use other FSM libraries until you need something heavy from FSM.
Here is an example of such an approach for ants simulation Ant FSM
When the ant is born it goes for food.
If ant sees a threat then it runs away from the threat.
If the threat disappears then an ant continues to find food.
If food is found by ants then it goes for home.
If an ant sees a threat then it runs away from the threat with food.
If the threat disappears then an ant continues to return home.
If ant at home it put food inside anthill then goes for food.

Related

Comparing between two skeleton tracking on processing 3

I am currently doing my dissertation which would involve in having 2 people a professional athlete and an amateur. First with the image processing skeletonization I would like to record the professional athlete while performing the squat exercise , then when the amateur performs the exercise I want to be able to compare the professional skeleton with that of the amateur to see if it is properly formed.
Please I m open for any suggestions and opinions , Would gladly appreciate some help
Here lies your question:
properly formed.
What does properly performed actually mean ? How can this be quantified ?
Bare in mind I'm not an athletic/experienced in this field.
If I were given the task I would counter-intuitively go in the opposite direction:
moving away form Processing 3/kinect/computer. I would instead:
find a professional athlete
find a skilled with trainer with functional mobility training.
find an amateur (probably easiest)
Item 2 will be trickier.For example FMS seems to put a lot of emphasis on correct exercising and mobility (to enhance performance and reduce risk of injuries). I'm not sure if that's the only approach or the best. You might want to check opinions on Physical Fitness, consult with people studying/teaching exercise science, etc. Do check credentials as it feels like a field where everyone has an opinion/preference.
The idea is to understand how a professional educated trainer asses correct movement. Take note of how that works in the real world and try to systemise it.
What are the cues for a correct execution ?
is the key poses
the motion in between
how the skeletal and muscular system work together/ the weights/forces applied/etc.
Having a better understanding of how this works in the real world should lead you to things you can start quantifying/comparing numerically on a computer.
Try to make a checklist/score system manually using a pen and paper based on the information you gather. If this works you already have a system you can start programming.
The next step is acquiring the data.
This is probably where the kinect comes, but bare in mind:
the second version of the kinect is more precise than the first
there is a Kinect2 SDK wrapper for Processing 3: use that if you can (windows only). There is a way you can get libfreenect2 working with OpenNI on osx/linux and therefore with SimpleOpenNI in Processing, but it's not straight forward and you won't have the same precision on the skeleton tracking algorithm
use data that is as precise as possible:
you can get the accuracy of a tracked skeleton joint
use an environment that doesn't contain a complex background (makes it easy to segment users and detect/track skeletons with little change of mistaking it for something else). prefer artificial non-incandescent light (less of a problem with kinect v2, but still you want as little IR interference as possible).
comparing orientation matrices or joints on single poses might not be enough to get the full picture: how do you capture/quantify motion taking into account the things that the kinect can't easily see: muscles flexing/forces applied/moving centre of gravity/etc.
try to use a grid system that will make it simple to pair the digital values with real world measurements. Check out how people used to study motion in the past, for example Étienne-Jules Marey or Eadweard Muybridge
Motion capture by Étienne-Jules Marey
Motion study by Eadweard Muybridge (notice the grid)
It's a pretty full on project to get right involving bits of anatomy/physics/kinematics/etc.
Start with the research first:
how did people study this in the past ?
what are the current developments ?
how does it work in the real world (without computers) ?
Take your constraints into account:
what resources (people/gear/etc.) can you use ?
how much time do you have available ?
Given the above, what topic/section of the project can be realistically be tackled to get useful results.
Overall probably something along these lines:
background research
real world studies
comparison system has feature which can be measured both with kinect and by a person
record data (real world data + mobility comparison evalutation and kinect data + mobility comparison)
compare data
write evaluation of findings (how effective is the system? what are limitations ? what could be improved (future work) ? etc.)
In short be aware of the kinect limitations: skeleton tracking is probability based: it's not 100% accurate. use data that's as clean/correct as possible to begin with (make it easy to acquire good data if you can control the capture environment). From what a real trainer would track, what could you track with a kinect ? do a comparison of the intersecting measurements.

Cellular Automata Java (Beginner)

I'm creating a game along the lines of Minicraft. I posted a question about how I should make a terrain similar to the one in the game here and user by the name of Quirliom posted an answer referring to what is called cellular automata.
I had absolutely no clue what it was, let alone how to do it. I did look it up and see what it was. But I have yet to find out how to do it. Could somebody please explain how to do it and how it works, perhaps a link or two or even some source codes/ examples.
For the theory, check out http://en.wikipedia.org/wiki/Book:Cellular_Automata. Once you have a sense of what cellular automata are in general, the next step is finding sources on their application to landscape generation (a pretty non-standard but not unheard of use); I suspect the initial theory readthrough will give you a pretty good sense on implementation techniques.
Formally, cellular automata are a subclass of dynamical system where space and time are discrete.
Depending on the model considered, some properties may or may not apply:
The component of the model are connected by a regular graph that is invariant by translation, rotation, etc.
Given S the state space, the updating rule is a function F(S^n) -> S where S^n is given by the neighborhood of a cell.
The updating rule is the same for all component.
The updating rule apply to all cells simultaneously, building states t+1 from states t.
Generally, cellular automata are good models to simulate a dynamical environment (sand, brownian motion, wildfires) because they allow large size and computation speed, due to their extreme simplicity.
If you want an entry in the world of cellular automata, I recommend you look up the Game of Life by Conway, find a tutorial and implement it.

Best algorithm for path finding in a tower defense

A have read about A* as well as D* and similar, and i'm not able to choose between them. What is the best searching algorithm when it comes with many searches(50 searches every tick) and with many different possibilities?
Between the two, I would pick D*. D* specifically assumes a best path, but if obstacles were encountered then recalculates. This means that each creep can have it's own personal view of the exit path, which is updated as the creep encounters obstacles.
Such assumptions on the best path with adjustments in behavior is slightly more realistic, as if you or I were walking the path, we wouldn't avoid obstacles prior to knowing about them. It also nicely accounts for path recalculation in the event someone (the players) builds a new tower. If you balance expansion of open nodes well, you might even have creeps walking around both sides of a tower centrally placed in the best path.
However, if you want to really make it fun, take a learning based approach on best path finding. Much more interesting than other solutions. To see an example, look to something like antbuster. Perhaps so interesting that it doesn't quite fit into the standard tower defense game genre.
Q-Learning may be a good choice for this. Q-Learning attempts to map out a grid of penatlies/gains that making a local decision would encoure in a finite world.

Java real time strategy game development

I'm coming to the end of my first year of CS and I thought a great way to consolidate all the things I've learnt this year would be a personal game project.
I would like to implement a 2D based rts, I'm thinking along the lines of starcraft I, warcraft II or even command and conquer. I will have about 3 months without interruptions to implement the game.
So to anyone experienced with java game programming, I have a few questions:
Is it realistic to design a 2D rts engine from scratch in 3 months?
If so what are some good books/resources to get started?
Would it be better to modify some existing project? I would think the experience of having to work with a lot of someone else's code would be good since our exposure to such topics in an undergrad cs degree seems very rare, if non-existent.
Are there any decent open source 2d rts projects that anyone could recommend? I've looked through a few but most seem to be written in c/c++
My humble thanks
Edit: Thanks for the quick responses, I think that perhaps it was a bad idea to post this in a rush since I think I misrepresented what I want to do.
When I say "along the lines of warcraft II etc" I mean more like that style of rts using sprites. I don't intend to implement a game nearly that complex, more like just a basic prototype.
My goal would be some thing more like a flat textured map with some basic obstacles like trees, a single unit producing structure like a barracks. I'd like to have the units to have health bars, be able to move and attack and die (and possible morph into another unit).
Far off goals would be to implement some basic pathing using a modified version of the dijkstra shortest path algorithm, ranged units with missle attack, etc.
I don't plan to implement any opponents or ai or networking or anything like that.
I'm thinking along the lines of starcraft I, warcraft II or even command and conquer
Make sure you purge your mind of matching the full scope of any of those. They took large teams of developers multiple years to make, with multi-million dollar budgets, so you can't even hope to approach those. They're called AAA for a reason. That being said, there's no reason you can't very minimally ape their design, or make a tiny game in their genre, assuming you have previous experience making small games.
A sub-genre of RTS that might be doable in that amount of time is a Tower Defense game. Plants vs Zombies is a good example. The reason I suggest this sub-genre is that you can avoid implementing any sort of AI or path-finding, which are notoriously difficult to get working, and I think technically impossible to implement "perfectly", especially with a limited CPU budget.
Make sure to reign in your scope. Favor a "complete" game over new features, because you can then call it "done" at any time. Get your game playable ASAP, and don't sweat the polish or details until you have to. Add one enemy type and one type of player unit (with only one ability, if you were thinking of implementing multiple abilities per unit). Make a title screen, menus (even if the menu is just "click screen to play"), game over screen, level complete or stat screens, cross-level player statistics, etc. Once you have all that ironed out, spend equal time adding new features and polishing the gameplay/graphics/bugs.
Once you have a playable, "complete" game ready (no matter how small in scope), find a real artist to do graphics for you. A shiny game always draws an audience, no matter how simple the gameplay.
It is very unrealistic to think you could implement a 2D RTS engine anywhere even close to the complexity in those kind of games. You could maybe get something very rough if you were experienced, but with only one year I think it's doubtful.
I can't help but feel like it would be much better for you if you used an existing engine or framework and built off of it. Like you said, working with other code would probably be a good learning experience as well. It would allow you to experiment without getting bogged down in having to do everything.
Keep it simple or you will simply drown in complexity before getting around to have anything playable. Since you have not tried it before, you will have a lot of nuts to crack and you don't know how long they will take.
Also remember that report writing and documentation takes time too.
The idea is good, and I think you can pull off a whole game if you find good building blocks. I would suggest discussing this with your teacher to hear what is acceptable for you to use. Would it e.g. be ok to do a game on an open source engine if you add some non-trivial functionality?
Update: Seems to be several engines available from Java at http://www.devmaster.net/engines/list.php?fid=6&sid=1
People often forget, that creating games is MUCH MORE than just coding the technique thing. Its about content creation, game design, sound and music, the "fun factor". If you make heavy use of existent APIs or engines, it will be possible, but writing it from scratch with no experience in 3 month is like asking yourself if you can code 100,000 LOC in this time which means 1111 LOC per day. This might be possible, but not if you have to desing and think, and just having the code makes no game.
Perhaps it would make sense to look at some existing efforts to get a feel for the scope of what you are looking at. These should give you some ideas or even code to build on:
http://www.duncanjauncey.com/btinternet/old/javagame/game.html
http://en.wikipedia.org/wiki/Lightweight_Java_Game_Library
http://www.ardor3d.com/
http://en.wikipedia.org/wiki/JMonkeyEngine
It would be a lot for me to bite off (from scratch) in the time given that is for sure. That is about all I can say.
EDIT: I thought maybe JOGRE was not what you are looking for. Then I thought about it and it seems like it would have all the right kinds of plumbing for what you are trying to do.
EDIT AGAIN: After my answer, one of the related questions links on the side seemed relevant: Java Game Programming: JOGL vs LWJGL?
Well if it gives you any hope at all, my team and I are currently working on an RTS game called "The Genesis Project". We call ourselves MotherBoard Games, or MBG for short. If you would like, I am always looking for more coders. You can email me at mpmn5891#gmail.com, I can give you some advice and tips form my 6 year experience, 2 of which have been spent making this game (to give you a scope)

A Simulator for a non-deterministic Push-Down Automaton

Well, I need to make simulator for non-deterministic Push-Down Automaton.
Everything is okey, I know I need to do recursion or something similar. But I do not know how to make that function which would simulate automaton.
I got everything else under control, automaton generator, stack ...
I am doing it in java, so this is maybe only issue that man can bump on, and I did it.
So if anyone have done something similar, I could use advices.
This is my current organisation of code:
Classes: class transit:
list<transit> -contains non deterministic transitions
state
input sign
stack sign class generator
it generate automaton from file clas NPA
public boolean start() - this function I am having trouble with
Of course problem of separate stacks, and input for every branch.
I tried to solve it with collection of objects NPA and try to start every object, but it doesn work.
Okay, think about the definition of the automaton. You have states and a state transition function. You have the stack. What makes life exciting is the non-determinism.
however, it is a theorem (look it up) that every nondeterministic finite automaton has an equivalent deterministic FSA.
One approach you could try is to construct the equivalent DFA. That's exponential space in the worst case, though: every state in the DFA maps to a subset of the powerset of the NFA states.
So you could try it "on line" instead. Now, instead of constructing the equivalent DFA, you simulate the NFA; at state transitions you construct all the next states you reach and put them on some data structure; then go back and see what happens next for each such state.
JFLAP is open source and does this (and much more!) - why not check it out?

Categories

Resources