Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [QUIZ] Hamurabi (#223)

Reply
Thread Tools

[QUIZ] Hamurabi (#223)

 
 
Daniel Moore
Guest
Posts: n/a
 
      10-31-2009
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The three rules of Ruby Quiz:

1. Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
sent.

2. Support Ruby Quiz by submitting ideas and responses
as often as you can.

3. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion. Please reply to
the original quiz message, if you can.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

RSS Feed: http://rubyquiz.strd6.com/quizzes.rss

Suggestions?: http://rubyquiz.strd6.com/suggestions

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

## Hamurabi (#223)

Boo Rubyists,

This week's quiz was submitted by Martin DeMello[1]

Back in the microcomputer age, there was a fascinating little game
called Hamurabi (no, that isn't a typo - there was an eight character
limit). The game mechanics were pretty simple: you were the ruler of a
kingdom, and every year you had to decide what proportion of your
grain to allocate to planting, and what proportion to feeding the
people. The game engine would then set up the formulae, toss in a few
random numbers and simulate your crop and population growth. For all
its simplicity, though, it was a lot of fun to play, and oddly
compulsive.

The Wikipedia page[2] links to a couple of implementations in BASIC;
pick one and reimplement it in Ruby.

Extra credit: if someone can come up with a fun multiplayer version,
I'll be impressed

Have fun!

[1]: http://zem.novylen.net
[2]: http://en.wikipedia.org/wiki/Hamurabi

--
-Daniel
http://rubyquiz.strd6.com

 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      11-01-2009
On Oct 31, 2009, at 6:23 PM, Daniel Moore wrote:

> Back in the microcomputer age, there was a fascinating little game
> called Hamurabi (no, that isn't a typo - there was an eight character
> limit). The game mechanics were pretty simple: you were the ruler of a
> kingdom, and every year you had to decide what proportion of your
> grain to allocate to planting, and what proportion to feeding the
> people. The game engine would then set up the formulae, toss in a few
> random numbers and simulate your crop and population growth. For all
> its simplicity, though, it was a lot of fun to play, and oddly
> compulsive.
>
> The Wikipedia page[2] links to a couple of implementations in BASIC;
> pick one and reimplement it in Ruby.


Thanks for a very enjoyable quiz!

I wrote a super minimal BASIC interpreter to avoid translating the
code. (Yes, I am aware that's insane. I'll seek help.)

Ironically, I think supporting that victory FOR loop at the very end
was the hardest part. I still have bugs in that.

James Edward Gray II

 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      11-02-2009
On 2009-11-01, James Edward Gray II <(E-Mail Removed)> wrote:
> On Oct 31, 2009, at 6:23 PM, Daniel Moore wrote:
>> Back in the microcomputer age, there was a fascinating little game
>> called Hamurabi (no, that isn't a typo - there was an eight character
>> limit). The game mechanics were pretty simple: you were the ruler of a
>> kingdom, and every year you had to decide what proportion of your
>> grain to allocate to planting, and what proportion to feeding the
>> people. The game engine would then set up the formulae, toss in a few
>> random numbers and simulate your crop and population growth. For all
>> its simplicity, though, it was a lot of fun to play, and oddly
>> compulsive.


Oh, man! I remember that. There was one for the econ students at St.
Olaf loooong ago, I actually wrote my own from scratch once. In mine,
there were also woolen mills (or, in an early version, wollen mills --
I speld ril gud as a kid), and the win condition was to have a given amount of
land, plus enough bolts of fabric to make wedding dresses for your population,
and enough people that you could have hundreds of happy families. (The
question of whether wool was a good choice for a wedding dress was never
answered).

> I wrote a super minimal BASIC interpreter to avoid translating the
> code. (Yes, I am aware that's insane. I'll seek help.)


It's a good kind of crazy.

-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
 
Reply With Quote
 
Ehsanul Hoque
Guest
Posts: n/a
 
      11-02-2009

> I wrote a super minimal BASIC interpreter to avoid translating the =20
> code. (Yes=2C I am aware that's insane. I'll seek help.)


Hah=2C ingenious!=20

I really didn't want to go about translating that BASIC either=2C but inste=
ad=2C I was just going to make my own version based on whatever I just read=
about the game. Making a simple BASIC interpreter is so much cooler though=
=2C it should be a ruby quiz in and of itself really (make it a DSL for ext=
ra credit ).

BTW=2C does anybody have any ideas for how a (fun) multiplayer version of H=
amurabi would look like? What I was thinking: Add in a model of free market=
s to set price of land=2C so there would then be real trading between playe=
rs. Then a smart player could influence prices through supply=2C to his opp=
onents' detriment=2C if he could see the state of their kingdoms. And then =
there could be all sorts of nice strategies and counter-strategies in the s=
truggle to be the best. Also: quick (say 30 seconds or a minute at most)=
=2C timed rounds=2C ending at round ten or so=2C at which point the winner =
is announced=2C and the game is restarted. =20

What do you guys think of that? Sound like any fun? A problem might be find=
ing other players to actually play with live! In which case a slower=2C non=
-timed version that emailed you when it was your turn might be more appropr=
iate (and less of a time sucker).

- Ehsan
=20
__________________________________________________ _______________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/=

 
Reply With Quote
 
Martin DeMello
Guest
Posts: n/a
 
      11-02-2009
On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
<(E-Mail Removed)> wrote:
>
> I wrote a super minimal BASIC interpreter to avoid translating the code.
> =A0(Yes, I am aware that's insane. =A0I'll seek help.)


Wow, I thought translating the code would be fairly simple, but it's a
morass of gotos and one-letter variables. I think I'd have written the
interpreter a lot quicker But now my stubborn side has kicked in
and I'm going to finish the translation instead.

martin

 
Reply With Quote
 
William Manire
Guest
Posts: n/a
 
      11-02-2009
[Note: parts of this message were removed to make it a legal post.]

BASIC wasn't that bad...

it was horrible

Just out of curiosity, which BASIC interpreter was the BASIC script you're
trying to port written for?

2009/11/2 Martin DeMello <(E-Mail Removed)>

> On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
> <(E-Mail Removed)> wrote:
> >
> > I wrote a super minimal BASIC interpreter to avoid translating the code.
> > (Yes, I am aware that's insane. I'll seek help.)

>
> Wow, I thought translating the code would be fairly simple, but it's a
> morass of gotos and one-letter variables. I think I'd have written the
> interpreter a lot quicker But now my stubborn side has kicked in
> and I'm going to finish the translation instead.
>
> martin
>
>



--
William Kevin Manire
Lead Developer
Edge Of Nowhere LLC (http://www.edgeofnowherellc.com)
(206) 384-5826

 
Reply With Quote
 
James Edward Gray II
Guest
Posts: n/a
 
      11-02-2009
On Nov 2, 2009, at 2:19 PM, Martin DeMello wrote:

> On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
> <(E-Mail Removed)> wrote:
>>
>> I wrote a super minimal BASIC interpreter to avoid translating the
>> code.
>> (Yes, I am aware that's insane. I'll seek help.)

>
> Wow, I thought translating the code would be fairly simple, but it's a
> morass of gotos and one-letter variables. I think I'd have written the
> interpreter a lot quicker But now my stubborn side has kicked in
> and I'm going to finish the translation instead.


Yeah, I'm am looking forward to seeing your translated version so I
can tell if my interpreter is even doing the right things.

James Edward Gray II

 
Reply With Quote
 
Martin DeMello
Guest
Posts: n/a
 
      11-02-2009
"8k MICROSOFT BASIC", apparently It's the one here:
http://www.dunnington.u-net.com/publ...icgames/HMRABI

martin

On Tue, Nov 3, 2009 at 2:01 AM, William Manire <(E-Mail Removed)> w=
rote:
> BASIC wasn't that bad...
>
> it was horrible
>
> Just out of curiosity, which BASIC interpreter was the BASIC script you'r=

e
> trying to port written for?
>
> 2009/11/2 Martin DeMello <(E-Mail Removed)>
>
>> On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
>> <(E-Mail Removed)> wrote:
>> >
>> > I wrote a super minimal BASIC interpreter to avoid translating the cod=

e.
>> > =A0(Yes, I am aware that's insane. =A0I'll seek help.)

>>
>> Wow, I thought translating the code would be fairly simple, but it's a
>> morass of gotos and one-letter variables. I think I'd have written the
>> interpreter a lot quicker But now my stubborn side has kicked in
>> and I'm going to finish the translation instead.
>>
>> martin
>>
>>

>
>
> --
> William Kevin Manire
> Lead Developer
> Edge Of Nowhere LLC (http://www.edgeofnowherellc.com)
> (206) 384-5826
>


 
Reply With Quote
 
William Manire
Guest
Posts: n/a
 
      11-02-2009
[Note: parts of this message were removed to make it a legal post.]

Wow this looks old, almost like GWBasic.

I would suggest flow charting this thing first, then creating it in Ruby
from your chart rather than trying to translate it line for line.

2009/11/2 Martin DeMello <(E-Mail Removed)>

> "8k MICROSOFT BASIC", apparently It's the one here:
> http://www.dunnington.u-net.com/publ...icgames/HMRABI
>
> martin
>
> On Tue, Nov 3, 2009 at 2:01 AM, William Manire <(E-Mail Removed)>
> wrote:
> > BASIC wasn't that bad...
> >
> > it was horrible
> >
> > Just out of curiosity, which BASIC interpreter was the BASIC script

> you're
> > trying to port written for?
> >
> > 2009/11/2 Martin DeMello <(E-Mail Removed)>
> >
> >> On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
> >> <(E-Mail Removed)> wrote:
> >> >
> >> > I wrote a super minimal BASIC interpreter to avoid translating the

> code.
> >> > (Yes, I am aware that's insane. I'll seek help.)
> >>
> >> Wow, I thought translating the code would be fairly simple, but it's a
> >> morass of gotos and one-letter variables. I think I'd have written the
> >> interpreter a lot quicker But now my stubborn side has kicked in
> >> and I'm going to finish the translation instead.
> >>
> >> martin
> >>
> >>

> >
> >
> > --
> > William Kevin Manire
> > Lead Developer
> > Edge Of Nowhere LLC (http://www.edgeofnowherellc.com)
> > (206) 384-5826
> >

>
>



--
William Kevin Manire
Lead Developer
Edge Of Nowhere LLC (http://www.edgeofnowherellc.com)
(206) 384-5826

 
Reply With Quote
 
genericpenguin
Guest
Posts: n/a
 
      11-03-2009
Sorry I'm new to the list. Is it ok to post solutions at this point
(Nov 1 10:30am to now +48hrs)?

On Nov 3, 7:44=A0am, William Manire <(E-Mail Removed)> wrote:
> Wow this looks old, almost like GWBasic.
>
> I would suggest flow charting this thing first, then creating it in Ruby
> from your chart rather than trying to translate it line for line.
>
> 2009/11/2 Martin DeMello <(E-Mail Removed)>
>
>
>
>
>
> > "8k MICROSOFT BASIC", apparently It's the one here:
> >http://www.dunnington.u-net.com/publ...icgames/HMRABI

>
> > martin

>
> > On Tue, Nov 3, 2009 at 2:01 AM, William Manire <(E-Mail Removed)=

m>
> > wrote:
> > > BASIC wasn't that bad...

>
> > > it was horrible

>
> > > Just out of curiosity, which BASIC interpreter was the BASIC script

> > you're
> > > trying to port written for?

>
> > > 2009/11/2 Martin DeMello <(E-Mail Removed)>

>
> > >> On Mon, Nov 2, 2009 at 5:29 AM, James Edward Gray II
> > >> <(E-Mail Removed)> wrote:

>
> > >> > I wrote a super minimal BASIC interpreter to avoid translating the

> > code.
> > >> > =A0(Yes, I am aware that's insane. =A0I'll seek help.)

>
> > >> Wow, I thought translating the code would be fairly simple, but it's=

a
> > >> morass of gotos and one-letter variables. I think I'd have written t=

he
> > >> interpreter a lot quicker But now my stubborn side has kicked in
> > >> and I'm going to finish the translation instead.

>
> > >> martin

>
> > > --
> > > William Kevin Manire
> > > Lead Developer
> > > Edge Of Nowhere LLC (http://www.edgeofnowherellc.com)
> > > (206) 384-5826

>
> --
> William Kevin Manire
> Lead Developer
> Edge Of Nowhere LLC (http://www.edgeofnowherellc.com)
> (206) 384-5826


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments