Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

37
votes
5answers
21k 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): ...
22
votes
4answers
5k 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 ...
22
votes
4answers
10k 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 ...
21
votes
5answers
1k 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 ...
19
votes
4answers
391 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 ...
17
votes
3answers
225 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 ...
17
votes
2answers
4k views

Barnes-Hut N-body simulator

I've 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 ...
16
votes
3answers
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 ...
15
votes
5answers
39k views

Basic Java dice game

...
14
votes
7answers
4k 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 ...
14
votes
3answers
569 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 (...
14
votes
3answers
3k 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 ...
13
votes
1answer
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) ...
12
votes
4answers
3k 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 ...
12
votes
6answers
14k 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 ...
12
votes
2answers
2k 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....
12
votes
2answers
333 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" ...
12
votes
2answers
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 ...
12
votes
2answers
307 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 ...
11
votes
4answers
3k 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 ...
11
votes
3answers
902 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. ...
11
votes
2answers
21k views

Dice-rolling simulator

I know there is a better way to store data. What is the most concise way to simplify this script? ...
11
votes
3answers
14k views

Enigma simulator performance

Here is my implementation of a simple 3 rotor Enigma machine in C++: ...
11
votes
2answers
837 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 ...
11
votes
3answers
429 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 ...
11
votes
1answer
1k 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 ...
10
votes
2answers
1k 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 ...
10
votes
4answers
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 ...
10
votes
2answers
1k 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. ...
10
votes
2answers
492 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 ...
10
votes
2answers
3k 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. ...
10
votes
1answer
914 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 ...
10
votes
1answer
121 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 ...
10
votes
0answers
661 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 ...
9
votes
3answers
3k 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. ...
9
votes
5answers
887 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 ...
9
votes
2answers
2k 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 ...
9
votes
2answers
3k 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. ...
9
votes
1answer
1k 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 ...
8
votes
4answers
6k views

Brute Force N Body Implementation in C++

I have wrote the following code in C++ for the n-body problem. This code is sequential as later on I am planning to parallelize it using OpenMP. I want to know whether I have wrote the correct ...
8
votes
3answers
2k views

Imitate randomness of a dice roll

I have written some code in Java that consists of two classes. I have tried my best and I want you to tell me if I can improve and how good this is. Also, how important is OOP? Java is an object ...
8
votes
4answers
1k views

Buffon's Needle experiment

I was working on a program that simulates the Buffon's Needle experiment. If anyone is not familiar with it, a Wiki link is provided - Buffons's Needle The point of Buffon's experiment is to find ...
8
votes
3answers
7k views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
8
votes
1answer
20k views

HTML / JS Slot Machine Simulator

This code is a slot machine simulator that uses elements of both HTML and JavaScript. Please pardon the lack of comments. ...
8
votes
2answers
235 views

Improvements/suggestions for my CPU emulator

I am trying to emulate a basic CPU (Z80) as close as possible. It currently does not read real assembly code, but that will be implemented. If you have any views on how that could be implemented, I'...
8
votes
3answers
572 views

OOP Critter Caretaker program from “Learning Python for the Absolute Beginner”

I'm currently learning programming and Python from Python Programming for the Absolute Beginner, Third Edition. I've been doing the challenges set out at the end of each chapter but I'm never sure if ...
8
votes
2answers
432 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 (...
8
votes
2answers
204 views

Hotel power management

A Hotel needs to reduce the overall power used by the equipments installed in its many floors. So the Hotel Management has installed sensors, like Motion Sensors, etc at appropriate places .I have to ...
8
votes
1answer
228 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 ...
8
votes
1answer
450 views

Monty Hall Optimization in Python 3.5

This is for homework but the deadline is over and I know the implementation is correct because it concurs with the math. At this point I just want to check my implementation for potential ...