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.

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 ...
8
votes
1answer
874 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 ...
1
vote
1answer
190 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 + ...
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 ...
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 ...
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 ...
4
votes
2answers
150 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? ...
-2
votes
1answer
2k views

Airport Simulator [closed]

I tried this program in both Orwell DevC++ and Visual Studio 2013 (program works correctly). My astonishment is the performance of the same program in both IDEs. While the former took only 395 ...
7
votes
2answers
2k views

Three-number lottery simulator

Please let me know how I can make it better, especially with avoiding repetition without the need to replace the user guesses. ...
4
votes
3answers
105 views

Genetic Drift Simulator - Follow Up

This question is a follow-up of a previous question of mine: Genetic Drift Simulator. Following the advice given in the last question, and some more general improvements, the code has been slimmed ...
2
votes
2answers
436 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 ...
3
votes
2answers
443 views

Generating a PANDAS DataFrame of simulated coin tosses

It's taking my machine quite a long time to execute 1 billion (1st loop x 10, 2nd loop x 1000, 3rd loop x 100,000) instructions. Suggestions for performance enhancements? Sources of potential concern: ...
4
votes
2answers
3k views

Simulation of 2 dice rolls

I wrote a program that records how many times 2 fair dice need to be rolled to match the probabilities for each result that we should expect. I think it works but I'm wondering if there's a more ...
2
votes
1answer
150 views

Java “pulse” between threads

I have two threads. One runs a simulation and one runs a UI. In the UI, it is possible to trigger a "tick" of the simulation. There are a few constraints: Ticks run on the simulation thread Each ...
6
votes
1answer
2k views

Bean Machine Simulation

I could not find a solution from my book's website (student-level access) but I feel that I am missing something that I'm supposed to learn from this exercise. Instructions: Balls are dropped from ...
8
votes
3answers
7k views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
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 ...
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 ...
4
votes
2answers
146 views

2D physics game engine

I'm writing a 2D game engine, and I just wrote the physics for it to handle collisions between AABBs and circles. It's on GitHub. Some of my worries are that my code isn't OOP, because I have to do ...
0
votes
2answers
101 views

Get neighbour sides of a Rubics cube

I'm writing 2x2x2 rubics cube simulator. In my code I have a concept of Face which is individual side of the cube, and State which is agregate of all six sides. When I create new State, in addition to ...
6
votes
1answer
277 views

N-body sim with Barnes-Hut - Follow up

Link to previous question: Barnes-Hut N-body simulator It still has issues I'm sure. Node.h ...
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 ...
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 ...
2
votes
2answers
497 views

Computation of population patterns in simple agent-based model

I've modeled the population changes for a group of agents that inhabit a 2D lattice (with wrapped boundaries) made up of M x M number of grids. At each time step: ...
3
votes
1answer
91 views

C++ port of my Ruby narcotic solitaire simulator

Having undergone a little "rediscovery" of C++, I decided to port my Ruby narcotic solitaire simulator program to it. My goal here is efficiency. This program is already about 5 times faster than the ...
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 ...
7
votes
1answer
480 views

Ad hoc implementation of cruise control

I've written a small C program that has ad hoc implementation of cruise control for my Altera DE2 FPGA. It works alright but there are too many global variables. Preferably there should be no global ...
2
votes
1answer
1k views

Monte Carlo asset price simulation

I'm trying to write a simplistic Monte Carlo simulator to predict asset prices. For example, if something has an initial value of 50 and an historic daily standard deviation of 2, what are the odds it ...
4
votes
1answer
991 views

Modified Coupon Collector's Problem in Java

What is Coupon Collector's Problem? In probability theory, the coupon collector's problem describes the "collect all coupons and win" contests. It asks the following question: Suppose that there is ...
6
votes
2answers
216 views

Mini console based life simulation thing

I made this mini life simulation thing. I got the idea from the Eloquent JavaScript textbook, and just kinda ran with it. I've been programming for a little less than year and this is probably the ...
7
votes
2answers
1k views

5 Customers, but only 1 Bank Teller

Recently, as part of an interview, I was given a (seemingly) simple code prompt: To simulate a Bank with 5 customers and one teller, allowing them to deposit to and withdraw from their accounts, but ...
3
votes
1answer
84 views

Simulating a GUI windowing system - follow-up

The previous and initial iteration at Simulating a GUI windowing system I have essentially cleaned the code based on the only answer. Now I have: MyCanvas.java: ...
3
votes
1answer
610 views

Lattice lotka-volterra

Can anyone comment on the efficiency of my code? I am new with Python using NumPy/SciPy and I am trying to program a lattice biological model where a certain (one and only one) species (represented by ...
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 ...
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): ...
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. ...
7
votes
1answer
3k views

Particle class for physics simulation

This is a very lengthy class called Particle, it relies on two other headers, one of them is a simple struct which contains an x and y (...
6
votes
1answer
3k views

Memory Segmentation Simulation

I recently have been working on a project to simulate segmentation in memory. I wanted to create everything from scratch; not use pre-built data structures. I create a memory object that allows for "...
1
vote
0answers
1k views

DP algorithm to find minimum average wait for customer-serving system

Below is the code to find the minimum average waiting time for customers at a store. I want improve the time complexity of the code. As an overview of the logic, I start from ...
2
votes
1answer
105 views

Modeling and plotting neuron responses

I want to assign the row of a matrix the return value of a function, but the only way I can figure out how to do this is with a for-loop. I'm assuming this is bad ...
3
votes
1answer
273 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 ...
5
votes
1answer
96 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 ...
8
votes
1answer
208 views

Individuals reproduce and mutate

How can I improve the performance (in terms of computation time) of this code? ...
1
vote
1answer
563 views

Count the accumulated rainfall in a 2D mountain range

Challenge: Count how much rain will be collected in the valleys between the peaks of a mountain range in a 2D world. The mountain range is defined by a single array of positive ...
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. ...
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 ...
5
votes
2answers
129 views

Stochastic simulation event timing

So I'm learning bits and pieces of python. Here's some code that just doesn't seem pythonic, and I'd like to improve it. I'm doing stochastic simulations with a Gillespie style approach, but if that ...
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 ...
3
votes
2answers
337 views

Scoring system of a pool of dice

I want to do some Monte Carlo simulations on a system based on a pool of dice. For each trial, a number of dies are rolled, and the winner is the highest value, getting as many points as dice are over ...
3
votes
1answer
3k views

Simulation of bus route

Theme of my course work in institute is simulation of bus route. Could you determine any faults and defects in this code? I will be very grateful if you give me some advice about one global variable, ...