Recently I was playing a game of Gin with my grandmother. We played a whole afternoon and as far as I can remember, I didn't won a single game.
So I told here that it with the help of computers it could become a much better player. She couldn't believe how computers could be useful there and that's why I want to demonstrate it.
I already implemented part of the logic, but now I have the problem that my solver is really not so sexy because he mainly is based on a brute force method. That is I calculated all the possibilities, score them according to the chances for a win and choose the best one. Is there any more sophisticated approach?
I'm talking about standard Gin. The implementation is done in C#.
I'm not 100% familiar with gin, but one thing to keep in mind is each strategy can be broken.
When you play, you have to play multiple players. Do they both have the same strategy? Do they have different strategy? If we played you might beat me in gin, but I might beat your grandma. How does your grandma know how to play? If you were given the same hand she does, how would she play it differently than yours? Yes you can take a look at the statistics, but your grandma doesn't play by statistics - she plays by experience. If you want to make it more sophisticated ask yourself "How can I factor experience into the hand?"
Related
I know that a certain delay between the “play-order” and the actual start of the playback of a sound is inevitable.
However, for my current project, I must be able to start a sound-playback at a certain moment in time. This moment is known, so the solution to the problem is ether to reduce the delay-time as much as possible or to somehow predict the latency and start the sound somewhat earlier (depending on the predicted latency).
I describe the problem in detail here:
https://naudio.codeplex.com/discussions/662236
My current solution is to use NAudio to play a sound and simultaneously observe the sound-output-volume. This way I can measure the latency and use it to time the “play-order” for the following sounds.
This way I get decent results (about 30 ms deviation from the supposed play-time), but I wanted to ask if you guys have better suggestions.
Best regards and many thanks
I am studying C# at the moment and I had an exam recently. I had to create a console game that has moving objects. I pretty much managed to do everything that was required, except I couldn't think out a way how to make each game object to move at different speed (actually there are only two moving objects, floors and the character), one of the tasks was to make powerups that increase either the character speed or the floors speed.... I couldn't think out a way how to modify their speed separately.. I am currently trying to finish the game but I cna't get my thoughts around this, my "endgame" is to have two variables charSpeed and floorSpeed... Could anyone explain to me how I can achieve this?
Thanks!
My code - http://pastebin.com/TkPd37xD - it's currently a mess, I just want to figure out what is the logic behind what I want to do. A "general solution", here I have only 2 objects, what if I want to change the speed of 10 objects?
P.S. No Classes, I can go up to Structs, I have not worked with Classes yet.
P.S.S. I take any kind of advices or criticizm about my code, so anything is appreciated since I am still learning, but my main concern at the moment is how to solve the problem at hand.
I would use a Timer for each different levep speed.
The callback of the timer would execute the logic of the movement.
This will certainly required a refactoring of your code ;)
I'm trying to create a program which gets the various "notes" in a sound file (WAV or MP3) and can get the frequency and amplitude of each. I've been searching around for this, and of course there is the problem of distinguishing individual "notes" in a music file which isn't a MIDI, but it seems that something along these lines can be done with NAudio or DirectSound. Any ideas?
Thanks!
What you are asking to do is extremely difficult.
Step one would be to convert your audio from a time domain to a frequency domain. That is, you take a number of samples, and do a Fourier transform (implemented in your software as FFT).
Next, you begin deciding what you call a note or not. This is as not as simple as picking out the loudest of the frequencies! Different instruments have different timbre, which is created by various harmonics. If you had a song of nothing but sine waves, this would be much simpler. However, you'll find that you'll start seeing notes where your ear tells you they don't exist.
Now, psychoacoustics come into play. It is entirely possible for humans to "hear" notes that do not even have a fundamental. This is particularly true in a musical context. If I were to take a trombone and start playing a scale downward, at some point, the fundamental disappears or is mostly gone. However, you will still perceive that scale as going downward, when in fact the fundamental sound has all-but disappeared. Things get really tricky at this point.
To answer your question, start with an FFT. Maybe this is sufficient for your needs. If not, begin reading the significant amount of technical literature on the subject.
I am looking for a way to approximate a volume of fluid moving over a heightmap. The easiest solution I can think of is to approximate it as a large number of non-drawn spheres, of small diameter (<0.1m). I would then place a visible plane representing the surface of the water on "top" of the spheres, at the locations they came to rest. To my knowledge, no managed physics engines contain a built in fluid simulator, hence the question.
Implementation would consist of using a physics engine such as JigLibX, which is capable of simulating the motion of the spheres. To determine the height of the planes, I was thinking of averaging the maximum height of each sphere that is on the top layer of a grouping.
I dont expect performance to be great, but would it be approachable for real time? If not, could I use this simulation to pre-bake lines of flow?
I hope this makes sense, I really want opinions/suggestions as to whether this is feasible, or if there is a better way of approaching this.
Thanks for any help, Venatu
(If its relevant, my target platform is XNA 4.0, using C#. Windows only at this point in time, so PhysX/Havok are possibilities for the simulation, but I would prefer a managed solution)
I haven't seen realistic fluid dynamics in real time without using something like PhysX as of yet - probably because the calculations needed are so complicated! The problem with your approach as I see it would come with the resting contact of all those spheres as they settled down, which takes up a lot of processing power. Lots of resting contact points are notorious for eating into performance very quickly, even on the most powerful of desktops.
If you are going down this route then I'd recommend modelling the fluid as an elastic but solid body using spring based physics, where the force applied to one part of the water would use springs to propagate out to the rest. This gives you the option of setting a breaking point for the springs and separating the body into two or more bodies when that happens (and the reverse for coming back together.) This can give you the foundation for things like spray. It's also a more versatile approach in terms of performance, because you can choose the number of particles and springs you use to approximate your model.
It's a big and complicated topic, but I hope that provided at least some insight!
The most popular method to simulate fluids in real-time is Smoothed-particle hydrodynamics.
Several useful links:
http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics
http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html
http://www.plunk.org/~trina/thesis/html/thesis_toc.html
In addition to simulation itself you will also need some specialized broad-phase collision detection algorithms such as sweep-and-prune or hashing cells.
And you're right, there is no completed 2d solutions for the fluid dynamics.
I'm planning to develop an expert system that automatically fits the school faculty's work load (time, teaching load, etc), and generate class sections, room that is at least 90% accurate with what the Director of a certain department wants to assign the schedule for a certain semester.
What algorithm to use? Heuristics? Optimization? Any suggestions or help is highly appreciated!
Two friends of mine did something similar for a class project. They used the simulated annealing heuristic. They concluded that it might not be the best tool for the job.
Hey, knowing what not to do can be useful, right? :)
Here are some general observations:
1) Manual scheduling is rarely attempted from scratch. Instead, somebody starts with the schedule for the previous year and alters it to take account of changes in requirements. One way of mimicing this with a computer is to use a hill-climbing algorithm, which repeatedly tries a number of small changes to improve a solution so far. This can then be started off at the current schedule.
2) Does the manual process ever terminate with the conclusion that the requirements are collectively unachievable and that some of them must be dropped? In that case your algorithm must be transparent enough that failures can be understood, or at least capable of proposing such changes (e.g. by maximising a penalty function which allows it to produce a "least bad" solution which does not satisfy all of the original constraints). I know of one case where a sophisticated constraint-based approach was replaced by a much simpler algorithm because failures of the constraint-based system did not give enough user feed back.
3) Curiously enough, the next generation system did not use sophisticated scheduling at all. It turned out - roughly speaking - that at the time the decisions had to be made not all of the consequences of sophisticated scheduling decisions could be forseen, and, in the long run, a simple predictable schedule that could be maintained indefinitely was more productive than constantly rearranging schedules to grab small momentary advantages.
Take a look at the curriculum course lesson scheduling example of Drools Planner (open source, java I am afraid). It uses meta-heuristics such as simulated annealing and tabu search.
Here is a paper on dynamic scheduling using genetic algorithms... you might find some of the ideas here useful... even if the domain isn't the same, I think the idea is more generally applicable.