Wikia

Vim Tips Wiki

Script:900

Talk0
1,612pages on
this wiki
Revision as of 05:51, November 23, 2011 by JohnBeckett (Talk | contribs)

Use this page to discuss script 900 hanoi: Tower of Hanoi game for Vim

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

Bug: Out of range errors

Hanoi gives out of range errors (list element -1) after moving the cursor to an empty pole, and stops. --June 20, 2011

Fix

I've also found the bug "Out of range errors" just like what's described in that bug report, read as "Hanoi gives out of range errors (list element -1) after moving the cursor to an empty pole, and stops."

To fix this bug, I've read the script and found a leak when process PoleMoveDisk. It forgot to determine the condition that the target pole to select (i.e. to move to) should have disks when selecting a pole!

So to fix it, I make up the condition determination in function! s:play() at row 266/271 in script file autoload/hanoi.vim by adding statement:

if s:curpole.next.NOD() > 0 and adding endif after statement call s:PoleSelectPole(s:curpole.next/prev) to close if statement.

To be more robust, I add another condition determination statement in function! s:PoleSelectPole(newPole) at row 508 in script file autoload/hanoi.vim by adding && a:newPole.NOD() > 0 in the if statement if s:curpole != a:newPole. Of course, this supplement is optional if the above leak has been fixed.

Hope the author fix the bug and offer the latest copy for downloading. --218.189.38.36 05:39, November 23, 2011 (UTC)

Comments

Around Wikia's network

Random Wiki