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.

learn more… | top users | synonyms

4
votes
3answers
106 views

Hungry ant AI: any food here?

I'm working on a little AI to simulate ants (very basic). The full code can be found on Github. This function (in Ants.py) takes a list of Tuples containing ...
2
votes
0answers
37 views

PHP Lottery Simulator

I have a lottery simulator on my website that simulates you playing the lottery every week until your death and tells you how much you would have won or lost. It can take a custom number of balls and ...
3
votes
1answer
67 views

Sleeping barber problem in Erlang

I'm learning Erlang. It's my first time with a non-imperative programming language. I've written a code and I want some thoughts about it: Is my logic easy to understand? Is my code idiomatic? Is ...
2
votes
0answers
38 views

Visualizing Newton-Raphson method for finding zeroes of a function

I have created a program to visualize the working of Newton-Raphson method to find the zeroes of a function: newton.m: ...
1
vote
1answer
43 views

Particle in Cell: efficient data structure handling

I am building a simulation where you have 'Agents' distributed over a rather large landscape. Because the number of Agents is small, compared to the size of the landscape, I use the PIC approach where ...
2
votes
1answer
28 views

Distributed (asynchronous) averaging

This code simulates a distributed averaging protocol. There is a network of nodes, and at the clicks of a Poisson process: A random node wakes up Transmits it's current average to all the nodes it ...
5
votes
1answer
78 views

Circuit Simulator

I'm trying to learn Golang from Java, and to do this, I wrote a basic circuit simulator with only two circuits. Is there anything I can do better to make it more idiomatic? Simulator.go ...
2
votes
2answers
57 views

Random positioning and movement of a rabbit on a table

I was inspired by this: If you would put a rabbit randomly on a circular table with radius r= 1 meter and it moves 1 meter in a random direction, what is the chance it won't fall off? I ...
12
votes
2answers
392 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 ...
6
votes
2answers
142 views

Distributed system simulator

I have coded a very simple distributed system simulator in Python. It uses multiprocessing to assign tasks, and queues to communicate between processes. The code is shown below. ...
2
votes
2answers
61 views

Generating time series for generator ON or OFF

Want to create time series for the nuclear power plant performance using the equation for Time to fail and time to repair for 8736 hours in the year so that I have the time series in hours when the ...
4
votes
2answers
66 views

Functional translation of dice simulation

I have tried my hands at "functionalising" a toy problem I had: find the expected number of throws of a six sided die until all sides have been seen (the answer is 14.7) My starting point is my ...
5
votes
2answers
98 views

Attempting to run multiple simulations of the Gillespie algorithm for a set of stochastic chemical reactions in less than 10 minutes

I have written Python code that generates a plot. In the code below, when I set maxtime = 0.1, the program takes ~50s and when I set ...
6
votes
1answer
64 views

Approximating π via Monte Carlo simulation

Inspired by a tweet linked to me by a friend and a Haskell implementation by her for the same problem, I decided to try my hand at approximating the value of π using everything in the Haskell standard ...
11
votes
1answer
123 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 ...
1
vote
0answers
19 views

Spatial parametric scaling in agent-based model

I’m running a simple agent-based disease spread model on a 2D lattice, where disease transmission in a population depends on each individual’s chance of avoiding infection at every time step, which ...
7
votes
2answers
66 views

Quite-Off-The-Bat Complex Console Ant Colony Simulator w/ Partial AI

As a follow-up of my previous non-off-the-bat Ant Colony Simulator, we have this one that works off-the-bat... quite; the code for when the ants find and take the food isn't really done but it would ...
8
votes
2answers
1k 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. ...
2
votes
1answer
54 views

Velocity verlet implementation

My code is meant to update the positions and velocities of planets. There are a few methods in this class, but updatePosition and ...
6
votes
0answers
109 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 ...
5
votes
1answer
78 views

War Card Game Simulator

This is the second thing I've ever written in Python. I am just looking for what I could improve upon along with things that could be done better. It is as compact as I could make it with my current ...
10
votes
1answer
83 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 ...
12
votes
2answers
242 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 ...
8
votes
1answer
110 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
51 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 + ...
8
votes
2answers
313 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
341 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 ...
14
votes
4answers
245 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
57 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? ...
-1
votes
1answer
294 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
385 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
85 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
294 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 ...
2
votes
2answers
86 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
514 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
61 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 ...
5
votes
1answer
374 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 ...
7
votes
3answers
667 views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
8
votes
1answer
103 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
214 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
69 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
68 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
103 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 ...
15
votes
2answers
1k 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 ...
10
votes
2answers
419 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
120 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
76 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
2k 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 ...
6
votes
1answer
133 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 ...
1
vote
1answer
204 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 ...