Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 32/1194 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • What quality, parser-generator options exist for ruby?

    - by cartoonfox
    What open source (preferably gem-based) parser-generator options do I have in Ruby? I've used (flex&bison)|(lex&yacc) from C in the past, and I'm comfortable with BNF-style specifications. I've heard of treetop, but it looks a bit alien and verbose compared to yacc... Purpose: I want to convert my text markup language to a BNF and generate the parsing code. I think it's a better strategy than my first-order solution: http://github.com/dafydd/semantictext/blob/master/lib/semantictext/rich_text_parser.rb

    Read the article

  • 2D Particle Explosion

    - by TheBroodian
    I'm developing a 2D action game, and in said game I've given my primary character an ability he can use to throw a fireball. I'm trying to design an effect so that when said fireball collides (be it with terrain or with an enemy) that the fireball will explode. For the explosion effect I've created a particle that once placed into game space will follow random, yet autonomic behavior based on random variables. Here is my question: When I generate my explosion (essentially 90 of these particles) I get one of two behaviors, 1) They are all generated with the same random variables, and don't resemble an explosion at all, more like a large mass of clumped sprites that all follow the same randomly generated path. 2) If I assign each particle a unique seed to its random number generator, they are a little bit -more- spread out, yet clumping is still visible (they seem to fork out into 3 different directions) Does anybody have any tips for producing particle-based 2D explosions? I'll include the code for my particle and the event I'm generating them in. Fire particle class: public FireParticle(xTile.Dimensions.Location StartLocation, ContentManager content) { worldLocation = StartLocation; fireParticleAnimation = new FireParticleAnimation(content); random = new Random(); int rightorleft = random.Next(0, 3); int upordown = random.Next(1, 3); int xVelocity = random.Next(0, 101); int yVelocity = random.Next(0, 101); Vector2 tempVector2 = new Vector2(0,0); if (rightorleft == 1) { tempVector2 = new Vector2(xVelocity, tempVector2.Y); } else if (rightorleft == 2) { tempVector2 = new Vector2(-xVelocity, tempVector2.Y); } if (upordown == 1) { tempVector2 = new Vector2(tempVector2.X, -yVelocity); } else if (upordown == 2) { tempVector2 = new Vector2(tempVector2.X, yVelocity); } velocity = tempVector2; scale = random.Next(1, 11); upwardForce = -10; dead = false; } public FireParticle(xTile.Dimensions.Location StartLocation, ContentManager content, int seed) { worldLocation = StartLocation; fireParticleAnimation = new FireParticleAnimation(content); random = new Random(seed); int rightorleft = random.Next(0, 3); int upordown = random.Next(1, 3); int xVelocity = random.Next(0, 101); int yVelocity = random.Next(0, 101); Vector2 tempVector2 = new Vector2(0, 0); if (rightorleft == 1) { tempVector2 = new Vector2(xVelocity, tempVector2.Y); } else if (rightorleft == 2) { tempVector2 = new Vector2(-xVelocity, tempVector2.Y); } if (upordown == 1) { tempVector2 = new Vector2(tempVector2.X, -yVelocity); } else if (upordown == 2) { tempVector2 = new Vector2(tempVector2.X, yVelocity); } velocity = tempVector2; scale = random.Next(1, 11); upwardForce = -10; dead = false; } #endregion #region Update and Draw public void Update(GameTime gameTime) { elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; fireParticleAnimation.Update(gameTime); Vector2 moveAmount = velocity * elapsed; xTile.Dimensions.Location newPosition = new xTile.Dimensions.Location(worldLocation.X + (int)moveAmount.X, worldLocation.Y + (int)moveAmount.Y); worldLocation = newPosition; velocity.Y += upwardForce; if (fireParticleAnimation.finishedPlaying) { dead = true; } } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw( fireParticleAnimation.image.Image, new Rectangle((int)drawLocation.X, (int)drawLocation.Y, scale, scale), fireParticleAnimation.image.SizeAndsource, Color.White * fireParticleAnimation.image.Alpha); } Fireball explosion event: public override void Update(GameTime gameTime) { if (enabled) { float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; foreach (Heart_of_Fire.World_Objects.Particles.FireParticle particle in explosionParticles.ToList()) { particle.Update(gameTime); if (particle.Dead) { explosionParticles.Remove(particle); } } collisionRectangle = new Microsoft.Xna.Framework.Rectangle((int)wrldPstn.X, (int)wrldPstn.Y, 5, 5); explosionCheck = exploded; if (!exploded) { coreGraphic.Update(gameTime); tailGraphic.Update(gameTime); Vector2 moveAmount = velocity * elapsed; moveAmount = horizontalCollision(moveAmount, layer); moveAmount = verticalCollision(moveAmount, layer); Vector2 newPosition = new Vector2(wrldPstn.X + moveAmount.X, wrldPstn.Y + moveAmount.Y); if (hasCollidedHorizontally || hasCollidedVertically) { exploded = true; } wrldPstn = newPosition; worldLocation = new xTile.Dimensions.Location((int)wrldPstn.X, (int)wrldPstn.Y); } if (explosionCheck != exploded) { for (int i = 0; i < 90; i++) { explosionParticles.Add(new World_Objects.Particles.FireParticle( new Location( collisionRectangle.X + random.Next(0, 6), collisionRectangle.Y + random.Next(0, 6)), contentMgr)); } } if (exploded && explosionParticles.Count() == 0) { //enabled = false; } } }

    Read the article

  • PHP general form generator/builder

    - by Ehsan
    I'm looking for an open source php form builder or form generator to add/edit/delete/search records? I have to create a simple manager for some records, it's a common application that should be found easily, but I can't find any good code/class/application/etc :( Any help is appreciated.

    Read the article

  • need help with Java solution /newbie

    - by Racket
    Hi, I'm new to programming in general so i'm trying to be as specific as possible in this question. There's this book that i'm doing some exercises on. I managed to do more than half of what they say, but it's just one input that I have been struggling to find out. I'll write the question and thereafter my code, "Write an application that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742. Hint: Think through the easiest way to construct the phone number. Each diigit does not have to be determined separately." OK, the highlighted sentence is what i'm looking at. Here's my code: import java.util.Random; public class PP33 { public static void main (String[] args) { Random rand = new Random(); int num1, num2, num3; num1 = rand.nextInt(900) + 100; num2 = rand.nextInt(643) + 100; num3 = rand.nextInt(9000) + 1000; System.out.println(num1+"-"+num2+"-"+num3); } } How am I suppose to do this? I'm on chapter 3 so we have not yet discussed if statements etcetera, but Aliases, String class, Packages, Import declaration, Random Class, Math Class, Formatting output (decimal- & numberFormat), Printf, Enumeration & Wrapper classes + autoboxing. So consider answer the question based only on these assumptions, please. The code doesn't have any errors. Thank you!

    Read the article

  • C# documentation generator?

    - by ryeguy
    Is there any kind of documentation generator for C#? Like something that would put the xml-ish documentation right above the method/class declarations? Is there a tool or is it tucked away somewhere in VS 2008?

    Read the article

  • Am I writing this right? [noob]

    - by Aaron
    private final int NUM_SOUND_FILES = 4; private Random rnd = new Random(4); private int mfile[] = new mfile[NUM_SOUND_FILES]; //the second mfile //reports error everytime mfile[0] = R.raw.sound1; mfile[1] = R.raw.sound2; mfile[2] = R.raw.sound3; mfile[3] = R.raw.sound4; int sndToPlay = rnd.nextInt(NUM_SOUND_FILES); I keep getting syntax errors no matter how I write it. And when I get the syntax right, it forcecloses. Here's with the alleged "correct" syntax but forcecloses: private final int NUM_SOUND_FILES = 4; private Random rnd = new Random(4); private int mfile[] = new int[NUM_SOUND_FILES];{ mfile[0] = R.raw.sound1; mfile[1] = R.raw.sound2; mfile[2] = R.raw.sound3; mfile[3] = R.raw.sound4;}

    Read the article

  • Code generator tool to generate a property and backing field

    - by MattSlay
    I'm working in VS2008 and C#, and I'm looking for a (free) code generator tool to generate a property with getter and setter, as well as the backing private field to go with. The template thingy in VS does not make the field to go with it. Just looking for something a little bit better. I once saw a web site where you could build this code, then cust-and-paste it from the web page to your code.

    Read the article

  • Sorting in Lua, counting number of items

    - by Josh
    Two quick questions (I hope...) with the following code. The script below checks if a number is prime, and if not, returns all the factors for that number, otherwise it just returns that the number prime. Pay no attention to the zs. stuff in the script, for that is client specific and has no bearing on script functionality. The script itself works almost wonderfully, except for two minor details - the first being the factor list doesn't return itself sorted... that is, for 24, it'd return 1, 2, 12, 3, 8, 4, 6, and 24 instead of 1, 2, 3, 4, 6, 8, 12, and 24. I can't print it as a table, so it does need to be returned as a list. If it has to be sorted as a table first THEN turned into a list, I can deal with that. All that matters is the end result being the list. The other detail is that I need to check if there are only two numbers in the list or more. If there are only two numbers, it's a prime (1 and the number). The current way I have it does not work. Is there a way to accomplish this? I appreciate all the help! function get_all_factors(number) local factors = 1 for possible_factor=2, math.sqrt(number), 1 do local remainder = number%possible_factor if remainder == 0 then local factor, factor_pair = possible_factor, number/possible_factor factors = factors .. ", " .. factor if factor ~= factor_pair then factors = factors .. ", " .. factor_pair end end end factors = factors .. ", and " .. number return factors end local allfactors = get_all_factors(zs.param(1)) if zs.func.numitems(allfactors)==2 then return zs.param(1) .. " is prime." else return zs.param(1) .. " is not prime, and its factors are: " .. allfactors end

    Read the article

  • String replace for personalize code generator

    - by Xurxof
    I must do a automatic codes generator with user-configurable string with predefined keys and can not find a good way to do it. For example, a string OT-{CustomCode}-{Date}-{##} could generate codes OT-C0001-20100420-01 OT-C0001-20100420-02 I thought of using RegExpr.Replace(), but I would have problems if the code of a customer was {##} Any help is welcome! (and sorry for my english)

    Read the article

  • Java template classes using generator or similar?

    - by Hugh Perkins
    Is there some library or generator that I can use to generate multiple templated java classes from a single template? Obviously Java does have a generics implementation itself, but since it uses type-erasure, there are lots of situations where it is less than adequate. For example, if I want to make a self-growing array like this: class EasyArray { T[] backingarray; } (where T is a primitive type), then this isn't possible. This is true for anything which needs an array, for example high-performance templated matrix and vector classes. It should probably be possible to write a code generator which takes a templated class and generates multiple instantiations, for different types, eg for 'double' and 'float' and 'int' and 'String'. Is there something that already exists that does this? Edit: note that using an array of Object is not what I'm looking for, since it's no longer an array of primitives. An array of primitives is very fast, and uses only as much space a sizeof(primitive) * length-of-array. An array of object is an array of pointers/references, that points to Double objects, or similar, which could be scattered all over the place in memory, require garbage collection, allocation, and imply a double-indirection for access. Edit2: good god, voted down for asking for something that probably doesn't currently exist, but is technically possible and feasible? Does that mean that people looking for ways to improve things have already left the java community? Edit3: Here is code to show the difference in performance between primitive and boxed arrays: int N = 10*1000*1000; double[]primArray = new double[N]; for( int i = 0; i < N; i++ ) { primArray[i] = 123.0; } Object[] objArray = new Double[N]; for( int i = 0; i < N; i++ ) { objArray[i] = 123.0; } tic(); primArray = new double[N]; for( int i = 0; i < N; i++ ) { primArray[i] = 123.0; } toc(); tic(); objArray = new Double[N]; for( int i = 0; i < N; i++ ) { objArray[i] = 123.0; } toc(); Results: double[] array: 148 ms Double[] array: 4614 ms Not even close!

    Read the article

  • Hint to MVC view generator for primary key on POCOs

    - by myotherme
    When generating a strongly-typed Index view for my model I always get the following: <%= Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %> I am using a POCO class for use with our ORM. As I understand it when using LINQ to SQL the view code will know which field is the primary key. Is there a way that I can an attribute to the property (or class) that will let the View Generator know that the ID property if the primary key?

    Read the article

  • Generating strongly biased radom numbers for tests

    - by nobody
    I want to run tests with randomized inputs and need to generate 'sensible' random numbers, that is, numbers that match good enough to pass the tested function's preconditions, but hopefully wreak havoc deeper inside its code. math.random() (I'm using Lua) produces uniformly distributed random numbers. Scaling these up will give far more big numbers than small numbers, and there will be very few integers. I would like to skew the random numbers (or generate new ones using the old function as a randomness source) in a way that strongly favors 'simple' numbers, but will still cover the whole range, I.e. extending up to positive/negative infinity (or ±1e309 for double). This means: numbers up to, say, ten should be most common, integers should be more common than fractions, numbers ending in 0.5 should be the most common fractions, followed by 0.25 and 0.75; then 0.125, and so on. A different description: Fix a base probability x such that probabilities will sum to one and define the probability of a number n as xk where k is the generation in which n is constructed as a surreal number1. That assigns x to 0, x2 to -1 and +1, x3 to -2, -1/2, +1/2 and +2, and so on. This gives a nice description of something close to what I want (it skews a bit too much), but is near-unusable for computing random numbers. The resulting distribution is nowhere continuous (it's fractal!), I'm not sure how to determine the base probability x (I think for infinite precision it would be zero), and computing numbers based on this by iteration is awfully slow (spending near-infinite time to construct large numbers). Does anyone know of a simple approximation that, given a uniformly distributed randomness source, produces random numbers very roughly distributed as described above? I would like to run thousands of randomized tests, quantity/speed is more important than quality. Still, better numbers mean less inputs get rejected. Lua has a JIT, so performance can't be reasonably predicted. Jumps based on randomness will break every prediction, and many calls to math.random() will be slow, too. This means a closed formula will be better than an iterative or recursive one. 1 Wikipedia has an article on surreal numbers, with a nice picture. A surreal number is a pair of two surreal numbers, i.e. x := {n|m}, and its value is the number in the middle of the pair, i.e. (for finite numbers) {n|m} = (n+m)/2 (as rational). If one side of the pair is empty, that's interpreted as increment (or decrement, if right is empty) by one. If both sides are empty, that's zero. Initially, there are no numbers, so the only number one can build is 0 := { | }. In generation two one can build numbers {0| } =: 1 and { |0} =: -1, in three we get {1| } =: 2, {|1} =: -2, {0|1} =: 1/2 and {-1|0} =: -1/2 (plus some more complex representations of known numbers, e.g. {-1|1} ? 0). Note that e.g. 1/3 is never generated by finite numbers because it is an infinite fraction – the same goes for floats, 1/3 is never represented exactly.

    Read the article

  • Windows 7 random black screen when idle

    - by Omar
    Occasionally, when I'm away from my computer for about 5 minutes, the computer screen will go black and all USB devices (keyboard/mouse) will lose power. Attempting to move the mouse or pressing keys does not 'wake up' the computer. This only started happening a few days ago but I'm not sure what changes I did could have caused this and I uninstalled programs (one by one) I installed before it started happening, but still having the same issue. The one thing I noticed different about my computer since it started happening is i've been getting random survey popups from www.insightexpress.com. I ran Microsoft Security Essentials scan, it picked up some Java related malware, I removed it but still the same issue. I'm running MBAM right now and will run SAS after.

    Read the article

  • Random haproxy 408 errors

    - by Errol Fitzgerald
    I keep getting random 408 timeout messages from haproxy, but can't figure out if its a bug in 1.5-dev25 or something in my config file global log 127.0.0.1 local0 log 127.0.0.1 local1 info #log loghost local0 info maxconn 80000 #debug #quiet user haproxy group haproxy stats socket /tmp/haproxy.sock defaults log global mode http errorfile 503 /etc/haproxy/errors/503.http option httplog option dontlognull retries 3 option redispatch maxconn 80000 timeout client 12s timeout server 120s timeout queue 120s timeout connect 10s timeout http-request 30s option http-server-close timeout http-keep-alive 3000 option abortonclose option httpchk ... Does anyone see anything wrong with these config settings?

    Read the article

  • Need help diagnosting a random BSOD

    - by diimdeep
    I have random BSOD even in idle .. Already tried: memtest - ok scandisk- ok netsh int ip reset Winsock fix. tcpip.sys+2c13e 21.06.2011 15:21:00 DRIVER_IRQL_NOT_LESS_OR_EQUAL tcpip.sys+2de08 22.06.2011 15:09:28 DRIVER_IRQL_NOT_LESS_OR_EQUAL tcpip.sys+2de08 22.06.2011 16:09:31 DRIVER_IRQL_NOT_LESS_OR_EQUAL tcpip.sys+2c13e 23.06.2011 9:48:16 DRIVER_IRQL_NOT_LESS_OR_EQUAL Fastfat.SYS+4dc 21.06.2011 11:55:10 SYSTEM_THREAD_EXCEPTION_NOT_HANDLED ipnat.sys ipnat.sys+6751 ntoskrnl.exe ntoskrnl.exe+699e0 tcpip.sys tcpip.sys+2c13e 0 HTTP.sys HTTP.sys+15d00 ipnat.sys ipnat.sys+6751 tcpip.sys tcpip.sys+2de08 ipnat.sys ipnat.sys+6751 ntoskrnl.exe ntoskrnl.exe+79d94 tcpip.sys tcpip.sys+2c13e Fastfat.SYS Fastfat.SYS+4dc ntkrnlpa.exe ntkrnlpa.exe+8d820 Here is .dmp files and report generated by BlueScreenView https://skydrive.live.com/redir.aspx?cid=7e5eafae5336f402&resid=7E5EAFAE5336F402!116 Please help !! I know this questions but answers in it not help Only browser causes BSOD -- all other TCP operations okay

    Read the article

  • Changing an MSSQL clustered index field from containing "random" GUIDs to sequential GUIDs - how wil

    - by Eyvind
    We have an MSSQL database in which all the primary keys are GUIDs (uniqueidentifiers). The GUIDs are produced on the client (in C#), and we are considering changing the client to generate sequential (comb) GUIDs instead of just using Guid.NewGuid(), to improve db performance. If we do this, how will this affect installations that already have data with "random" GUIDs as clustered PKs? Can anything be done (short of changing all the PK values) to rebuild the indexes to avoid further fragmentation and bad insert performance? Please give explicit and detailed answers if you can; I am a C# developer at heart and not all too familiar with all the intricacies of SQL Server. Thanks!

    Read the article

  • Random flickering on 2.6.32 kernels after suspend

    - by whitequark
    I have XUbuntu 9.10 installed on a Toshiba NB200 netbook with Intel video card that's handled with i915 driver. With 2.6.31 stable, recommended kernel everything but WiFi works fine: Atheros ath9k WiFi shows too small signal power and loses packets in 'bursts' sometimes. With 2.6.32-* (I tested -9 to -11 from Ubuntu's kernel unstable ppa) everything works fine just prior to first suspend: echo mem >/sys/power/state. After it random unidentified fullscreen 'one-frame' flickering begins in Xorg, and after a couple of minutes everything eventually hangs while showing filled grey (not white; it is like default button colour) screen; no X keys are working: Ctrl+Alt+Fn don't, blind typing in console too. Magic SysRq still works and I was able to reboot. Also there is one out-of-tree kernel module called omnibook that is required to turn on WiFi and Bluetooth. Any advices?

    Read the article

  • iPod Touch G4 disconnects from Belkin N+ Router at random intervals

    - by leeand00
    I have an iPod Touch G4 and a Belkin N+ Router F5D8235-4 v2, and for some reason the iPod Touch disconnects from the router at random intervals. Checking the settings in the iPod, it will read that it is still connected to the router, but before I can access the internet again, I have to turn on Airplane mode and then turn it off again to get any program to work with the Internet again. I've tried upgrading the firmware in the router, but that also doesn't seem to help. I'm using the wiresless mode 802.11b&802.11g&802.11n in the 20/40MHz frequency. Is there any way of fixing this issue? It doesn't happen with any of the other devices that are connected to the router. This post has been cross-posted here

    Read the article

  • Autoinstall of Microsoft Security Essentials give random error message

    - by vegarwe
    I'm using wpkg to auto install Microsoft security essentials on WinXP. At the first login after the installer finishes I get an error message as msseces.exe starts. After a reboot the message goes away. The error message indicates a random access restriction. "An error has occured in the program. Try to open it again. If this problem continues, you'll need to reinstall Microsoft Security Essentials from the Microsoft Download Center. Error code: 0x80070005" Firstly: Does anyone know why I get this error message? Second: How do I debug this kind of problems? The event log doesn't seem to contain anything useful. Is there a tool to detect and list denied system calls?

    Read the article

  • Putty freezes at random when logging into a remote machine in another continent

    - by vito
    I have to ssh to a remote machine in Europe from Asia every day for my work. But Putty freezes sometimes at totally random times and I have no choice but to close and re-open a new ssh session. It's frustrating especially when I'm editing something or executing a long running program. I know the question really doesn't have much details ('cause nothing seems to be wrong with the network at all). Has anyone experienced this sort of issue with Putty and had resolved it? Thanks for your time!

    Read the article

  • PRNG test suite: bitstream and stream length

    - by Martin Trigaux
    On the NIST website, there is a tool called sts (Statistical Test Suite) that allow us to rest the validity of a pseudo-random number generator based on a stream of bits in input. When running the program, there is two variables I am not sure to understand : the stream length and number of bitstream. Is the stream length the size of the file ? The number of bit inside ? The size of a bitstream ? Are the bitstreams subset of the whole file ? Chosen how ? Let say I have a text file containing 1,000,000 bits in ascii. What should be my arguments ? You can find the user manual here if needed (I didn't find explanation about what are these variables in it). Thank you

    Read the article

  • Random shut down? Asus N53J Laptopi

    - by Mr.Y
    My Laptop is pretty new and today it random shut down on its own. I was surfing the net and the computer shut down on its own (Like losing power, without any warning). It was the 2nd time, the first time was 3 weeks ago. Btw it happens during cold days. I remember one time I was unable to turn on my laptop at all. So I'm pretty sure it's not related to heat issue... could it be the laptop is too "cold"? My room temperature is around 17=18 degree on average :P edit -I use Windows 7 Professional. -I run memtest86 once and it passed. -I run my laptop WITHOUT battery all the time.

    Read the article

  • Random Server shutdown? - CentOS

    - by Kevin Hammett
    My system was working fine, and then it just had a random restart. Anyone have any idea of the problem? The message log: Jul 6 22:56:34 909I7 shutdown[719711]: shutting down for system halt Jul 6 22:56:34 909I7 init: Switching to runlevel: 0 Jul 6 22:56:35 909I7 smartd[10743]: smartd received signal 15: Terminated Jul 6 22:56:35 909I7 smartd[10743]: smartd is exiting (exit status 0) Jul 6 22:56:42 909I7 hcid[8749]: Got disconnected from the system message bus Jul 6 22:56:42 909I7 auditd[8430]: The audit daemon is exiting. Jul 6 22:56:42 909I7 kernel: audit(1341640602.922:344412): audit_pid=0 old=8430 by auid$ Jul 6 22:56:43 909I7 pcscd: pcscdaemon.c:572:signal_trap() Preparing for suicide Jul 6 22:56:43 909I7 pcscd: hotplug_libusb.c:376:HPRescanUsbBus() Hotplug stopped Jul 6 22:56:44 909I7 pcscd: readerfactory.c:1379:RFCleanupReaders() entering cleaning f$ Jul 6 22:56:44 909I7 pcscd: pcscdaemon.c:532:at_exit() cleaning /var/run Jul 6 22:56:44 909I7 kernel: Kernel logging (proc) stopped. Jul 6 22:56:44 909I7 kernel: Kernel log daemon terminating. Jul 6 22:56:45 909I7 exiting on signal 15

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >