simulation

How the dynamics of a sports simulation game works?

萝らか妹 提交于 2019-12-04 08:42:21
问题 I would like to create a baseball simulation game. Are these sports management games based on luck? A management game entirely based on luck is not fair, but it cannot be too predictable either. How does the logic behind these games work? 回答1: As you have already figured out, the core component of such games is the match simulation engine. As Spence said so, you want that simulation to "look right" rather than to "be right". I worked on a rugby game simulation some time ago and there's an

Controlling memory allocation/GC in a simulation?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 08:16:20
I'm having a bit of trouble figuring out how to reduce memory usage and GC time in a simulation running in the State monad. Presently I have to run the compiled code with +RTS -K100M to avoid stack space overflow, and the GC stats are pretty hideous (see below). Here are relevant snippets of the code. Complete, working (GHC 7.4.1) code can be found at http://hpaste.org/68527 . -- Lone algebraic data type holding the simulation configuration. data SimConfig = SimConfig { numDimensions :: !Int -- strict , numWalkers :: !Int -- strict , simArray :: IntMap [Double] -- strict spine , logP :: Seq

Calculating the mean of every replication

a 夏天 提交于 2019-12-04 07:13:23
问题 I have the following code set.seed(30) nsim <- 50 ## NUMBER OF REPLICATIONS demand <- c(12,13,24,12,13,12,14,10,11,10) res <- replicate(nsim, { load <- runif(10,11,14) diff <- load - demand ## DIFFERENCE BETWEEN DEMAND AND LOAD return(sum(diff < 0)) }) res [1] 6 5 7 4 4 5 4 3 6 4 5 5 5 4 2 5 3 3 3 5 3 2 4 6 5 4 4 3 5 6 4 4 3 6 5 3 5 5 4 3 3 [42] 6 4 4 4 6 6 5 4 5 I have a huge data set and the question is what is the fastest way of calculating the mean for every replication. For example the

Recording data in a long running python simulation

隐身守侯 提交于 2019-12-04 05:35:52
问题 I am running a simulation from which I need to record some small numpy arrays every cycle. My current solution is to load, write then save as follows: existing_data = np.load("existing_record.npy") updated = np.dstack((existing_data,new_array[...,None])) np.save("existing_record.npy",updated) This has created a big performance bottleneck and the simulation runs at half the speed with this method. I have considered appending the numpy arrays to a list and writing it at the end of the

Flocking boids behaviour problem

拟墨画扇 提交于 2019-12-04 04:41:37
Yesterday I came across Craig Reynolds' Boids , and subsequently figured that I'd give implementing a simple 2D version in Java a go. I've put together a fairly basic setup based closely on Conrad Parker's notes . However, I'm getting some rather bizarre (in my opinion) behaviour. Currently, my boids move reasonably quickly into a rough grid or lattice, and proceed to twitch on the spot. By that I mean they move around a little and rotate very frequently. Currently, I have implemented: Alignment Cohesion Separation Velocity limiting Initially, my boids are randomly distributed across the

simulating key press event using SendInput with C#

末鹿安然 提交于 2019-12-04 04:28:50
问题 Following the advice from this thread: distinguish between keyboard's Real and Virtual key presses I'm trying to create a program, that will send keyboard's key-press events using SendInput() method. However, the problem is that when I try to simulate a key press event - nothing happens whatsoever. So far that's my code: [DllImport("user32.dll")] static extern UInt32 SendInput(UInt32 nInputs, [MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] INPUT[] pInputs, Int32 cbSize); [StructLayout

Improving a numpy implementation of a simple spring network

倾然丶 夕夏残阳落幕 提交于 2019-12-03 21:55:29
I wanted a very simple spring system written in numpy. The system would be defined as a simple network of knots , linked by links . I'm not interested in evaluating the system over time, but instead I want to go from an initial state, change a variable (usually move a knot to a new position) and solve the system until it reaches a stable state (last applied force is below a given threshold). The knots have no mass, there's no gravity, the forces are all derived from each link's current lengths/init lengths. And the only "special" variable is that each knot can bet set as "anchored" (doesn't

Simulating a key press event in Python 2.7

做~自己de王妃 提交于 2019-12-03 18:43:51
问题 What I want to do is to press any keyboard key from the Python script level on Windows. I have tried SendKeys but it works only on python 2.6. Other methods that I have tried including import win32com.client win32com.client.Dispatch("WScript.Shell").SendKeys('String to be typed') allow only to type strings from the script level but dont allow to press ENTER and other 'special' keys. Therefore my question is: How can I simulate any keyboard key press event from python script level including

Sweep Line Algorithm - Implementation for 1D plane

断了今生、忘了曾经 提交于 2019-12-03 17:13:49
The problem is simple, There is some given 1D lines on a plane. We need to find the total size of space having at least one line. Let me discuss this with an example image- This may a case . Or This may be a case or anything like this. I know it is a basic problem of Sweep Line Algorithm . But there is no proper document in the internet for it to understand properly. The one best I have is a blog of Top Coder and that is here . But it is not clear how to implement it or how may be the simulation. If I want, we can do it in O(n^2) with 2 loops, but I can't realize how would be the procedure. Or

Collision Detection between Accelerating Spheres

此生再无相见时 提交于 2019-12-03 13:54:22
I am writing a physics engine/simulator which incorporates 3D space flight, planetary/stellar gravitation, ship thrust and relativistic effects. So far, it is going very well, however, one thing that I need help with is the math of the collision detection algorithm. The iterative simulation of movement that I am using is basically as follows: (Note: 3D Vectors are ALL CAPS.) For each obj obj.ACC = Sum(all acceleration influences) obj.POS = obj.POS + (obj.VEL * dT) + (obj.ACC * dT^2)/2 (*EQ.2*) obj.VEL = obj.VEL + (obj.ACC * dT) Next Where: obj.ACC is the acceleration vector of the object obj