All Questions

Tagged with
Filter by
Sorted by
Tagged with
2
votes
0answers
54 views

How can I shorten the runtime of my simulation?

Before you read the code below, note the following explanation: I have three classes: Driver, Vehicle, and ...
3
votes
0answers
64 views

Monte Carlo Simulation of a Markov Process

A 1D binary string has the following dynamics $$1100 \to 1010,\quad 1101\to 1011$$ each with rate \$p<1\$. That is if we see \$110\$ in the string, then we change to \$101\$ with probability \$p\$....
10
votes
2answers
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 ...
3
votes
1answer
726 views

N-Body Gravitational Simulation of Point-Masses in Python

I made an n-body gravitational simulation in python. The algorithm does produce an approximate solution, which is shown at the bottom of the post. Additional methods to produce animations (among other ...
12
votes
1answer
2k 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 ...
1
vote
1answer
948 views

Bank account class

Simple object-oriented, money management code where a user can deposit money in, withdraw from, show, and exit the balance. ...
-1
votes
1answer
109 views

Champions League Simulation [closed]

Here is my first attempt at creating a full Champions League Simulation, including drawing the groups and subsequent games and playing all matches. The code is very, very long and I am sure there must ...
19
votes
6answers
5k 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 ...
3
votes
1answer
177 views

Simplified three-body simulation

The code below simulates a given Newtonian 3 body system. Each row per slice is supposed to represent a Cartesian component for the initial trajectory vector and for the distance vectors to the other ...
2
votes
1answer
106 views

Monty Hall problem in Python3

Some years ago I made a Monty Hall simulations in Java, and now I decided to give it a go in Python, after learning (yet another) the language at university. I decided to make a generalized, object-...
4
votes
1answer
167 views

Agent based model in Python

My model is based on the Ultimatum Game. I won't go into the intuition behind it but generally speaking it functions as follows: The game consists of a n × n lattice on which an agent is placed at ...
13
votes
1answer
287 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, ...
9
votes
1answer
173 views

Population dynamic simulation on biological information maintenance

Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, parasites can come to be due to mutation. They can drive the system ...
5
votes
2answers
165 views

Birthday paradox simulation

I'm writing a simulator which checks how many balls we need to occupy every box or how many balls we need for any box has at least 2 balls (birthday paradox). I wrote the script in python and it is so ...
2
votes
1answer
214 views

2-dimensional random walk simulator, draws the steps on a canvas

Here's what I came up with for a 2-dimensional random walk exercise. It takes a number of steps as input and iterates through them, while drawing every step as a line on the canvas. The direction is ...
1
vote
0answers
121 views

Blackjack simulator for Probability of a dealer bust for each starting card

I came up with this solution to another exercise out of John Zelle's Programming book. ...
2
votes
1answer
827 views

Craps Simulator Exercise

I did another exercise, this time it simulates n games of craps(dice game) and outputs the wins and win percentage! ...
1
vote
1answer
243 views

DM::OJ Slot Machines challenge in Python 3

I have written a solution to the Slot Machines challenge on DM::OJ: Martha takes a jar of quarters to the casino with the intention of becoming rich. She plays three machines in turn. Unknown to ...
1
vote
0answers
38 views

Moderate return-low risk vs high returns-high risk investments

To quantify Buffet's #1 rule of investing, "Don't lose money", I take the assumption that % returns of an investment follow a Normal distribution. Now a high return high risk investment might follow ...
5
votes
2answers
380 views

Chess Simulation

Part of the program I wrote simulates a Chess game choosing random moves for each player until it's a draw or win for either player. It takes 3 seconds to complete 1 simulation and since it trains ...
2
votes
2answers
60 views

The importance of consistency in percentage returns when investing

It is said that Being consistent in percentage annual returns leads to larger amount over time. That is for any given principal, getting 20% successively for 2 years is better than 30% for first ...
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 ...
0
votes
2answers
1k views

Blackjack strategy simulation

I'm very new to python (been coding for about two days) and have created a programme that simulates blackjack games so that I can work out optimal strategy over many iterations. The problem is that ...
7
votes
2answers
150 views

A game of automated tag

This game has 4 people moving randomly, one unit in one of the four directions (up, down, left, right), with a fifth person as a designated tagger. If this fifth person tags someone, the person is out....
1
vote
1answer
205 views

Rock Climbing Simulation Game

I am a rock climber so I made a rock climbing game. I have two conceptual objects; the climber and the route. I ended up putting them both into a single Climber ...
2
votes
1answer
338 views

Dice roll simulator (updated) created using Python 3.5 and PyQt5

...
7
votes
1answer
1k views

Python CS GO Case Simulator

I'm a beginner in Python, 1-2 months experience. Please assess my code. I used a dictionary to store cases. The cases_data is stored in another file. Is the structuring right? My code seems to have a ...
5
votes
0answers
610 views

Customizable Multi-Agent Predator/Prey Simulation

I am trying to create a highly customizable "battle simulator". The default setup is a predator/prey relationship (no births); however, I am trying to create code such that it's easy to add and ...
7
votes
1answer
804 views

Monty Hall simulation with any number of doors

After answering Monty hall python simulation I wondered what the outcome were to be if there were more than three doors, say four or seven. And so I decided to modify the problem slightly to adjust ...
8
votes
3answers
1k 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 ...
-4
votes
1answer
7k views

Python PID simulator controller output [closed]

I have written a piece of code (in Py3) that graphs out the controller value of PID controller. This is so that by changing the various sub controllers (P/I/D) I can visualise how the graph changes. I'...
5
votes
3answers
3k views

Python election challenge

Basically, there is an election on 3 regions where either candidate needs to win 2 in order to win the election. Idea is to simulate 10000 elections to see which candidate wins. I think my solution ...
2
votes
1answer
302 views

Monty Hall simulator in Python 3.x

I've been working on Python for the past few weeks trying to get my head around it's syntax/naming conventions/style/etc. I decided to make a monty hall sim to see how it looks in python. For those ...
9
votes
1answer
597 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 ...
9
votes
1answer
2k 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 ...
1
vote
1answer
59 views

Income Simulation programifier

http://pastebin.com/7UqD0gwF I'm looking for serious feedback on my first serious program. This is a program to calculate PvZ income over time of sunflowers and sunshrooms on nighttime pool levels. ...
8
votes
3answers
16k views

Slot Machine in Python

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