Wig-Wug Simulator

Discussion in 'Ruby' started by James Gray, Aug 15, 2008.

  1. James Gray

    James Gray Guest

    James Gray, Aug 15, 2008
    #1
    1. Advertising

  2. James Gray

    Chris Shea Guest

    On Aug 14, 9:19 pm, James Gray <> wrote:
    > I have started a Wig-Wug (http://therubyist.com/homework/wig-wug/)  
    > simulator and thrown it on github (http://github.com/JEG2/wig-wug/tree/master
    > ).  It probably still has issues, but it may be of interest to others  
    > playing with the problem.  It includes a map and a digger class I  
    > wrote that does badly on that map.  Enjoy.
    >
    > James Edward Gray II
    Chris Shea, Aug 15, 2008
    #2
    1. Advertising

  3. James Gray

    Chris Shea Guest

    On Aug 14, 9:19 pm, James Gray <> wrote:
    > I have started a Wig-Wug (http://therubyist.com/homework/wig-wug/)  
    > simulator and thrown it on github (http://github.com/JEG2/wig-wug/tree/master
    > ).  It probably still has issues, but it may be of interest to others  
    > playing with the problem.  It includes a map and a digger class I  
    > wrote that does badly on that map.  Enjoy.
    >
    > James Edward Gray II


    Sorry for the empty message. Hit send WAY too early.

    I mean to send this patch, which lets your game server not crash if a
    player ends up on the edge of the map:

    91a92
    > return 'E' if x == -1 || y == -1 || x == @width || y == @height


    Chris
    Chris Shea, Aug 15, 2008
    #3
  4. James Gray

    James Gray Guest

    On Aug 15, 2008, at 11:12 AM, Chris Shea wrote:

    > On Aug 14, 9:19 pm, James Gray <> wrote:
    >> I have started a Wig-Wug (http://therubyist.com/homework/wig-wug/)
    >> simulator and thrown it on github (http://github.com/JEG2/wig-wug/tree/master
    >> ). It probably still has issues, but it may be of interest to others
    >> playing with the problem. It includes a map and a digger class I
    >> wrote that does badly on that map. Enjoy.
    >>
    >> James Edward Gray II

    >
    > Sorry for the empty message. Hit send WAY too early.
    >
    > I mean to send this patch, which lets your game server not crash if a
    > player ends up on the edge of the map:
    >
    > 91a92
    >> return 'E' if x == -1 || y == -1 || x == @width || y == @height


    Interesting. Is this a patch to Map#[]? I wouldn't think it would be
    needed, due to lines 46-50 of game.rb. Am I missing something?

    James Edward Gray II
    James Gray, Aug 15, 2008
    #4
  5. James Gray

    Chris Shea Guest

    On Aug 15, 2:20 pm, James Gray <> wrote:
    > On Aug 15, 2008, at 11:12 AM, Chris Shea wrote:
    >
    >
    >
    > > On Aug 14, 9:19 pm, James Gray <> wrote:
    > >> I have started a Wig-Wug (http://therubyist.com/homework/wig-wug/)
    > >> simulator and thrown it on github (http://github.com/JEG2/wig-wug/tree/master
    > >> ).  It probably still has issues, but it may be of interest to others
    > >> playing with the problem.  It includes a map and a digger class I
    > >> wrote that does badly on that map.  Enjoy.

    >
    > >> James Edward Gray II

    >
    > > Sorry for the empty message. Hit send WAY too early.

    >
    > > I mean to send this patch, which lets your game server not crash if a
    > > player ends up on the edge of the map:

    >
    > > 91a92
    > >>      return 'E' if x == -1 || y == -1 || x == @width|| y == @height

    >
    > Interesting.  Is this a patch to Map#[]?  I wouldn't think it would be  
    > needed, due to lines 46-50 of game.rb.  Am I missing something?
    >
    > James Edward Gray II


    Yes. That was for Map#[]. But taking that out and going back to
    game.rb, I added "pp surrounding" after surrounding gets settled, and
    you can see that there's something up:

    $ ./bin/wig-wug -w 2 -h 2 ~/Desktop/bots/digger.rb [15:06:44]
    FO
    OR
    Surprise: Starts at x=1, y=0.

    Turn 1
    [["E", "E", "E"], ["F", "P", nil], ["O", "R", nil]]
    Surprise: (down) Reached the ruby.

    Result: Surprise won.

    I think the issue is that Comparable#between? includes both endpoints,
    so if a bot is on the bottom edge of the map, the Map ends up asking
    for points not on the map. And those will be nil if the player's on
    the right edge, and will raise a NoMethodError for nil[] if it's on
    the bottom edge.

    Subtracting one from width and height when they appear as arguments to
    #between? on line 46 of game.rb should actually take care of it better
    than what I suggested earlier.

    Or am I missing something now?

    Chris
    Chris Shea, Aug 15, 2008
    #5
  6. James Gray

    James Gray Guest

    On Aug 15, 2008, at 4:17 PM, Chris Shea wrote:

    > On Aug 15, 2:20 pm, James Gray <> wrote:
    >> On Aug 15, 2008, at 11:12 AM, Chris Shea wrote:
    >>
    >>
    >>
    >>> On Aug 14, 9:19 pm, James Gray <> wrote:
    >>>> I have started a Wig-Wug (http://therubyist.com/homework/wig-wug/)
    >>>> simulator and thrown it on github (http://github.com/JEG2/wig-wug/tree/master
    >>>> ). It probably still has issues, but it may be of interest to
    >>>> others
    >>>> playing with the problem. It includes a map and a digger class I
    >>>> wrote that does badly on that map. Enjoy.

    >>
    >>>> James Edward Gray II

    >>
    >>> Sorry for the empty message. Hit send WAY too early.

    >>
    >>> I mean to send this patch, which lets your game server not crash
    >>> if a
    >>> player ends up on the edge of the map:

    >>
    >>> 91a92
    >>>> return 'E' if x == -1 || y == -1 || x == @width || y ==
    >>>> @height

    >>
    >> Interesting. Is this a patch to Map#[]? I wouldn't think it would
    >> be
    >> needed, due to lines 46-50 of game.rb. Am I missing something?
    >>
    >> James Edward Gray II

    >
    > Yes. That was for Map#[]. But taking that out and going back to
    > game.rb, I added "pp surrounding" after surrounding gets settled, and
    > you can see that there's something up:
    >
    > $ ./bin/wig-wug -w 2 -h 2 ~/Desktop/bots/digger.rb [15:06:44]
    > FO
    > OR
    > Surprise: Starts at x=1, y=0.
    >
    > Turn 1
    > [["E", "E", "E"], ["F", "P", nil], ["O", "R", nil]]
    > Surprise: (down) Reached the ruby.
    >
    > Result: Surprise won.
    >
    > I think the issue is that Comparable#between? includes both endpoints,
    > so if a bot is on the bottom edge of the map, the Map ends up asking
    > for points not on the map. And those will be nil if the player's on
    > the right edge, and will raise a NoMethodError for nil[] if it's on
    > the bottom edge.
    >
    > Subtracting one from width and height when they appear as arguments to
    > #between? on line 46 of game.rb should actually take care of it better
    > than what I suggested earlier.
    >
    > Or am I missing something now?


    I think you are exactly right. I've committed the fix. Thanks!

    James Edward Gray II
    James Gray, Aug 15, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Basuki Endah Priyanto

    Free VHDL Simulator

    Basuki Endah Priyanto, Aug 15, 2003, in forum: VHDL
    Replies:
    1
    Views:
    5,337
    Tuukka Toivonen
    Aug 15, 2003
  2. Mike Kopp

    VHDL Simulator Options

    Mike Kopp, Sep 22, 2003, in forum: VHDL
    Replies:
    3
    Views:
    742
  3. Kingsley Oteng

    Bit-Level C Simulator

    Kingsley Oteng, Jan 17, 2004, in forum: VHDL
    Replies:
    4
    Views:
    623
    Tuukka Toivonen
    Jan 21, 2004
  4. Chaos Master

    Free VHDL simulator

    Chaos Master, Jun 17, 2004, in forum: VHDL
    Replies:
    5
    Views:
    19,148
    Chaos Master
    Jun 18, 2004
  5. Tristan Gingold

    [ANN] GHDL 0.13 - a free VHDL simulator

    Tristan Gingold, Jun 26, 2004, in forum: VHDL
    Replies:
    0
    Views:
    648
    Tristan Gingold
    Jun 26, 2004
Loading...

Share This Page