Skip to main content

Questions tagged [simulation]

Simulation is the imitation of some real thing, state of affairs, or process. The act of simulating something generally entails representing certain key characteristics or behaviours of a selected physical or abstract system.

Filter by
Sorted by
Tagged with
3 votes
5 answers
1k views

How do I speed up this simulation program

This is a program to solve a differential equation numerically using Euler method. As of now, it is very slow, and I need to run 10000 Monte Carlo simulations. The differential equation is called ...
8 votes
1 answer
3k views

Simulate round-robin tournament draw

I decided to implement the round robin algorithm in Python. My code takes a list of teams as input and prints the schedule. This is my first try to write something by my own after taking some online ...
3 votes
1 answer
57 views

how to launch multiple processes efficiently

I have a list of car models which I want to simulate by launching multiple instances of an external simulator executable. My application stores the current status of all the cars that are being ...
1 vote
1 answer
143 views

Dial up some obscure stats for the Chutes and Ladders game

Years ago, I wrote some code in Perl for the Chutes and Ladders game. I re-wrote the code here in Python. The code simulates one player in a game to see how many spins of the dial are needed to win ...
2 votes
3 answers
163 views

Friendly probability puzzle solved with simulation

A friend posed to me a question to see if I could solve it. He says I solved it appropriately. I was hoping someone here could give me a review of the program I wrote to answer it. I figured it would ...
5 votes
1 answer
430 views

Blackjack simulator for probability of a dealer bust for each starting card

I came up with this solution to an exercise out of John Zelle's Python Programming book. ...
5 votes
1 answer
196 views

Fast Hardy-Weinberg equilibrium simulation

I was very bored over one of my breaks this year, so I built a Hardy-Weinberg equilibrium simulator for two unrelated alleles of the same gene. Hardy-Weinberg equilibrium is when there is no evolution,...
3 votes
1 answer
61 views

Simulating a Moving Average Process

I was studying stochastic processes and thought to independently simulate a moving average process. ...
4 votes
1 answer
261 views

Python Genetic Algorithm Implementation

I've made this to pick the LQR parameters for my self balancing robots simulation. So to break down what I have done, Randomly Create Population I create a random population. The population is a list ...
4 votes
2 answers
484 views

Spatial radius search in Boid simulation

I am working on a Boid simulation with 10,000 boids. I've successfully utilized geometry shaders and an array<GLfloat[3], MAX_BOIDS> for vertices to enhance ...
0 votes
1 answer
75 views

Temperature of a Lennard-Jones system

Are the formulas used in getTemperature() and setTemperature() correct? ...
2 votes
1 answer
88 views

Agent based Dengue transmission simulation

I'm trying to implement the dynamics of Dengue transmission between mosquitoes and humans. I decided create two classes, one for the human population and another for the mosquitoes. Both are based on ...
1 vote
2 answers
161 views

Minimalistic implementation of Leapfrog integration algorithm (2)

Please review this C++ listing of an implementation of Leapfrog integration. This C++ listing is rewritten according to this review. ...
1 vote
1 answer
64 views

Counting number of time frames in a simulation trajectory file

I have written a function in c++, which accepts an "ifstream" object (file) to read from and a string to match a header token in the file. This way I am counting how many times a token ...
3 votes
1 answer
92 views

Simulating disease spread in a population

I am trying to build a model that allows me to estimate the spread of disease in the population. The setup is similar to the SIR model, with the difference that this model includes the stochastic ...
1 vote
1 answer
64 views

Flowers in the Window: An Exercise in Using Classes and Objects in Rust

The Problem As part of my doomed efforts to learn Rust, I decided to get to grips with how the language handles classes and objects. But, instead of taking on some well-known exercise, I thought it ...
1 vote
1 answer
67 views

Molecular Simulation: PBC using the Ewald Summation technique

The following is a Rust implementation of polymer simulation where the PBC(periodic boundary condition) has been implemented using the Ewald Summation technique. Can you review the code? Is the PBC ...
6 votes
2 answers
868 views

Molecular simulation: Minimum Image Convention

Can you review the following code to check to see if the Minimum Image Convention is properly implemented? ...
2 votes
1 answer
148 views

plotting Monte Carlo Simulation from excel sheet

I have created the following code: Option Explicit ...
0 votes
1 answer
248 views

Python Logic Gate Circuit Simulator [closed]

I have recently become interested in simulating logic circuits because of a electronics class at school. I have created a functioning simulator for logic gate circuits in Python. My implementation ...
6 votes
2 answers
482 views

Means square displacement (MSD)

I have written a code to calculate the MSD of some molecules. The code averages over multiple time origins (sliding time window) and over all the molecules. I have also made it do one extra thing: do ...
9 votes
2 answers
293 views

Simulating surname convergence in a population

I was curious a few weeks ago about how surnames come and go (mostly on the go). I wanted to know how quickly surnames die out, because (in my simplified simulation world) once the last person with a ...
2 votes
1 answer
161 views

Simulation of a real capacitor to calculate its capacitance

The goal is to simulate a real flat plate capacitor in 2D. The potential of the armature is fixed to +V and -V, on the edges of the simulation cell the potential is zero. Between the plates of the ...
2 votes
1 answer
84 views

Smoothed Particle Hydrodynamics in Rust

So I'm simultaneously learning both Rust and Smoothed Particle Hydrodynamics. I've been using this video from AMD as a reference and the provided smoothing kernels. At this stage, I've not optimised ...
18 votes
3 answers
4k views

Simulating a two-body collision problem to find digits of Pi

I came across a nice video on 3Blue1Brown's channel that highlights a very indirect way to find the digits in Pi. I'd suggest watching the whole video, but briefly: The setup is as above. A "small" ...
11 votes
2 answers
5k views

C++ Beginner Bunny Exercise

I recently completed (somewhat) an exercise I found on a C++ forum. The exercise is found at the end of the list of exercises and is called "Graduation" and is about bunnies in a linked list. ...
1 vote
1 answer
195 views

Simulating a toilet seat usage in Java - follow-up

(See the previous iteration.) This time, I removed the stuff I don't need in my demo runner. Also, I consolidated some code that seemed DRY to me. Simulation rules When a female arrives, she ensures ...
2 votes
2 answers
125 views

Simulating a toilet seat usage in Java

(See also the next iteration.) I have this small simulation program simulating a toilet seat. The toilet seat may be in two positions: up or down. If a male arrives to the toilet to urinate, and ...
3 votes
1 answer
71 views

I made a webpage that simulates sharks eating fish in the torrid world of Wa-tor

I've been self-studying HTML/CSS/JS. I read about Wa-tor. It's a population dynamics simulation which simulates fish and sharks breeding and predating. This seemed cool so I decided to implement it....
4 votes
2 answers
1k views

Traffic simulation GUI: an exercise in concurrent programming using threads

To avoid a code dump I have removed most of the code and left the first few lines of constructors and methods and anything relevant. Full code at the bottom. The purpose of this code is to use threads ...
11 votes
3 answers
516 views

Membrane protein diffusion in different confinement models

I am a junior Software Engineer, C++ is usually my main jam but I started picking up Python for a research project I am doing in college. I am eager to learn as much Python syntax, tricks, best ...
2 votes
1 answer
360 views

Simulation of sand particle collision

I am making a module that allows you to create sand and simulate it. I have successfully done this, but it runs very slowly. I need this to be able to simulate at least 1000 particles, at a fps higher ...
2 votes
1 answer
77 views

Estimate an average duration of every game state in a football match given implied goals for home and away teams

What my program does I'm trying to estimate for how many minutes in average a football(soccer) match will be in different game states depending on implied goals of both teams. Problem domain For our ...
7 votes
2 answers
592 views

Dice league, putting players against each other

I've got this code: ...
3 votes
0 answers
80 views

Finds a moving target within a given space

https://youtu.be/XEt09iK8IXs?t=1264 Ben Awad did a mock interview with a React developer, and asked this question. There are a set of 100 holes (0-99). A rabbit is located in one of these holes. Every ...
6 votes
4 answers
1k views

Monty hall python simulation

I have the following code that simulates the monty hall problem (see google for more details). I used sets to do it but is there a more intuitive or efficient way to do it? ...
1 vote
4 answers
333 views

Given the arrival times of people at a door, resolve their passage times

I was trying to solve the following question: You are given 2 arrays: one representing the time people arrive at a door and other representing the direction they want to go (in or out) You have to ...
2 votes
1 answer
547 views

Electronic circuit logic gates simulator

I've seen a lot of C++ simulators implementing logic gates, but absolutely all of them use the wrapped bitwise operations of the programming language itself. I have tried to omit the use of a bitwise ...
8 votes
2 answers
245 views

Frozen yogurt shop simulator

I made this project that simulates a frozen yogurt shop, where you can pick your flavor, toppings, and sauces and then pay for it. I'm a beginner at python and this is my first project. I don't even ...
2 votes
1 answer
270 views

Heston model implementation in C++

I have implemented an option pricing algorithm following the Heston model. The simulation involves specifying the number of simulations, then generating a discretized path for each simulation (code ...
3 votes
2 answers
2k views

Betting strategy simulation

I lately got interested into betting systems, dice strategies and algorithms. I took some time to think about it and eventually ended up with an algorithm of my own. Considering that I don't have ...
8 votes
1 answer
860 views

Python implementation of a Galton board simulation

I watched a YouTube show the other day in which a variant of a Galton board is used to make a random selection from a range of movies that will be reviewed in that show. In contrast to a standard ...
1 vote
2 answers
2k views

Blackjack strategy simulation

I'm very new to python (been coding for about two days) and have created a programme that simulates blackjack games so that I can work out optimal strategy over many iterations. The problem is that ...
5 votes
4 answers
3k views

Coin flip streaks in Python

Below is the wording from the problem in Automate the Boring Stuff book. The bold text leads me to believe that I should be checking for a streak and not multiple streaks within each experiment of 100 ...
3 votes
1 answer
258 views

Percolation threshold simulation using C++

I am studying Algorithms by Princeton University. The first week assignment is to simulate percolation by using Java. https://coursera.cs.princeton.edu/algs4/assignments/percolation/specification.php ...
10 votes
1 answer
921 views

High performance physics simulation - core class design

Below is some stripped down code from a physics simulation. The classes Vector2, Line and ...
3 votes
1 answer
502 views

Barnes-Hut \$n\$-body simulation (3D) in C++

I have implemented the Barnes-Hut algorithm for \$n\$-body-simulations (in this case "sort-of" 3D-gravity - see below). I'd appreciate any comments for improving my code (especially ...
6 votes
1 answer
781 views

Plants vs. Zombies simulator

I am making a pvz simulator. We have a game board with 1 = peashooter and 2 = zombie: ...
2 votes
1 answer
425 views

Robotic swarm simulation: aggregation

This program simulates the phenomenon of aggregation of a swarm of robots with no cooperation between each other and each robot following a very simple rule: The velocity of this robot has a random ...
1 vote
1 answer
292 views

Conway's Game of Life in C++ with a Board Struct

I made the game of Life in C++ for a highschool class project. The website we're using doesn't have an autograder for C++, and my programming teacher doesn't really know how to program... so I'd love ...

1
2 3 4 5
8