Skip to content
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

Merged
merged 6 commits into from
May 3, 2024

Conversation

StephenWampler
Copy link
Collaborator

One demonstration of 2D graphics and two programs showing example use of various uni packages.

Copy link
Collaborator

@Don-Ward Don-Ward left a 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?

Comment on lines +45 to +46
mh := Args().getOpt("rows") | 48 # Maze height (rows)
mw := Args().getOpt("cols") | 88 # Maze width (columns)
Copy link
Collaborator

@Don-Ward Don-Ward May 2, 2024

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.

Copy link
Collaborator Author

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.


procedure GenerateMaze(r,c) #: Depth First Maze Generation
static maze,h,w,rd
if /maze then { # BEGING - No maze yet
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BEGING -> BEGIN

Copy link
Collaborator Author

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.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insize -> inside

Copy link
Collaborator Author

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.

}
return # signal success to caller
}
}
Copy link
Collaborator

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?

end

procedure GenerateMaze(r,c) #: Depth First Maze Generation
static maze,h,w,rd
Copy link
Collaborator

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.")

Copy link
Collaborator Author

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.

}
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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

@StephenWampler StephenWampler marked this pull request as draft May 2, 2024 14:35
@StephenWampler
Copy link
Collaborator Author

I've converted this to a draft until the recursive GenerateMaze gets "unrecursed".

@StephenWampler
Copy link
Collaborator Author

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]>
@StephenWampler StephenWampler marked this pull request as ready for review May 2, 2024 19:23
@Don-Ward Don-Ward merged commit 8399ced into uniconproject:master May 3, 2024
22 checks passed
@StephenWampler StephenWampler deleted the Demos branch May 3, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants