Search Results

Search found 647 results on 26 pages for 'rand mate'.

Page 3/26 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Cheap and cheerful rand() replacement.

    - by Mick
    After profiling a large game playing program, I have found that the library function rand() is consuming a considerable fraction of the total processing time. My requirements for the random number generator are not very onerous - its not important that it pass a great battery of statistical tests of pure randomness. I just want something cheap and cheerful that is very fast. Any suggestions?

    Read the article

  • Using Mate's RemoteObjectInvoker with C# classes

    - by FigBug
    I'm using the Mate framework for Flex and communicating with a server running C#. I'm having trouble mapping C# classes to ActopnScript classes. I've got it working fine for simple classes and built in datatypes. If I have a C# method in my API that returns a API.Foo.Result what name do I use for my RemoteClass alias? Do I need to make a separate ActionScript class for each variation of the API.Foo.Result? How do I call C# method that takes a class as a parameter? Making an ActionScript class with members with the same names doesn't seem to work. What is the best way to handle C# classes that contain arrays of objects? The seem to get converted to ArrayCollections of Object. Is there a way to get them converted to an ArrayCollection of my specific class?

    Read the article

  • =rand(100,60) - MSOffice Problem

    - by sagar
    Oho ! Have you tried this one ?? Very simple office utility question. The question is something like this. Open Microsoft word ( 2003 or 2007 ) whatever you use. ( Let me clarify that - I am not here for any kind of advertisement of Micro soft - I want to solution to my Query ) After opening the word. Let's have a new empty blank document. ( It's up to you to have it or not ) Press enter to go to a new line. now type "=rand(100,60)" in new line Now press enter After writing this - it will create 81 pages long story The question is Why ?? How ?? What exactly microsoft word is doing?? Thanks in advance for sharing your great knowledge. Sagar

    Read the article

  • Linq to NHibernate, Order by Rand() ?

    - by Felipe
    Hi everybody, I'm using Linq To Nhibernate, and with a HQL statement I can do something like this: string hql = "from Entity e order by rand()"; Andi t will be ordered so random, and I'd link to know How can I do the same statement with Linq to Nhibernate ? I try this: var result = from e in Session.Linq<Entity> orderby new Random().Next(0,100) select e; but it throws a exception and doesn't work... is there any other way or solution? Thanks Cheers

    Read the article

  • problems with infinite loop

    - by Tom
    function addAds($n) { for ($i=0;$i<=$n;$i++) { while($row=mysql_fetch_array(mysql_query("SELECT * FROM users"))) { $aut[]=$row['name']; } $author=$aut[rand(0,mysql_num_rows(mysql_query("SELECT * FROM users")))]; $name="pavadinimas".rand(0,3600); $rnd=rand(0,1); if($rnd==0) { $type="siulo"; } else { $type="iesko"; } $text="tekstas".md5("tekstas".rand(0,8000)); $time=time()-rand(3600,86400); $catid=rand(1,9); switch ($catid) { case 1: $subid=rand(1,8); break; case 2: $subid=rand(9,16); break; case 3: $subid=rand(17,24); break; case 4: $subid=rand(25,32); break; case 5: $subid=rand(33,41); break; case 6: $subid=rand(42,49); break; case 7: $subid=rand(50,56); break; case 8: $subid=rand(57,64); break; case 9: $subid=rand(65,70); break; } mysql_query("INSERT INTO advert(author,name,type,text,time,catid,subid) VALUES('$author','$name','$type','$text','$time','$catid','$subid')") or die(mysql_error()); } echo "$n adverts successfully added."; } The problem with this function, is that it never loads. As I noticed, my while loop causes it. If i comment it, everything is ok. It has to get random user from my db and set it to variable $author.

    Read the article

  • Rails form not creating object

    - by user2136807
    I have created a simple form to create an instance of a modle and for some reason it is not calling the create method in the controller. Here is the form code: <% @house.mates.each do |mate| %> <p><%= mate.name %></p> <% end %> <h2>Add a new mate:</h2> <%= form_for @mate do |f| %> <p><%= f.label "Name" %> <%= f.text_field :name %> <%= f.hidden_field :house_id %> </p> <%= f.submit "Submit", :action => :create %> <% end %> Here is the controller code: class MatesController < ApplicationController def new @mate = Mate.new end def create @mate = Mate.new(params[:mate]) @mate.save redirect_to house_path(current_house) end end There is a many to one relationship between the Mate model and the House model... I am fairly new to rails but I have made other apps with similar forms, and I have never had this problem before. I can create and save Mate objects in the console, and I am not getting any errors, so it seem that somehow the controller method is not being called. Any help is much appreciated!

    Read the article

  • Fedora 18 bêta disponible : intégration du bureau Mate, de nouveaux outils Cloud et une application d'installation remaniée

    Fedora 18 bêta disponible : intégration du bureau Mate de nouveaux outils Cloud et une application d'installation remaniée La distribution Linux Fedora 18 alias « Spherical Cow » est disponible en version bêta. La nouvelle version de l'OS soutenu par Red Hat et utilisé comme socle pour RHEL ou CentOS se distingue surtout par l'intégration de l'environnement de bureau Mate (fondé sur Gnome 2), qui permettra d'attirer de nouveaux utilisateurs qui ont du mal à s'adapter à GNOME 3 ou encore KDE 4. L'environnement de bureau Gnome passe à la version controversée 3.6, qui introduit une nouvelle interface utilisateur. L'OS met également à jour les bureaux KDE, XFCE et Sugar desktop (bure...

    Read the article

  • how much effective is a frameworks for RIA in long run ?

    - by iamgopal
    hi , i am pretty newbie in terms of flex/RIA frameworks. mostly done work on server side. as i search on internet , people are using a lot different framework, cairngorm to mate. so my question is , as i am baby stepping through flex, should i go for learning framework ? or without framework ? ( as of now , those DI,DAO,VO and IoC doesnt make much sense to me apart from full form. ) . i needed to do pretty serious stuff after around eight month or so. should that be enough time for learning flex ? thanks in advance. ( also any link or pointers are welcome -- althogh i have spend whole my day googling around and making hello worlds...) . how to become master of RIA FLEX ?

    Read the article

  • Very slow guards in my monadic random implementation (haskell)

    - by danpriduha
    Hi! I was tried to write one random number generator implementation, based on number class. I also add there Monad and MonadPlus instance. What mean "MonadPlus" and why I add this instance? Because of I want to use guards like here: -- test.hs -- import RandomMonad import Control.Monad import System.Random x = Rand (randomR (1 ::Integer, 3)) ::Rand StdGen Integer y = do a <-x guard (a /=2) guard (a /=1) return a here comes RandomMonad.hs file contents: -- RandomMonad.hs -- module RandomMonad where import Control.Monad import System.Random import Data.List data RandomGen g => Rand g a = Rand (g ->(a,g)) | RandZero instance (Show g, RandomGen g) => Monad (Rand g) where return x = Rand (\g ->(x,g)) (RandZero)>>= _ = RandZero (Rand argTransformer)>>=(parametricRandom) = Rand funTransformer where funTransformer g | isZero x = funTransformer g1 | otherwise = (getRandom x g1,getGen x g1) where x = parametricRandom val (val,g1) = argTransformer g isZero RandZero = True isZero _ = False instance (Show g, RandomGen g) => MonadPlus (Rand g) where mzero = RandZero RandZero `mplus` x = x x `mplus` RandZero = x x `mplus` y = x getRandom :: RandomGen g => Rand g a ->g ->a getRandom (Rand f) g = (fst (f g)) getGen :: RandomGen g => Rand g a ->g -> g getGen (Rand f) g = snd (f g) when I run ghci interpreter, and give following command getRandom y (mkStdGen 2000000000) I can see memory overflow on my computer (1G). It's not expected, and if I delete one guard, it works very fast. Why in this case it works too slow? What I do wrong?

    Read the article

  • Explaining Asteroids Movement code

    - by Moaz ELdeen
    I'm writing an Asteroids Atari clone, and I want to figure out how the AI for the asteroids is done. I have came across that piece of code, but I can't get what it does 100% if ((float)rand()/(float)RAND_MAX < 0.5) { m_Pos.x = -app::getWindowWidth() / 2; if ((float)rand()/(float)RAND_MAX < 0.5) m_Pos.x = app::getWindowWidth() / 2; m_Pos.y = (int) ((float)rand()/(float)RAND_MAX * app::getWindowWidth()); } else { m_Pos.x = (int) ((float)rand()/(float)RAND_MAX * app::getWindowWidth()); m_Pos.y = -app::getWindowHeight() / 2; if (rand() < 0.5) m_Pos.y = app::getWindowHeight() / 2; } m_Vel.x = (float)rand()/(float)RAND_MAX * 2; if ((float)rand()/(float)RAND_MAX < 0.5) { m_Vel.x = -m_Vel.x; } m_Vel.y =(float)rand()/(float)RAND_MAX * 2; if ((float)rand()/(float)RAND_MAX < 0.5) m_Vel.y = -m_Vel.y;

    Read the article

  • How to I fix software center after installing the Linux Mint MATE desktop?

    - by tinuz
    I installed the MATE desktop using this manual but now i can't open my Ubuntu Software Center and can't open the settings from the update manager. I removed mate desktop but it doesn't fix the problem, i also reinstalled the software center, software-properties-gtk and software-properties-common using: sudo apt-get update; sudo apt-get --purge --reinstall install software-center software-properties-common software-properties-gtk. But when using this line i get the following error: Reading package lists... Done Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 3 reinstalled, 0 to remove and 0 not upgraded. Need to get 0 B/735 kB of archives. After this operation, 0 B of additional disk space will be used. (Reading database ... 304824 files and directories currently installed.) Preparing to replace software-center 5.0.2 (using .../software-center_5.0.2_all.deb) ... Unpacking replacement software-center ... Preparing to replace software-properties-common 0.81.13.1 (using .../software-properties-common_0.81.13.1_all.deb) ... Unpacking replacement software-properties-common ... Preparing to replace software-properties-gtk 0.81.13.1 (using .../software-properties-gtk_0.81.13.1_all.deb) ... Unpacking replacement software-properties-gtk ... Processing triggers for desktop-file-utils ... Processing triggers for gnome-menus ... Processing triggers for bamfdaemon ... Rebuilding /usr/share/applications/bamf.index... Processing triggers for hicolor-icon-theme ... Processing triggers for man-db ... Processing triggers for shared-mime-info ... Unknown media type in type 'all/all' Unknown media type in type 'all/allfiles' Unknown media type in type 'uri/mms' Unknown media type in type 'uri/mmst' Unknown media type in type 'uri/mmsu' Unknown media type in type 'uri/pnm' Unknown media type in type 'uri/rtspt' Unknown media type in type 'uri/rtspu' Unknown media type in type 'interface/x-winamp-skin' Setting up software-center (5.0.2) ... Traceback (most recent call last): File "/usr/sbin/update-software-center", line 38, in <module> from softwarecenter.db.update import rebuild_database File "/usr/share/software-center/softwarecenter/db/update.py", line 59, in <module> from softwarecenter.db.database import parse_axi_values_file File "/usr/share/software-center/softwarecenter/db/database.py", line 26, in <module> from softwarecenter.db.application import Application File "/usr/share/software-center/softwarecenter/db/application.py", line 25, in <module> from softwarecenter.backend.channel import is_channel_available File "/usr/share/software-center/softwarecenter/backend/channel.py", line 25, in <module> from softwarecenter.distro import get_distro File "/usr/share/software-center/softwarecenter/distro/__init__.py", line 165, in <module> distro_instance=_get_distro() File "/usr/share/software-center/softwarecenter/distro/__init__.py", line 148, in _get_distro module = __import__(distro_id, globals(), locals(), [], -1) ImportError: No module named LinuxMint Setting up software-properties-common (0.81.13.1) ... Setting up software-properties-gtk (0.81.13.1) ... $ Is there a way to fix this problem without having to reinstall Ubuntu 11.10?? thanks in advance tinuz

    Read the article

  • Linux Mint 12 sort en version finale : Gnome 3 avec extensions, MATE et DuckDuckGo comme nouveau moteur de recherche par défaut

    Linux Mint 12 sort en version finale Gnome 3 avec extensions ou MATE, DuckDuckGo est son nouveau moteur de recherche par défaut La distro. du moment Mint vient de sortir officiellement en version 12 « Lisa». L'annonce officielle vient confirmer la disponibilité de cette édition sur plusieurs sites miroirs depuis quelques jours. Mint sort en effet dès qu'elle est prête, et n'a pas de calendrier précis comme pour l'Ubuntu dont elle dérive. Avant toute considération technique, ce lancement est marqué par un partenariat stratégique. Le m...

    Read the article

  • is there a such thing as a randomly accessible pseudo-random number generator? (preferably open-sour

    - by lucid
    first off, is there a such thing as a random access random number generator, where you could not only sequentially generate random numbers as we're all used to, assuming rand100() always generates a value from 0-100: for (int i=0;i<5;i++) print rand100() output: 14 75 36 22 67 but also randomly access any random value like: rand100(0) would output 14 as long as you didn't change the seed rand100(3) would always output 22 rand100(4) would always output 67 and so on... I've actually found an open-source generator algorithm that does this, but you cannot change the seed. I know that pseudorandomness is a complex field; I wouldn't know how to alter it to add that functionality. Is there a seedable random access random number generator, preferably open source? or is there a better term for this I can google for more information? if not, part 2 of my question would be, is there any reliably random open source conventional seedable pseudorandom number generator so I could port it to multiple platforms/languages while retaining a consistent sequence of values for each platform for any given seed?

    Read the article

  • Why might this work on my server but not my schools?

    - by Doug
    I created a captcha just now, and it works PERFECTLY on my own server. On the school's server, it doesn't generate an image. Why might this be? The difference in code is one line. *Edit:*Originally, it was working, but I deleted the directory by mistake and I do not know why did it suddenly work in the first place. Source code on school server: <?php session_save_path("/ichanged/this/path/for/this/post/"); session_start(); $img=imagecreatefromjpeg("bg.jpg"); if( empty($_SESSION['captcha_numbers']) ) { $captcha_numbers = 'error'; } else { $captcha_numbers = $_SESSION['captcha_numbers']; } $image_numbers=$captcha_numbers; $red=rand(100,150); $green=rand(100,255); $blue=rand(100,255); $color=imagecolorallocate($img,255-$red,255-$green,255-$blue); $text=imagettftext($img,12,rand(-7,7),rand(10,20),rand(20,30),$color,"fonts/M04.TTF",$image_numbers); header("Content-type:image/jpeg"); header("Content-Disposition:inline ; filename=secure.jpg"); imagejpeg($img); ?> Source code on my server: <?php session_start(); $img=imagecreatefromjpeg("bg.jpg"); if( empty($_SESSION['captcha_numbers']) ) { $captcha_numbers = 'error'; } else { $captcha_numbers = $_SESSION['captcha_numbers']; } $image_numbers=$captcha_numbers; $red=rand(100,150); $green=rand(100,255); $blue=rand(100,255); $color=imagecolorallocate($img,255-$red,255-$green,255-$blue); $text=imagettftext($img,12,rand(-7,7),rand(10,20),rand(20,30),$color,"fonts/M04.TTF",$image_numbers); header("Content-type:image/jpeg"); header("Content-Disposition:inline ; filename=secure.jpg"); imagejpeg($img); ?>

    Read the article

  • Stack Overflow Error

    - by dylanisawesome1
    I recently created a recursive cave algorithm, and would like to have more extensive caves, but get a stack overflow after re-cursing a couple times. Any advice? Here's my code: for(int i=0;i<100;i++) { int rand = new Random().nextInt(100); if(rand<=20) { if(curtile.bounds.y-40>500+new Random().nextInt(20)) digDirection(Direction.UP); } if(rand<=40 && rand>20) { if(curtile.bounds.y+40<m.height) digDirection(Direction.DOWN); } if(rand<=60 && rand>40) { if(curtile.bounds.x-40>0) digDirection(Direction.LEFT); } if(rand<=80 && rand>60) { if(curtile.bounds.x+40<m.width) digDirection(Direction.RIGHT); } } } public void digDirection(Direction d) { if(new Random().nextInt(100)<=10) { new Miner(curtile, map); // try { // Thread.sleep(2); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } //Tried this to avoid stack overflow. Didn't work. }

    Read the article

  • Mutation Problem - Clojure

    - by Silanglaya Valerio
    having trouble changing an element of my function represented as a list. code for random function: (defn makerandomtree-10 [pc maxdepth maxwidth fpx ppx] (if-let [output (if (and (< (rand) fpx) (> maxdepth 0)) (let [head (nth operations (rand-int (count operations))) children (doall (loop[function (list) width maxwidth] (if (pos? width) (recur (concat function (list (makerandomtree-10 pc (dec maxdepth) (+ 2 (rand-int (- maxwidth 1))) fpx ppx))) (dec width)) function)))] (concat (list head) children)) (if (and (< (rand) ppx) (>= pc 0)) (nth parameters (rand-int (count parameters))) (rand-int 100)))] output )) I will provide also a mutation function, which is still not good enough. I need to be able to eval my statement, so the following is still insufficient. (defn mutate-5 "chooses a node changes that" [function pc maxwidth pchange] (if (< (rand) pchange) (let [output (makerandomtree-10 pc 3 maxwidth 0.5 0.6)] (if (seq? output) output (list output))) ;mutate the children of root ;declare an empty accumulator list, with root as its head (let [head (list (first function)) children (loop [acc(list) walker (next function)] (println "----------") (println walker) (println "-----ACC-----") (println acc) (if (not walker) acc (if (or (seq? (first function)) (contains? (set operations) (first function))) (recur (concat acc (mutate-5 walker pc maxwidth pchange)) (next walker)) (if (< (rand) pchange) (if (some (set parameters) walker) (recur (concat acc (list (nth parameters (rand-int (count parameters))))) (if (seq? walker) (next walker) nil)) (recur (concat acc (list (rand-int 100))) (if (seq? walker) (next walker) nil))) (recur acc (if (seq? walker) (next walker) nil)))) ))] (concat head (list children))))) (side note: do you have any links/books for learning clojure?)

    Read the article

  • what's best language to mate with Adobe Flex-based GUI for math crunching?

    - by gkdsp
    Hi, I'm not a software expert but need to outsource a web-based scientific GUI application, and I'm considering Adobe Flex. My math routines are currently in Javascript and C/C+. Having no experience with Flex, was hoping someone could help me understand what options are available for performing (preferably fast and efficient) CLIENT-side calculations. That is, can Flex interact with Javascript and/or C easily? If not, is actionscript or other language preferred? Downsides/tradeoffs? Need functions like LOG10, LN, SQRT, and would be nice to also have the error function (ERF) and complementary error function (ERFC), although I may be able to derive these last two from more basic functions if necessary. Thanks!

    Read the article

  • Is there an Alternative to TextMate's mate and rmate for Windows?

    - by TiernanO
    As part of the upcoming TextMate 2 release, there will be a new feature called rmate, which will allow you to edit files from a remote machine (Linux/Unix/OSX) via SSH using your local copy of TextMate... Is there something similar for Windows? I know i could use CyberDuck, find the file i want to edit, download locally, work on it and then re-upload, but rmate looks like you just type rmate on the remote server, and text mate pops up with the file. (i have not tried since i am not a TextMate owner) Is there something similar for Windows?

    Read the article

  • PHP, MySQL - would results-array shuffle be quicker than "select... order by rand()"?

    - by sombe
    I've been reading a lot about the disadvantages of using "order by rand" so I don't need update on that. I was thinking, since I only need a limited amount of rows retrieved from the db to be randomized, maybe I should do: $r = $db->query("select * from table limit 500"); for($i;$i<500;$i++) $arr[$i]=mysqli_fetch_assoc($r); shuffle($arr); (i know this only randomizes the 500 first rows, be it). would that be faster than $r = $db->("select * from table order by rand() limit 500"); let me just mention, say the db tables were packed with more than...10,000 rows. why don't you do it yourself?!? - well, i have, but i'm looking for your experienced opinion. thanks!

    Read the article

  • Global list doesn't contain value at another function [migrated]

    - by burakim
    I want to make a global list and I saved a value in my global list (def rand()). Whatever I save, my saved value doesnt include at another function except rand(). What am I missing? sayi = [] def rand(): global sayi initial = 1000 for i in range(1000,10000): initial +=1 sayi.append(initial) print sayi[43] def main(): rand() print len(sayi) /////// Shows 0 but I have added value at rand funct. with append funct. main()

    Read the article

  • getting Ubuntu-quality fonts / configuration under Cygwin/X

    - by user5402
    I have Cygwin/X installed on a Win7 box. I also have an Ubuntu VM running on the Win7 host. If I do the following: Start Xming on the Win7 box Start mate-terminal under Cygwin/X then mate-terminal starts up with very crappy-looking fonts and a blinking cursor. (I'm using "Monospace 10" in mate-terminal.) If I then do: Use putty to ssh into the Ubuntu VM (fowarding the X connection) Run gnome-settings-daemon on the Ubuntu VM then the fonts in mate-terminal suddenly become much better looking and the cursor stops blinking (probably because I've configured it that way in Ubuntu.) Question: How can I get the better-looking fonts and the ability to set cursor-blinks option for mate-terminal under Cygwin/X without having to run the Ubuntu VM? FWIW, I have Xming-fonts-7-5-0-4 installed. Update: Starting Xming with '-dpi 101' as suggested here helps, but the fonts are still not anti-aliased.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >