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
8 votes
1 answer
111 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 ...
user avatar
  • 398
5 votes
4 answers
381 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 ...
user avatar
  • 51
3 votes
1 answer
52 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 ...
user avatar
  • 135
10 votes
1 answer
829 views

High performance physics simulation - core class design

Below is some stripped down code from a physics simulation. The classes Vector2, Line and ...
user avatar
3 votes
1 answer
108 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 ...
user avatar
6 votes
1 answer
117 views

Plants vs. Zombies simulator

I am making a pvz simulator. We have a game board with 1 = peashooter and 2 = zombie: ...
user avatar
2 votes
1 answer
86 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 ...
user avatar
  • 27k
1 vote
1 answer
107 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 ...
user avatar
5 votes
1 answer
115 views

Monte-carlo simulation code - simple exercise

I created a quick monte-carlo simulation which seems to do what I want (simple version below). The code basically simulates a Poisson distribution, say this results in a simulation of ...
user avatar
  • 53
4 votes
1 answer
72 views

Path of a particle in a non-uniform B field

I have completed my project which simulates the path of a particle trapped in a device known as a magnetic mirror. I would like your thoughts and improvements on my implementation. Here is the code: <...
user avatar
  • 215
1 vote
1 answer
81 views

Quickly update, clone, and iterate ball simulation

What the program does: I have made a program that simulates a ball in an area made of triangles and many optimizations because it's for high-performance ball path simulation (technically ball path ...
user avatar
  • 207
5 votes
1 answer
89 views

The python code simulates an environment of a disease and calculates how many people get infected

The python code simulates an environment of an X number of persons with an Y number of places they can go to, puts the persons randomly in the places and calculates how many persons get infected, die ...
user avatar
  • 65
1 vote
0 answers
388 views

Solving the Knapsack Problem With a Genetic Algorithm Simulation in Python

I was watching Computerphile's video on using genetic algorithms to solve the Knapsack problem, and I decided to give it a whack. For anyone running the code, the ...
user avatar
2 votes
1 answer
51 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 ...
user avatar
  • 21
6 votes
4 answers
647 views

Monty Hall simulation - OOP

I mainly write code for data analysis so don't think about or use OOP at all on the day job. I thought I'd have a go at a simple Monty Hall simulation in an object-oriented style to figure out how it ...
user avatar
  • 163
4 votes
2 answers
94 views

Simulate transmission spectrum of extreme ultraviolet laser pulse through laser-dressed finite sample (Python Version)

I am currently participating in research on transient absorption spectroscopy and four wave mixing. In the experimental design, an extreme ultraviolet (XUV) laser pulse and infrared (IR) laser pulse ...
user avatar
3 votes
0 answers
28 views

MatLab: Plotting Output Electric Field Spectrum

Goal This code combines two matrices, diagonalizes that matrix, and finds the right and left eigenvectors, right and left eigenvectors are normalized with respect to each other, then it is multiplied ...
user avatar
  • 31
5 votes
1 answer
39 views

Simulate transmission spectrum of extreme ultraviolet laser pulse through laser-dressed finite sample (MATLAB version)

I am currently participating in research on transient absorption spectroscopy and four wave mixing. In the experimental design, an extreme ultraviolet (XUV) laser pulse and infrared (IR) laser pulse ...
user avatar
1 vote
1 answer
227 views

C# Coffee Machine

I saw this post and tried to do my attempt. This is the requirement of task: Design a coffee machine which makes different beverages based on set ingredients. The initialization of the recipes for ...
user avatar
  • 143
4 votes
1 answer
61 views

Finding number of possible arrangements of books on a shelf with a Monte-Carlo approach

The Problem I am trying to determine numerically how many possible ways a number of books can be arranged on a shelf. Specifically, there are x3 categories "physics", "sci-fi", and ...
user avatar
  • 141
4 votes
1 answer
120 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 ...
user avatar
  • 141
11 votes
1 answer
196 views

From Hummingbirds to Ornithopters: Simulating the Aerodynamics of Flapping Wings

Ptera Software A Flapping Wing Aerodynamics Simulator Written in Python Motivation About a year ago, I became fascinated by how animals fly. As an aerospace engineering student, it surprised me that ...
user avatar
3 votes
1 answer
128 views

Discrete event simulation framework for discrete times in Julia

I would like to receive constructive feedback on my simulation framework (this is for my thesis work). I have no formal background in programming, and I am wondering if there is a more effective and ...
user avatar
  • 31
2 votes
1 answer
57 views

Improving performance for social network simulation program

I'm an undergraduate student with little to no experience in formal computer science or coding, and I specialise in quantitative social science research. Our professor asked us to fabricate some ...
user avatar
1 vote
1 answer
41 views

Optimize narrow phase contact detection for phyiscs simulation code

I'm trying to optimize the narrow phase of the contact detection in my code. I'm using OpenMP for multithreading. That is the starting code: ...
user avatar
  • 111
3 votes
2 answers
75 views

A simple multithreaded openrct2 maze simulator

I found these two videos by Marcel Vos: (1) (2) that show how you can make hedge mazes that are very hard for the simple roller coaster tycoon 2 park guest AI to solve. Long story short, he eventually ...
user avatar
  • 33
5 votes
1 answer
770 views

Python - 2D Elastic Collision Simulation

I am currently a Python beginner, who just finished a script simulating collisions between circles (balls) in 2 dimensions. I would appreciate comments on overall structure, variable names and really ...
user avatar
  • 151
2 votes
0 answers
56 views

How can I shorten the runtime of my simulation?

Before you read the code below, note the following explanation: I have three classes: Driver, Vehicle, and ...
user avatar
3 votes
2 answers
91 views

Hex boardgame with fast random rollouts (OpenAI gym framework)

I implemented the boardgame Hex using the OpenAI gym framework with the aim of building a bot/AI player that can learn through self-play and expert iteration (details Note: not my paper; I am merely ...
user avatar
3 votes
0 answers
67 views

Monte Carlo Simulation of a Markov Process

A 1D binary string has the following dynamics $$1100 \to 1010,\quad 1101\to 1011$$ each with rate \$p<1\$. That is if we see \$110\$ in the string, then we change to \$101\$ with probability \$p\$....
user avatar
3 votes
1 answer
53 views

Ensure that column names in output retain original variable names, instead of using arbitrary X1, X2, etc

Is there a more elegant way to ensure that colnames(output) of a output R dataframe retains the original column variable names ...
user avatar
  • 61
10 votes
2 answers
1k views

Monty Hall implementation

To get a feel of Monty Hall problem, I've implemented Monty Hall simulator in Python, using only two strategies: never switch the door or always switch the door. Please review it with an eye towards ...
user avatar
2 votes
1 answer
110 views

Maxwell's distribution using Box-Muller transform

I am given the following problem to solve (This text is translated from Russian. So, there may be some translation issues): ... Another method to draw from the normal distribution is to draw two ...
user avatar
1 vote
0 answers
40 views

conditional simulation(path dependent simulation) in R

My codes are not good, I want to konw how to solve my problem efficicently and learn writing some elegant R codes.Thanks in advance! "r" is the starting value in ...
user avatar
6 votes
1 answer
95 views

Dangers of increasing fishing on a fish population simulation

Setup The following code implements the algorithm described in this and this paper. The first paper describes how the evolution of a fish population can be simulated, while the second paper introdues ...
user avatar
  • 384
1 vote
2 answers
89 views

Monte Carlo Simulation of "DNA Mutation" Game Mechanic

The game Space Station 13 (on the Paradise Station codebase) contains a DNA mechanic. Every carbon-based lifeform with DNA has 55 "blocks" that can be altered in a DNA Modifier, giving the mob ...
user avatar
  • 43
3 votes
1 answer
496 views

C++/SFML Boid/Flocking Simulation

I have created a flocking simulation based on Craig Reynolds Boids. Could you give me some feedback on my code? I am a newbie and would really appreciate some criticism. Files: Boid - this is the ...
user avatar
  • 151
5 votes
1 answer
221 views

Simulation of virus growth

The gist of my program is to simulate the growth of some virus. I used (attempted) OOP concepts to break down the problem into chunks and have the chunks talk to each other. Not sure if my ...
user avatar
3 votes
1 answer
127 views

Molecular dynamics simulation

I'm looking for some fresh ideas on how to optimize a couple of functions in my C++ code. I run the code through a profiler and it shows that they take 20% and 40% of the time respectively. The ...
user avatar
  • 33
1 vote
1 answer
38 views

Simulation of Central Limiting Theorem (CLT)

The following is the simulation of Central Limiting Theorem from Statistics: ...
user avatar
1 vote
1 answer
58 views

Statistical sampling from a vector

I have written a function/script to simulate data for sample size estimation. The following code samples from a vector of generated values with varying numbers of sample sizes and then concatenates ...
user avatar
  • 111
3 votes
1 answer
1k views

N-Body Gravitational Simulation of Point-Masses in Python

I made an n-body gravitational simulation in python. The algorithm does produce an approximate solution, which is shown at the bottom of the post. Additional methods to produce animations (among other ...
user avatar
5 votes
2 answers
279 views

A type of game simulation dropping disks

Quincunx is that little game where you drop a ball or disk down rows of nails in a pyramid formation until they land in a slot. This was a project for my class, but it's already been submitted. I am ...
user avatar
7 votes
1 answer
188 views

Generating Infinite Procedural Terrain Using Command-Line Graphics

Continuing my trend of (ab)using the Windows command-line interface to do fancy graphics-related things with my command-line-graphics library, CLIGL, I've created an infinite procedural terrain ...
user avatar
5 votes
1 answer
144 views

Gamblers ruin, parallel compute trials

Context The following script is a quick implementation of the gambler's ruin problem. For each given upper bound on the number of rounds in a game max_iter, ...
user avatar
1 vote
1 answer
80 views

Simulation to find the minimum number of patrollers to cover a wall

Problem description Scarpi, who owns a restaurant, decided to remodel it with his friends because the interior of the restaurant is too old. The place where the restaurant is located is a ...
user avatar
32 votes
9 answers
6k views

Simple n-body class in C++

As part of my training, I implemented a n-body class in C++ to simulate gravitational interaction of bodies and to get more familiar with features that C++ offers such as object oriented programming. ...
user avatar
  • 1,003
12 votes
1 answer
2k views

Predator-prey simulation

I made a random-walk predator-prey simulation that focuses on individual animals instead of the (maybe) more common array-based approach. I'd like to hear your opinion about this: how could the ...
user avatar
  • 405
3 votes
1 answer
209 views

Particle simulator using Python - Why is the NumPy version slower than pure Python?

This is an interesting example from G.Lanaro's book, Python High Performance. The program is a simple simulator which describes movement of particles based on their positions and angular velocities (<...
user avatar
  • 159
1 vote
1 answer
1k views

Bank account class

Simple object-oriented, money management code where a user can deposit money in, withdraw from, show, and exit the balance. ...
user avatar
  • 605

1
2 3 4 5
7