Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Trees
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
1MAE002 - ALGORITHM AND COMPUTING
Advanced
Trees
Commits
02aea1bd
Verified
Commit
02aea1bd
authored
Jul 1, 2024
by
STEVAN Antoine
Browse files
Options
Downloads
Patches
Plain Diff
add snippets for `src.ui.qtree`
parent
6d2e96d3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/README.md
+48
-0
48 additions, 0 deletions
src/README.md
with
48 additions
and
0 deletions
src/README.md
+
48
−
0
View file @
02aea1bd
# `src.ui.maze`
Below are snippets that show how to define a maze and use the
`src.ui.maze`
module:
-
import the library
...
...
@@ -68,3 +69,50 @@ while True:
-
_left click_ on two different maze cells to select them
-
_right click_ to unselect all the cells
-
_ENTER_ to run the path algorithm once the maze generation is done
# `src.ui.qtree`
Below are snippets that show how to define a maze and use the
`src.ui.qtree`
module:
-
import the library
```
python
from
src.ui.qtree
import
Canva
```
-
setup the canva
```
python
canva
=
Canva
(
1600
,
800
,
caption
=
''
,
frame_rate
=
30
)
canva
.
setup
()
```
-
create a bunch of points
```
python
from
random
import
random
canva
.
points
=
[]
for
_
in
range
(
1000
):
canva
.
points
.
append
(
Point
(
randint
(
0
,
canva
.
width
),
randint
(
0
,
canva
.
height
),
3
,
))
```
-
run the animation
```
python
# compute the new set of points, e.g. by moving them a bit randomly
def
update
(
points
:
list
)
->
list
:
return
[]
# gives back to the canva the things to show.
# it should be either
# - a list of booleans, one for each point, that indicates whether or not a
# point is colliding with others
# - a quad-tree and the query range
def
f
(
points
:
list
,
mouse
:
(
int
,
int
)):
...
canva
.
loop
(
update
,
f
)
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment