-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A few simple programs demonstrating different features of the uni library #449
Conversation
…rary. Signed-off-by: Steve Wampler <[email protected]>
Signed-off-by: Steve Wampler <[email protected]>
Signed-off-by: Steve Wampler <[email protected]>
Signed-off-by: Steve Wampler <[email protected]>
Signed-off-by: Steve Wampler <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After our discussion (in a PM), Is it worth deferring this commit until the GenerateMaze
procedure has been refactored to replace the deep recursion with an explicit stack?
mh := Args().getOpt("rows") | 48 # Maze height (rows) | ||
mw := Args().getOpt("cols") | 88 # Maze width (columns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These defaults don't match the help. I suggest that we define DEFROW
and DEFCOL
(or some such) and use those definitions in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the mismatch but left them magic constants as the HTML comment would still need the magic values.
uni/gprogs/qmazer.icn
Outdated
|
||
procedure GenerateMaze(r,c) #: Depth First Maze Generation | ||
static maze,h,w,rd | ||
if /maze then { # BEGING - No maze yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BEGING -> BEGIN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'maze' really should have been a local variable, so that's fixed, removing the typo in the process.
uni/gprogs/qmazer.icn
Outdated
GenerateMaze(start[1],start[2]) # recurse through maze | ||
return 1(.maze,maze := &null) # return maze, reset for next | ||
} | ||
else { # ----------------------- recursed to clear insize of maze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insize -> inside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went away when recursive version was made non-recursive.
uni/gprogs/qmazer.icn
Outdated
} | ||
return # signal success to caller | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a comment "Fail if already seen". be helpful here?
uni/gprogs/qmazer.icn
Outdated
end | ||
|
||
procedure GenerateMaze(r,c) #: Depth First Maze Generation | ||
static maze,h,w,rd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it's possible to figure out what's going on by a careful reading of the code, I think a brief description of the maze data structure would be helpful (Something like "a two dimensional array of bit significant values implemented as a list of lists. The meaning of each bit is described above on lines 80 .. 89. Each value represents one cell of the maze.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added to that effect.
uni/gprogs/qmazer.icn
Outdated
} | ||
rd := [NORTH, EAST, SOUTH, WEST] # initial list of directions | ||
GenerateMaze(start[1],start[2]) # recurse through maze | ||
return 1(.maze,maze := &null) # return maze, reset for next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this (quite subtle) code a fossil from when GenerateMaze could be called more than once by the main program? If not, reset for next what exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost certainly. Will get removed along with the recursion.
maxcands # Most candidates on any ballot (needed in tie-breaks) | ||
|
||
#<p> | ||
# Read in ranked-choice ballots where each ballot is a single line with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Minor: no need to fix if you don't want to)
Is it worth noting that the program doesn't handle spoilt ballots?
I've converted this to a draft until the recursive GenerateMaze gets "unrecursed". |
The qmazer program has been rewritten so maze-generation no longer uses recursion, allowing for larger mazes to be generated without causing a stack-overflow. |
Signed-off-by: Steve Wampler <[email protected]>
One demonstration of 2D graphics and two programs showing example use of various uni packages.