Results 1 to 8 of 8
  1. #1
    NewJavaBean is offline Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    5
    Rep Power
    0

    Default Implementing a pseudo random generator with shift-register method

    Hi guys,
    i'm new to this board, so hello!

    Like the topic said, i have to implement a pseudo random generator with the so called shift-register method. All i know is the interface this project should have but no idea how that generator is suppose to work?
    Ok, basically i create an object from RandomPseudo and when calling it's method next, i'm getting a new random number. But how works the RandomPesudo class with the classes XOR and Register?
    I make it more clear for you:

    class: RandomPseudo
    methods:
    RandomPseudo()
    RandomPseudo(long seed)
    int next(int bits)

    class: Register
    methods:
    void shiftLeft(int lsb)
    int getBitAt(int position)
    getRegisterContent()

    class: XOR
    methods:
    boolean xor(boolean i1, boolean i2)

    I hope someone can help me!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Google and/or Wikipedia usually answer these types of questions:
    Xorshift

  3. #3
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default You have lots of NON-JAVA research to do.

    It looks like your assignment is to build
    the generator from the ground up.

    The register is the easiest class by my
    experience. But it has nothing to do with
    java. It's a part of computer architecture
    that you will have to research from a
    computer architecture/design source.

    Your outline of the XOR class seems a
    lttle confusing to me. It should be the
    easiest to understand from my experience.
    You had better get a better definition of
    how this should work.

  4. #4
    NewJavaBean is offline Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    5
    Rep Power
    0

    Default

    @Fubarable
    I checked wiki before, but i still don't get it.

    @paul pasciak
    Well, we should develop it in java that's why i posted in this forum.
    Feel free to drop a piece of code then it would fit perfectly fine ;)
    If someone can help me figuring out that kind of problem, a coder-forum is a good place, i guess.
    The XOR class and how an xor actually works make sense to me. But how to combine that with the register is my problem. How to code it probably too.
    In fact, that was our second lecture and most of us dind't wrote one single line java-code before. So called pushing into the cold water :)

  5. #5
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default

    Wikipedia has a great animation of how this
    sequencer works. Use:

    "linear feedback shift registers"

    to find it.

  6. #6
    NewJavaBean is offline Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    5
    Rep Power
    0

    Default

    Thx i'll search for that

  7. #7
    NewJavaBean is offline Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    5
    Rep Power
    0

    Default

    I think i got it. I give a number to the generator each call. A Register object takes this number saves it and turns it into a order of bits. Then the two bit-positions get marks with the other two methods of class Register. After that these two bits get compared by the xor-method and the according result should be put to the first position of the register. After doing that a while the result is a random number.

    If my assumption is right, my next question is how to turn the seed-number into a appropriate form to work with the single bits. Should there be a array or something, because of the many add and erase operations of the single bits of the number.?
    Last edited by NewJavaBean; 04-06-2009 at 07:40 PM.

  8. #8
    rdtindsm is offline Member
    Join Date
    Feb 2009
    Posts
    92
    Rep Power
    0

    Default

    ignore this post
    Last edited by rdtindsm; 04-07-2009 at 06:07 AM. Reason: answer irrelevant

Similar Threads

  1. Help with class project, random number generator.
    By Christopher The Great in forum New To Java
    Replies: 4
    Last Post: 03-14-2009, 02:12 AM
  2. Random Shape generator
    By scheng12 in forum New To Java
    Replies: 1
    Last Post: 03-09-2009, 02:06 AM
  3. Replies: 3
    Last Post: 05-27-2008, 01:51 PM
  4. Run method on Ctrl+Shift+D
    By Echilon in forum AWT / Swing
    Replies: 1
    Last Post: 02-16-2008, 10:31 PM
  5. Random Generator
    By padutch2 in forum New To Java
    Replies: 1
    Last Post: 12-03-2007, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •