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
40k 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
33 votes
9 answers
7k 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
24 votes
4 answers
11k views

Simple Turing machine simulator

Yesterday I got a sudden urge to go from writing Python to something, well, more UNIX core-ish. I read some examples on here and decided I might as well put some of that stuff to use to test something ...
A.J.Rouvoet's user avatar
23 votes
5 answers
2k views

Benchmarks of various scientific programming languages for theoretical modelling

For a theoretical modelling course for biology students, I am trying to decide which would be the best technical programming language for doing evolutionary simulations in terms of elegance and ...
Tom Wenseleers's user avatar
22 votes
4 answers
7k views

C++ Coin flip simulator and data collector

Asks the user for the chance of a coin landing on heads, the number of trials per experiment, and the number of experiments. For example, given 5 trials per experiment and 20 experiments, the program ...
Daniel's user avatar
  • 323
21 votes
2 answers
6k 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
19 votes
6 answers
6k views

Premier League simulation

I've created a simulator for the Premier League, which takes in all of the 20 teams and plays them against each other, recording the results and outputting a table at the end. The skill levels are ...
woody101298's user avatar
19 votes
4 answers
468 views

Ising Model - Atom Vibration Simulation in Scala

I am an experienced Java developer (12+ years) and have recently switched to Scala and I love it. However I feel not comfy yet and I have a feeling that I might use to many paradigms from the good old ...
Julian Pieles's user avatar
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" ...
Shirish Kulhari's user avatar
18 votes
1 answer
1k views

Fluid Simulation with SDL

I have always wanted to write a fluid simulation, and with the help of a paper and some StackOverflow users I've got something that works. My goal is to have a program that someone can run right away ...
qwr's user avatar
  • 1,016
17 votes
5 answers
50k views

Basic Java dice game

...
user3026468's user avatar
17 votes
3 answers
277 views

"Do I understand the gravity of the situation?"

What is this? This is a two-dimensional physics simulator that models gravity and collisions between circular objects (though it doesn't model rotation). How do you use it? You can tweak the following ...
Thriggle's user avatar
  • 1,308
16 votes
3 answers
2k views

Newton-Pepys, common birthdays and other probability simulations in Python 3

I have been learning Probability from Statistics 110 and trying to simulate problems that have an unintuitive answer ...
kamalbanga's user avatar
16 votes
3 answers
1k views

Razzle Dazzle simulator

Inspired by the video from Scam Nation and James Grime from Numberphile, I tried to make a Razzle Dazzle simulator. Razzle Dazzle is a scam in the form of a game. Per turn, the player pays a fee and ...
user2966394's user avatar
15 votes
3 answers
5k views

Orbital Trajectory simulator

I have written a simple program to do trajectory simulation in the Earth-Moon system, it still has a long way to go I am working on making it more class oriented and am looking into implementing a ...
Mark Omo's user avatar
  • 449
14 votes
7 answers
5k views

Monty Hall Paradox in Java

I was wondering if this code looks neat, and if I should change anything. I was planning to implement Frames (or JFrame) tomorrow on it. Would it be a good idea to ...
mazunki's user avatar
  • 263
14 votes
3 answers
628 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,321
13 votes
4 answers
4k views

Simulating a printer

I'm trying to recreate a printer in Java. I'm fairly new to programming so I'm using huge if/else blocks inside a single ...
PacketSniffer's user avatar
13 votes
3 answers
17k views

Enigma simulator performance

Here is my implementation of a simple 3 rotor Enigma machine in C++: ...
StuR's user avatar
  • 245
13 votes
1 answer
1k views

Haskell Particle Simulation

I recently started learning Haskell and as my first project I decided to port a particle simulation I had written in C. The simulation is pretty simple. We have a cubic box with particles (spheres) ...
Grieverheart's user avatar
13 votes
1 answer
326 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
12 votes
6 answers
19k views

Write a program that simulates a lottery

I am taking a C++ course and we have received our final assignment, I was looking for some suggestions and or tips so I can continue to improve. I am aware that the use of ...
Brendon's user avatar
  • 305
12 votes
2 answers
1k views

Gravitational Brute Force N-body Algorithm

I've just started dabbling with code, and as a learning exercise I've written a simple algorithm for solving gravitational n-body problems numerically in JavaScript. I would be very grateful for ...
Happy Koala's user avatar
12 votes
2 answers
335 views

How Long Will Your Smartphone Distract You From Family Dinner?

I wrote a program to simulate this week's 538 Riddler, reproduced below: You’ve just finished unwrapping your holiday presents. You and your sister got brand-new smartphones, opening them at the ...
User1000547's user avatar
12 votes
1 answer
4k 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 ...
Neinstein's user avatar
  • 405
12 votes
1 answer
1k views

Poker probabilities finder

This code finds the probabilities of the various scores in Poker. It uses a Monte Carlo approach, in which, two million (\$2 \times 10^{6}\$) hands are simulated and evaluated, not an exhaustive ...
Caridorc's user avatar
  • 27.4k
11 votes
4 answers
4k views

Doodlebug vs. ant population simulation

I am looking for a review on one of my homework assignments for this semester. This homework has already been submitted and graded and my final has already been submitted so there is no cheating or ...
StormsEdge's user avatar
11 votes
3 answers
1k views

Souped-up random walk terrain generator

I started learning Python a couple of weeks ago, and to test my new knowledge of Python, I decided to use Pygame to code a random walk terrain generator. ...
Ethan Bierlein's user avatar
11 votes
2 answers
22k views

Dice-rolling simulator

I know there is a better way to store data. What is the most concise way to simplify this script? ...
PythonBeginner's user avatar
11 votes
5 answers
1k views

Probabilistic matchmaking simulation

The following is a problem I found on this wiki. What can I do to optimize my algorithm, and make this code more C++11? Write a program to discover the answer to this puzzle:"Let's say men and ...
Quaxton Hale's user avatar
  • 2,629
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
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. ...
Equilibrium's user avatar
11 votes
3 answers
502 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 ...
hexaquark's user avatar
  • 213
11 votes
2 answers
1k views

Espresso Queue simulation

I was asked to do a technical test with the following specification, but my solution was rejected and I was not selected for the available position (Junior to "normal" level, with 4 days of time to ...
Juha Untinen's user avatar
11 votes
3 answers
3k views

Coding exercise to simulate animal population

(This is all available in a github repo if that's easier: https://github.com/paulnicholsen27/SpeciesSimulator) I am submitting this as a code sample for a possible job, so I'm just looking for any ...
thumbtackthief's user avatar
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
11 votes
1 answer
2k views

Lotto simulator

With the recent craziness of the Powerball in the US, I got interested in building a little lotto simulator to see how frequently I could win with purchasing large amounts of tickets. For those not ...
Jared Mackey's user avatar
11 votes
1 answer
214 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
  • 65.3k
10 votes
5 answers
3k views

Ising model simulation

I have written this code to simulate Ising Model at one particular temperature in presence of magnetic field to observe hysteresis effect using the metropolis algorithm. While the code runs and gave ...
aargiee's user avatar
  • 101
10 votes
2 answers
2k views

WaTor Code in Java

I just coded a version of WaTor, a population simulation game in which fish and sharks move around, breed, and eat each other. I am wondering how I did and if there are better ways to do some of the ...
Jared's user avatar
  • 721
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 ...
LetMeSOThat4U's user avatar
10 votes
2 answers
5k views

Solar System model

I have a model that works, as far as I know, but it's so messy! I am very new to Java, so I'd really appreciate some help tidying up. In particular, a lot of my constructors are empty which is ...
user13948's user avatar
  • 225
10 votes
4 answers
1k views

Make a Deal program - using sets in Python

Mostly because I didn't believe the outcome of the classic game play Make-a-Deal (see https://math.stackexchange.com/questions/608957/monty-hall-problem-extended) I made this little program... and ...
Bruno Vermeulen's user avatar
10 votes
2 answers
1k views

Powerball Lottery Simulator in C

I made a Powerball lottery simulator in C. I chose C because it is fast. Here's how it plays: The user plays one ticket every day. The user can choose to play the same ticket every day or a ...
user91656's user avatar
  • 383
10 votes
1 answer
903 views

High performance physics simulation - core class design

Below is some stripped down code from a physics simulation. The classes Vector2, Line and ...
Oliver Schönrock's user avatar
10 votes
2 answers
4k views

Predator Prey Simulation

Below is a simple random walk predator prey simulation that is optimized to the best of my abilities. I would love to hear about any improvements that can made. ...
Paul's user avatar
  • 475
10 votes
1 answer
300 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 ...
wingedNorthropi's user avatar
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,321
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
  • 779
9 votes
1 answer
3k views

ALOHA network simulation in Python

I'm currently studying the book From Algorithms to Z-Scores: Probabilistic and Statistical Modelling in Computer Science In the first chapter of the book the ALOHA network protocol is introduced as ...
Sorrop's user avatar
  • 297

1
2 3 4 5
8