Binary-file module? (also, rubychess)

In Ruby, do we have a module that makes reading/parsing/writing
binary files super-easy?

I've been reading Practical Common Lisp (ISBN 1-59059-239-5)
(also available online: http://www.gigamonkeys.com/book ) and Chapter 24
has a really nice package for handling binary files.

Before I spend the time porting it to Ruby, I was curious if
anyone knows of anything similar for Ruby? Google "ruby parse binary
files" didn't come up with anything of interest.

Oh, and just as a teaser... I've been porting pythonchess-0.6
to Ruby and barring any unforeseen difficulties, it should be finished
in about another week or two. I'll probably open up a Rubyforge project
and put it in there so others can play with it.

-- Glenn Lewis

Glenn M. Lewis wrote:

Oh, and just as a teaser... I've been porting pythonchess-0.6
to Ruby and barring any unforeseen difficulties, it should be finished
in about another week or two. I'll probably open up a Rubyforge project
and put it in there so others can play with it.

That would be awesome. Would you mind sending out an email when the
Rubyforge project is available?

Thanks
Jeff

···

--
Posted via http://www.ruby-forum.com/\.

Check out binaryparse (available as a gem). I wrote it to meet my
needs (and those of my boss :-), but if there is something I could do
to enhance it, let me know.

pth

···

On 9/18/06, Glenn M. Lewis <noSpam@nospam.net> wrote:

In Ruby, do we have a module that makes reading/parsing/writing
binary files super-easy?

Glenn M. Lewis wrote:

In Ruby, do we have a module that makes reading/parsing/writing
binary files super-easy?

There's BitStruct, but it doesn't help much with variable length fields (such as a field that includes a length specifier or terminator).

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

You forgot the URL
http://code.google.com/p/binaryparse/

···

On Tue, 19 Sep 2006 13:16:42 +0900, Patrick Hurley wrote:

On 9/18/06, Glenn M. Lewis <noSpam@nospam.net> wrote:

In Ruby, do we have a module that makes reading/parsing/writing
binary files super-easy?

Check out binaryparse (available as a gem). I wrote it to meet my
needs (and those of my boss :-), but if there is something I could do
to enhance it, let me know.

pth

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/

I have now been working on the port of pythonchess-0.6 to Ruby
for over two months and have come to the point of diminishing returns.
In other words, I've about exhausted my brain cells on this one.

  Even though I have been programming in Ruby for over 5 years
and consider myself somewhat adept at it, this port has been an
extremely challenging project (also, I didn't know much about python
when I started, except that I didn't like its use of white space as
part of the language syntax).

  Now, rubychess will actually start playing a good game of chess,
but it will eventually crash as it gets closer to figuring out how to
checkmate you. This is, obviously, unacceptable. But I need help in
tracking down and fixing the remaining bug(s).

  Therefore, I've decided to go ahead and make rubychess a Rubyforge
project and hopefully enlist the talent of some of you bright Rubyists
to help me weed out the remaining bugs and polish this puppy up so that
we can play chess with our favorite language without fear of crashing. :slight_smile:

  Hopefully the Rubyforge project will get set up soon and I can
put the files in place.

  Thank you in advance for those who will help me with this... and
to the rest of the Ruby community, I apologize that I was not able to
bring this project 100% to completion before releasing it.

-- Glenn Lewis

Jeff Cohen wrote:

···

Glenn M. Lewis wrote:

Oh, and just as a teaser... I've been porting pythonchess-0.6
to Ruby and barring any unforeseen difficulties, it should be finished
in about another week or two. I'll probably open up a Rubyforge project
and put it in there so others can play with it.

That would be awesome. Would you mind sending out an email when the Rubyforge project is available?

Thanks
Jeff

Actually it's primary home is rubyforge
(http://rubyforge.org/projects/binaryparse/\) -- I created the
code.google account while waiting for the rubyforge
confirmation/setup. But the easiest way to grab it is:

gem install binaryparse

let me know if you find it useful
pth

···

On 9/19/06, Ken Bloom <kbloom@gmail.com> wrote:

On Tue, 19 Sep 2006 13:16:42 +0900, Patrick Hurley wrote:

> On 9/18/06, Glenn M. Lewis <noSpam@nospam.net> wrote:
>> In Ruby, do we have a module that makes reading/parsing/writing
>> binary files super-easy?
>
> Check out binaryparse (available as a gem). I wrote it to meet my
> needs (and those of my boss :-), but if there is something I could do
> to enhance it, let me know.
>
> pth

You forgot the URL
Google Code Archive - Long-term storage for Google Code Project Hosting.

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/

Glenn M. Lewis wrote:

    I have now been working on the port of pythonchess-0.6 to Ruby
for over two months and have come to the point of diminishing returns.
In other words, I've about exhausted my brain cells on this one.

    Even though I have been programming in Ruby for over 5 years
and consider myself somewhat adept at it, this port has been an
extremely challenging project (also, I didn't know much about python
when I started, except that I didn't like its use of white space as
part of the language syntax).

    Now, rubychess will actually start playing a good game of chess,
but it will eventually crash as it gets closer to figuring out how to
checkmate you. This is, obviously, unacceptable. But I need help in
tracking down and fixing the remaining bug(s).

    Therefore, I've decided to go ahead and make rubychess a Rubyforge
project and hopefully enlist the talent of some of you bright Rubyists
to help me weed out the remaining bugs and polish this puppy up so that
we can play chess with our favorite language without fear of crashing. :slight_smile:

    Hopefully the Rubyforge project will get set up soon and I can
put the files in place.

    Thank you in advance for those who will help me with this... and
to the rest of the Ruby community, I apologize that I was not able to
bring this project 100% to completion before releasing it.

No apology necessary... how many projects out there have major
version numbers less than 1? :slight_smile:

When you say it crashes, do you mean that literally? Or what?

Is part of this in C?

Is Ruby's performance acceptable (up till the time it dies)?

Hal

I'm a chess nut, so at least interested in looking at the code. Drop a link when you get it up somewhere.

James Edward Gray II

···

On Oct 11, 2006, at 12:25 AM, Glenn M. Lewis wrote:

  I have now been working on the port of pythonchess-0.6 to Ruby
for over two months and have come to the point of diminishing returns.
In other words, I've about exhausted my brain cells on this one.

No apology necessary... how many projects out there have major
version numbers less than 1? :slight_smile:

I think I might start the versioning of all my projects with letters of
the alphabet or perhaps animal names, just to screw with your numerical
assumptions :slight_smile:

Nic

···

--
Posted via http://www.ruby-forum.com/\.

No apology necessary... how many projects out there have major

> version numbers less than 1? :slight_smile:

             Thanks, Hal! I appreciate it.

> When you say it crashes, do you mean that literally? Or what?

             No, sorry. It exits with an error message, like this, for example:
kingix is NIL!!! color=-1... about to crash
./nchess6.rb:1924:in `': no implicit conversion from nil to integer (TypeError)
         from ./nchess6.rb:1924:in `Eval'
         from ./nchess6.rb:1918:in `each'
         from ./nchess6.rb:1918:in `Eval'
         from ./nchess6.rb:1781:in `Eval'
         from ./nchess6.rb:2407:in `ABnegaSearchZWTail'
         from ./nchess6.rb:2383:in `times'
         from ./nchess6.rb:2383:in `ABnegaSearchZWTail'
         from ./nchess6.rb:2457:in `ABnegaSearchZWTail'
          ... 11 levels...
         from board.rb:1028:in `PrepareForNextMoveWhenOpponentThinks'
         from board.rb:812:in `replaystart'
         from board.rb:230:in `build'
         from board.rb:1079

While I could easily prevent that particular ‘crash’ from happening, it is indicative of
an error somewhere in the engine that needs to be fixed, so I’m not just plugging the hole,
if that makes any sense.

> Is part of this in C?

             No, it is 100% pure Ruby. It is a line-by-line port of the Pythonchess-0.6, with
only one tiny tweak I made myself because I had always wanted the python version to
draw a red box around where it last moved from to where it last moved to, in case I was
looking away when it moved. :slight_smile:

> Is Ruby's performance acceptable (up till the time it dies)?

             Well, that is an excellent question. At work, I’ve got a brand new screaming
Core Duo machine, and the performance is great. But if you run the python version
side-by-side with the Ruby version, the python version is easily 10x faster, and sometimes
100x faster based purely on the “number of nodes” it processes during the game, which
it reports in the GUI. So most of the time Ruby will process ~200 nodes/second while
python would be processing ~4000 nodes/second. Sad, but true. I wish someone
would just step in and make an ‘-O’ flag for ruby that either byte-compiled the script
or native-compiled it and then ran it. :slight_smile:

-- Glenn

···

Hal

Glenn

Please let us know when you put up some files or open your
repository, chess and programming is a nice quiz.

All the best
JE

···

--
Jon Egil Strand
Phone: +47 98232340
jes@luretanker.no

Rubychess is now available at rubyforge:
http://rubyforge.org/projects/rubychess/
Enjoy, and thanks in advance if you choose to help on this project.
-- Glenn

Jon Egil Strand wrote:

···

Glenn

Please let us know when you put up some files or open your repository, chess and programming is a nice quiz.

All the best
JE

Greetings

On Windows XP I'm a happy user of the Fox toolkit through Lyle Johnsons
excellent fxruby library.

Now I'm trying to port some applications to linux(ubuntu 6.06, ruby
1.8.4 installed from ubuntu package), but face trouble with the fxruby
gem.

I compiled and installed the latest stable fox-toolkit (1.6.16) from
source. All fine.

I install the latest gem:
  
   sudo gem install fxruby

All fine.

I try to run hello.rb, but it fails on require 'fox1.6'

  irb(main):001:0> require 'fox1.6'
  LoadError: no such file to load -- fox1.6
          from (irb):1:in `require'
          from (irb):1

Instead, I am able to use require_gem

  irb(main):002:0> require 'rubygems'
  => true

  irb(main):003:0> require_gem 'fxruby'
  => true

Unfortunately I'm not able to include the Fox module

  irb(main):004:0> include Fox
  NameError: uninitialized constant Fox
          from (irb):4

Questions:
i) On WinXP I use: require 'fox1.6', shall I really use
    require_gem 'fxruby' on linux(ubuntu)

ii) How can the include Fox problem be mended?

All the best

···

--
Jon Egil Strand

Jon Egil Strand wrote:
...

I try to run hello.rb, but it fails on require 'fox1.6'

Maybe that was a typo, but it should be

   require 'fox16'

Does it still fail?

Does it really work on windows with

   require 'fox1.6'

?

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

As Joel noted in his reply, this should be 'fox16' and not 'fox1.6'.
But you're also going to have trouble installing FXRuby from a source
gem using the current release of RubyGems, due to a bug in the
RubyGems installer; see:

    http://rubyforge.org/tracker/index.php?func=detail&aid=4948&group_id=126&atid=575

For that reason, I'd recommend installing FXRuby using the regular
source tarball.

···

On 10/17/06, Jon Egil Strand <jes@luretanker.no> wrote:

I install the latest gem:

         sudo gem install fxruby

All fine.

I try to run hello.rb, but it fails on require 'fox1.6'

Maybe that was a typo, but it should be

   require 'fox16'

Thanks for your reply, but alas, it's my silly typo in the email.

Does it still fail?

yes, require 'fox16' fails

Does it really work on windows with

   require 'fox1.6'

no, but require 'fox16' works.

···

--
Jon Egil Strand