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
43 votes
5 answers
41k views

Designing a coffee machine

I was recently rejected from what looked like a really promising string of interviews. I did very well in a questionnaire style review, and then they handed me this assignment (more or less): ...
spacecadet's user avatar
11 votes
1 answer
219 views

MAC1 simulator/debugger

In constructing an answer to this question, I wrote a small debugger/simulator for the MAC-1 instruction set. There are a number of simulators already out there, but most are either too old to be ...
Edward's user avatar
  • 66.5k
11 votes
2 answers
2k views

Monte Carlo virus infection simulation

I am learning C++ from a C background, and I was wondering if I could convert this old C program I'd written into C++ as a personal exercise. The original C program is a simple Monte Carlo simulation ...
Alexis King's user avatar
  • 3,172
9 votes
1 answer
501 views

Multiplayer bowling in Ruby (follow-up: injection, single responsibility)

This is a multiplayer bowling simulator in Ruby. It allows for variable skill levels, and produces weighted random results for each player's rolls based on those skill settings. This is a complete ...
a2bfay's user avatar
  • 215
8 votes
1 answer
266 views

Simulating a GUI windowing system

I was eager to learn the implementation details behind windowing GUI systems. Because I am mostly a high level programmer having not much experience in low-level stuff, I had to simulate it instead of ...
coderodde's user avatar
  • 28.7k
7 votes
1 answer
346 views

Model simulation using Java annotations

A couple of days ago I posted my code that models systems made up of moving parts. I got several great tips and ideas and here is my latest version. My actions are now methods annotated with @Action (...
uros calakovic's user avatar
5 votes
1 answer
51 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 ...
Matt Bowman's user avatar
33 votes
9 answers
8k 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. ...
Gilfoyle's user avatar
  • 1,125
21 votes
2 answers
7k views

Barnes-Hut N-body simulator

I have written an n-body simulator, implementing the Barnes-Hut algorithm. Please comment on anything you can see wrong with this. Wikipedia Barnes-Hut page This is a screen shot of the simulation 20 ...
Kieren Pearson's user avatar
14 votes
3 answers
629 views

Suggestions needed after modification of Simulation of an Ocean

After suggestions given in this question, modifications to the code has been done. Only thing I could not do is to decide, where to place the starveTime property (...
overexchange's user avatar
  • 3,341
13 votes
1 answer
337 views

Population dynamic simulation on biological information maintenance 2

This question is the follow-up to this previous question. Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, ...
rokamama's user avatar
  • 325
11 votes
2 answers
3k views

Random D20 number generator

I'm teaching myself code using Zed Shaw's Learn Python The Hard Way, and I got bored during one of the memorization lessons so I thought I would make a random D20 number generator for when I play RPGS....
lerugray's user avatar
  • 605
9 votes
2 answers
6k views

Ant Colony Simulator

This program is a simulation of an ant colony, inspired by SimAnt. It doesn't do it off the batch; there must be code that instructs the ants to follow scent tiles in particular and react to the food. ...
wallabra's user avatar
  • 789
9 votes
1 answer
202 views

Population dynamic simulation on biological information maintenance

Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, parasites can come to be due to mutation. They can drive the system ...
rokamama's user avatar
  • 325
9 votes
3 answers
4k views

Simulation of an ocean containing sharks and fish

As part of my Java learning, I tried solving Part I of problem description here. The only issue that I see now is that I could not close the button of Frame. ...
overexchange's user avatar
  • 3,341
8 votes
1 answer
1k views

Discrete event simulation of a prioritized lunch queue

Note This post is a continuation of Discrete event simulation of a prioritized lunch queue in Java (Data structures). Please refer to it for problem description. This part about "algorithms": all ...
coderodde's user avatar
  • 28.7k
8 votes
2 answers
1k views

Epidemic simulation

The purpose of this code is to simulate epidemics across a population. There are 625 (pop) individuals at random locations. The epidemic parameters are infectious period (inf_period), trans (...
StatsSorceress's user avatar
6 votes
2 answers
402 views

Skill Upgrades for Strategy Game

I built a simple class to handle skill increases for the workers in a strategy game for iOS. The basic idea is that whenever a worker finishes a job, their skill (which starts at 0) will increase by ...
bazola's user avatar
  • 8,569
6 votes
1 answer
205 views

Randomizing and mutating algo class - functionality

See Randomizing and mutating algo class - style I'm looking for a review of the functionality of this code, answers to the above question which also describes the code use focus on style instead. ...
alan2here's user avatar
  • 289
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? ...
user3079275's user avatar
6 votes
1 answer
579 views

Schelling's model of Segregation Python implementation with Geopandas

If you don't know what is Schelling's model of segregation, you can read it here. The Schelling model of segregation is an agent-based model that illustrates how individual tendencies regarding ...
Kartikeya Sharma's user avatar
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 ...
a-rizzo's user avatar
  • 51
5 votes
1 answer
112 views

Vectorization for temperature simulation

I'm new to Matlab and I would like to know tips in order to reduce the processing time of such program. The scheme of the actual code is very similar to typical C++ code and I would like to vectorize ...
jaugas's user avatar
  • 59
5 votes
2 answers
318 views

Randomizing and mutating algo class - style

I've updated this question to be about code style only, as all of it's answered focused on this aspect. For the codes function, see Randomizing and mutating algo class - functionality ...
alan2here's user avatar
  • 289
5 votes
2 answers
165 views

Change random list of numbers into all 5's using simple evolution simulation

This is supposed to be an evolutionary algorithmic program, and I'm not sure if it does what it's supposed to do. It is supposed to take a random list of numbers (containing at least one 5), and over ...
FrigidDev's user avatar
  • 371
4 votes
2 answers
2k views

Generating stock prices using geometric brownian motion

I am writing a c++ class of "A simple least squares approach" by Longstaff and Schwartz. I have only finished writing a function for creating the stock price paths using geometric brownian motion. I ...
Wolfy's user avatar
  • 219
4 votes
2 answers
289 views

Follow up Implementation on Monty Hall Simulation

I have taken your inputs on my original question and formed a new implementation of the Monty Hall Simulation: Again keep an eye on CleanCode and OOP The Price to be won: ...
Martin Frank's user avatar
  • 2,838
4 votes
2 answers
253 views

Python object-oriented pipe cooling simulations

Here is my code simulating liquid in a pipe cooling under different conditions. How did I do approaching this in an object orientated way? Is there any way I can improve this code? ...
kilojoules's user avatar
4 votes
2 answers
422 views

Worker AI and Job Queue Management for Simulation Game

So I've been working on AI for a Tower Building simulation game for quite a few days, and I think the code would really benefit from review. I'm a hobbyist programmer, but I really care about doing ...
bazola's user avatar
  • 8,569
3 votes
0 answers
336 views

Animation of an incremental rotary encoder

While reworking my teaching materials for an exercise of an introductory course on mobile robotics, I recently created a animation/simulation of an incremental rotary encoder, e.g. often used for ...
AlexV's user avatar
  • 7,260
3 votes
1 answer
329 views

Ruby program to simulate a game of Narcotic Solitaire

In the game of Narcotic Solitaire, played with a standard 52-card deck, the player deals a row of four cards onto the table, from left to right. If all four cards are of the same value, they are ...
EMBLEM's user avatar
  • 267
3 votes
1 answer
559 views

Classic Hundred Doors Simulation

I am doing the 100 Doors problem as an exercise to practice user input and loops. I do understand the problem can be solved by outputting every square number up to the maximum number, but it defeats ...
Anthony Pham's user avatar
3 votes
2 answers
920 views

Simulating a random packet routing algorithm and printing packet statistics in Java

I have this short program for simulating a random packet routing algorithm: Packet.java ...
coderodde's user avatar
  • 28.7k
3 votes
2 answers
670 views

Simulating a system of moving points

This is an update of the code from my previous question. I'm simulating a system of particles which interact with each other and move and rotate due to the interaction. There are 2000 particles in ...
codder code's user avatar
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 ...
coderodde's user avatar
  • 28.7k
2 votes
2 answers
555 views

Genetic Drift simulator

Genetic drift — along with natural selection, mutation, and migration — is one of the basic mechanisms of evolution. In each generation, some individuals may, just by chance, leave behind a few ...
Quill's user avatar
  • 11.9k
1 vote
2 answers
494 views

Implement operation and simulation mode in an interface [closed]

Context: I have to create an interface between devices and a client. My package is composed of: Device.py Error.py DeviceA.py (for example) DeviceB.py ... Basically each ...
Katsu's user avatar
  • 181
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 ...
coderodde's user avatar
  • 28.7k
1 vote
2 answers
403 views

Simulation of interacting particles [closed]

I'm simulating a system of particles which interact with each other and move and rotate due to the interaction. There are 2000 particles in total but each particle interacts with other particles and ...
Oliver Range's user avatar
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. ...
user366312's user avatar
1 vote
1 answer
454 views

Discrete event simulation of a prioritized lunch queue in Java (Data structures)

(See also the Algorithms part.) Post details The program I am putting for being reviewed does not fit entirely in a single post, so I have to resort to the equation by Niklaus Wirth: Algorithms + ...
coderodde's user avatar
  • 28.7k