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

6
votes
3answers
92 views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
7
votes
1answer
58 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
116 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
45 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
51 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
45 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 ...
14
votes
2answers
128 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
302 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
84 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
59 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
1k 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
76 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
54 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
68 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 ...
6
votes
2answers
80 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
213 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
45 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: ...
2
votes
1answer
114 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 ...
13
votes
7answers
1k 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 ...
27
votes
5answers
4k 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): ...
8
votes
2answers
310 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. ...
6
votes
1answer
157 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
142 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
220 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
42 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 ...
2
votes
1answer
87 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 ...
4
votes
1answer
68 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 ...
9
votes
1answer
186 views

Individuals reproduce and mutate

How can I improve the performance (in terms of computation time) of this code? ...
1
vote
1answer
96 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 ...
10
votes
3answers
494 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
102 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
63 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 ...
11
votes
6answers
2k 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
69 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
196 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, ...
3
votes
2answers
98 views

Multifunctional Monty Hall Simulator

Based on this question on math.SE regarding probabilities in variations on the Monty Hall problem, I cobbled up a simulator in Ruby to give myself an introduction to the language. Since this is my ...
7
votes
1answer
329 views

Simulations and game code

I will like to improve my code in Java involving creating simulations and games. This is a problem-solving code so far in interest and percentage calculations. ...
0
votes
2answers
90 views

Monte Carlo dice [closed]

For this lab you should re-use your Dice class from the previous week. The user inputs a number n which determines the number of groups of 6 dice to be rolled. The program should output x, ...
2
votes
1answer
201 views

Simulation Framework

I started creating a small abstract simulation framework and would be happy if someone could take a look at the code and give me feedback on it. The code can be found here, and it is currently not in ...
4
votes
1answer
396 views

Vehicle-crossing simulation

It seems like this code should be shorter, but with all the error checking it is long and hard to follow. This is for a simulation of vehicles crossing a bridge, and this part is dealing with mutexes. ...
7
votes
1answer
131 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 ...
8
votes
5answers
616 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 ...
11
votes
2answers
265 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 ...
6
votes
2answers
131 views

Summator simulation

This is a reference implementation of a summation unit. The algorithm used is a most straightforward carry-propagation. If necessary, a test driving code could be provided. Few notes for the ...
4
votes
1answer
95 views

Simulating the martingale betting system with roulette

I wrote a program that simulates many instances of trying the martingale betting system with roulette in Haskell. At the answerer's suggestion I opted to leave the ...
2
votes
2answers
115 views

90 year data simulation in need of performance increase

I developed some code for my masters project that will simulate 90 years daily data using 1000 different data sets. The code is working fine and gives the correct output that I wanted but the ...
7
votes
1answer
523 views

Algorithm simulator (bubble and selection sorts)

I am concerned where it can be improved. Main concerns are coding style. Any other improvements are welcome too. Priority is on JavaScript, review for HTML/CSS are welcome too. What it does: ...
3
votes
1answer
62 views

Revised worker movement AI for strategy game

A while ago I posted this question about worker AI and Job Queues for a strategy game. I have posted other questions about the Job Queue, and now I would like to post this revised question about ...
5
votes
2answers
288 views

Can I make this simulation written in C more “C++-y”?

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 ...
6
votes
2answers
204 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 ...