Random Rain Sounds in GameMaker - game-engine

I’m making a game with GameMaker 1.4 and I’m in a dungeon room and I want to add drop sounds (like it’s damp) randomly.
Thank You!

Depending on how often you want the raindrop sound to play, you can use the random_range() function (https://docs.yoyogames.com/source/dadiospice/002_reference/maths/real%20valued%20functions/random_range.html) to variably count up to a pre-defined variable amount, or if it hits a specific number (like rolling a 1 through 4 on a 10 sided dice). Once that amount is hit, either randomly or by adding up to a threshold amount, you can just play the raindrop soundfile you have normally by using the audio_play_sound() function (https://docs.yoyogames.com/source/dadiospice/002_reference/game%20assets/sounds/audio_play_sound.html)

Related

Sequence number field with concurrent writes

Imagine a rail track, and my goal is to store every railcar that exists on that track. Each railcar has a position. Say there are 100 railcars on the track, so each railcar object would have a TrackPosition from 1-100.
That is essentially what we are doing right now, with a Track having child Railcars, and each Railcar has an integer TrackPosition.
When a new railcar is added, we simply take the # of cars in the track + 1 to save the position of the new car.
We are running into issues in a few different areas:
We would like to add cars concurrently using AWS Lambda. This presents a problem as two functions could hit the line of logic that calculates "total cars on track + 1" at the same time. When they go to save, both cars would have the same position. Locking that bit of code is not possible within AWS Lambda (as far as I can tell from what I've read). We've resolved this for the time being by setting the Lambdas to fire synchronously (concurrency set to 1), obviously not ideal for performance.
We would like to add a car into the middle of a track. This would involve taking any car with a greater position and incrementing them all. Not difficult to write some code to do this, but..
I'm wondering if I'm missing something fundamental within SQL that can achieve what I am after in a less error-prone way. The way I'm doing it seems naive. I've looked into Sequences, but I'm not sure if they would solve my concurrency issue.
Any insight would be greatly appreciated. We are using Entity Framework Core 2 with SQL Server.

Octaplanner example for Capicated Vehicle Routing with Time Window?

I am new to OctaPlanner.
I want to build a solution where I will nave number of locations to deliver items from one single location and also I want to use openmap distance data for calculating the distance.
Initially I used jsprit, but for more than 300 deliveries, it takes more than 8 minutes with 20 threads. Thats why I am trying to use Octa planner.
I want to map 1000 deliveries within 1 minute.
Does any one know any reference code or reference material which I can start using?
Thanks in advance :)
CVRPTW is a standard example, just open the examples app, vehicle routing and then import one of the belgium datasets with timewindows. The code is in the zip too.
To scale to 1k deliveries and especially beyond, you'll want to use "Nearby selection" (see reference manual), which isn't on by default but which makes a huge difference.

Converting Sum's Values into Base 10

I am making a computer purely out of water. It's going well, but I have one problem. In the adders, where the sum exits, I just have water collected there. I don't know how to take the base two sum values and convert them back into base 10 and display it... any help would be great.
Why are you using adders, do you mean AND gated.
No adders needed.

Calculating speed in Windows Phone

I am developing a Windows Phone 7 app and I want to see how fast the user is going.
Right now, I am storing the last 2 locations (and timestamps) that were recorded. I am finding the distance between the 2 locations by using the method suggested here. Then I am finding the difference in time (timestamp2 - timestamp1) and calculating the speed using the formula speed = (distance/time).
Am I using the right method or should I use the GeoCoordinate.Speed property?
I don't see why shouldn't you just use the GeoCoordinate.Speed property!
The GeoCoordinate class already gives you the speed and course (heading) of the movement, so why not just use it?

Knapsack algorithm for time

I am using VB.NET and I am trying to come up with some algorithm or some pseudo-code, or some VB.NET code that will let me do the following (hopefully I can explain this well):
I have 2 collection objects, Cob1 and Cob2. These collection objects store objects that implement an interface called ICob. ICob has 3 properties. A boolean IsSelected property, a property called Length, which returns a TimeSpan, and a Rating property, which is a short integer.
OK, now Cob1 has about 100 objects stored in the collection and Cob2 is an empty collection. What I want to do is select objects from Cob1 and copy them over to Cob2. I want the following rules obeyed when selecting the objects though:
I want to be able to specify a timespan and I want enough objects to be selected to fit into the timespan I specify (based on the Length property). So for example, if I pass a 10 minute timespan to my function, it should pick enough objects that fill the entire 10 minute window, or come as close to filling it as possible.
No objects should be selected twice.
Objects that have a higher rating (via the Rating property) should have a better chance at being picked then other objects.
No object that has been selected in the last 30 minutes should be selected again (so that each object will eventually get selected at least once), regardless of rating.
Can anyone give me some tips on how to achieve this? The tips can be in the form of mental processes, VB.NET example code, Pseudo-code or just about anything else that might help me.
Thanks
EDIT:
Maybe It would help to everyone if I revealed what I'm trying to do in real life.
I am writing software for a radio station that will automatically select the music and advertisments to play, kinda of like a computerized program manager.
The length represents the length of the sound byte (either a song or an advertisement) and the rating is just that. If the song is popular, it gets more airtime. If an advertiser pays more money, then it also gets more airtime.
So my program should pick songs that play for 20 minutes or so, then pick some advertisements to play for about 5 minutes or so.
Hopefully this helps a little.
Thanks for the input from everyone!
Alan
Note that:
The restriction 1 is from the classical knapsack problem, which works on sets, as requested by restriction 2.
Restriction 3 is rather vague. It is better to have higher value or higher coverage of the lifespan? If you don't specify a objective function to maximaze (or, to be precise, there are two: lifespan itself and rate), there are some pareto optimal solutions.
Restriction 4 is implementable by making a map object -> last time selected., in the form of black list.
Long story short: first I'd filter the set by blacklisting the object by restriction 4, and then apply a knapsack algorithm.
In order to implement 4., I believe you'll need to save the date/time when the Cob was last selected. Then, I'd do it in the following steps:
Filter out the ones that have not been selected within the last 30 minutes.
Sort by rating and set your "cursor" on the first item in the list.
Check the item's timespan. If short enough to fit in the specified time, select it. If not, goto 3 and proceed with the next item.
Check if your timespan has been filled. If yes, you are done. If no, goto 3 and proceed with the next item.