http://qs321.pair.com?node_id=951769


in reply to ASCII Battleship Program

Bug report: When you try to place an entity on the board that has a width of less than five (the largest piece), the smaller piece shows up at an offset from where you actually try to place it.

Example: Place a sub (three chars wide) at A7r. You can't. You must place it at A5r, in which case it appears at A6r, extends right three places, and leaves a blank slot in A10.

It also seems (in the one game I played) that the computer placed two pieces overlapping. I could be wrong on that though.


Dave

Replies are listed 'Best First'.
Re^2: ASCII Battleship Program
by perlStuck (Sexton) on Feb 04, 2012 at 15:25 UTC

    Yeah, I think I found a partial solution at least. It would appear that two of the conditionals that would allow the return of a properly placed ship was faulty. In 'sub place_ship' there's a line that reads:

    return 0 if $x<0 or $y<0 or $x>9 or $y>9;

    Changing it to:

    return 0 if $x<0 or $y<0 or $x>10 or $y>10;
    That seems to work.