[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Binary-file module? (also, rubychess

Bob Lehmann

9/19/2006 3:43:00 AM

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.gigamonkey... ) 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

16 Answers

Jeff

9/19/2006 3:57:00 AM

0

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-....

Patrick Hurley

9/19/2006 4:17:00 AM

0

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

Joel VanderWerf

9/19/2006 4:38:00 AM

0

Glenn M. Lewis wrote:
> In Ruby, do we have a module that makes reading/parsing/writing
> binary files super-easy?

There's http://redshift.sourceforge.net/..., 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

Ken Bloom

9/20/2006 1:04:00 AM

0

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
http://code.google.com/p/bi...

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

Patrick Hurley

9/20/2006 4:01:00 AM

0

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
> http://code.google.com/p/bi...
>
> --
> Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
> Department of Computer Science. Illinois Institute of Technology.
> http://www.iit.edu...
>
>

Actually it's primary home is rubyforge
(http://rubyforge.org/projects/bi...) -- 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

Bob Lehmann

10/11/2006 5:21:00 AM

0

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. :-)

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
>

Hal E. Fulton

10/11/2006 5:49:00 AM

0

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. :-)
>
> 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? :)

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

Dr Nic

10/11/2006 11:39:00 AM

0

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

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 :)

Nic

--
Posted via http://www.ruby-....

James Gray

10/11/2006 1:16:00 PM

0

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.

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

Bob Lehmann

10/12/2006 3:36:00 AM

0

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

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. :-)

> 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. :-)

-- Glenn

> Hal