Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/chynl/snake
/ functions
Functions
97 in github.com/chynl/snake
⨍
Functions
97
◇
Types & classes
16
↓ 12 callers
Method
len
(self)
src/snake.py:198
↓ 8 callers
Method
head
(self)
src/snake.py:192
↓ 6 callers
Method
adj
(self, direc: Direction)
src/pos.py:17
↓ 5 callers
Method
is_out_of_bound
(self, pos: Pos)
src/snake.py:184
↓ 4 callers
Method
is_reachable
(self, pos: Pos, snake: Snake)
src/agents/graph.py:233
↓ 4 callers
Method
neighbors
( self, pos: Pos, snake: Snake, visited: set[Pos], )
src/agents/graph.py:210
↓ 4 callers
Method
tail
(self)
src/snake.py:195
↓ 3 callers
Method
draw
(self, pos: Pos, cell_type: CellType)
src/game.py:181
↓ 3 callers
Method
is_food
(self, pos: Pos)
src/snake.py:175
↓ 3 callers
Method
is_stopped
(self)
src/snake.py:169
↓ 3 callers
Method
new_train_net
(self, src: RLNet | None = None)
src/agents/rl.py:225
↓ 3 callers
Function
print_summary_stats
( type: str, time: float, steps: float, score: float, seed: int | None = None, )
src/bench.py:131
↓ 3 callers
Method
shortest_path
(self, dst: Pos, snake: Snake)
src/agents/graph.py:74
↓ 3 callers
Method
state
(self, snake: Snake)
src/agents/rl.py:240
↓ 2 callers
Method
action
( self, q_vals: torch.Tensor, epsilon: float | None = None, )
src/agents/rl.py:285
↓ 2 callers
Method
action_to_direc
(self, action: torch.types.Number, snake: Snake)
src/agents/rl.py:321
↓ 2 callers
Method
game_over
(self)
src/game.py:153
↓ 2 callers
Method
hamilton_direc
( self, neighbors: list[tuple[Direction, Pos]], snake: Snake, )
src/agents/graph.py:144
↓ 2 callers
Function
init_agent
(mode: Mode)
src/agents/__init__.py:5
↓ 2 callers
Method
is_opposite
(self, other: "Direction")
src/direc.py:10
↓ 2 callers
Method
is_tail
(self, pos: Pos)
src/snake.py:181
↓ 2 callers
Method
move
( self, snake: Snake, action: torch.types.Number, )
src/agents/rl.py:294
↓ 2 callers
Method
next_direc
(self, snake: Snake)
src/agents/base.py:8
↓ 2 callers
Method
next_direc_valid
(self)
src/game.py:156
↓ 2 callers
Method
print_delim
(self)
src/agents/rl.py:445
↓ 2 callers
Method
refresh_food
(self, pos: Pos | None)
src/snake.py:161
↓ 2 callers
Method
refresh_grid
(self)
src/snake.py:45
↓ 2 callers
Method
reset
(self)
src/game.py:47
↓ 2 callers
Method
reset
(self, snake: Snake | None = None)
src/agents/graph.py:22
↓ 2 callers
Method
save
(self, net: RLNet)
src/agents/rl.py:403
↓ 2 callers
Method
save_recording
(self)
src/game.py:282
↓ 1 callers
Method
build_hamilton_index
(self, path: list[Direction], snake: Snake)
src/agents/graph.py:134
↓ 1 callers
Method
capture_frame
(self)
src/game.py:275
↓ 1 callers
Method
copy
(self)
src/snake.py:54
↓ 1 callers
Method
draw_empty
(self, pos: Pos)
src/game.py:188
↓ 1 callers
Method
draw_food
(self, pos: Pos)
src/game.py:197
↓ 1 callers
Method
draw_snake
(self, pos: Pos, cell_type: CellType)
src/game.py:204
↓ 1 callers
Method
hamilton_backtrack
( self, cur: Pos, dst: Pos, snake: Snake, visited: set[Pos], p
src/agents/graph.py:168
↓ 1 callers
Method
hamilton_heuristic
(self, pos: Pos, snake: Snake, visited: set[Pos])
src/agents/graph.py:204
↓ 1 callers
Method
hamilton_path
(self, dst: Pos, snake: Snake)
src/agents/graph.py:158
↓ 1 callers
Method
handle_events
(self)
src/game.py:103
↓ 1 callers
Method
index
(self)
src/direc.py:54
↓ 1 callers
Method
init_logging
(self)
src/game.py:62
↓ 1 callers
Method
is_empty
(self, pos: Pos)
src/snake.py:172
↓ 1 callers
Method
is_snake
(self, pos: Pos)
src/snake.py:178
↓ 1 callers
Method
learn
( self, experiences: Iterable[RLExperience], q_net: RLNet, q_net_target: RLNet
src/agents/rl.py:352
↓ 1 callers
Method
left
(self)
src/direc.py:32
↓ 1 callers
Method
longer_path
Build a path slightly longer than the shortest path.
src/agents/graph.py:87
↓ 1 callers
Method
loop
(self)
src/game.py:85
↓ 1 callers
Method
loss
( self, experiences: Iterable[RLExperience], q_net: RLNet, q_net_target: RLNet
src/agents/rl.py:369
↓ 1 callers
Function
main
()
rl_train.py:41
↓ 1 callers
Function
main
()
main.py:8
↓ 1 callers
Method
manhattan_dist
(self, p1: Pos, p2: Pos)
src/agents/graph.py:207
↓ 1 callers
Method
max_len_reached
(self)
src/snake.py:166
↓ 1 callers
Method
move
(self, new_direc: Direction)
src/snake.py:64
↓ 1 callers
Method
move
(self)
src/game.py:125
↓ 1 callers
Method
new_eval_net
(self)
src/agents/rl.py:211
↓ 1 callers
Method
new_food
(self)
src/snake.py:153
↓ 1 callers
Method
new_head
(self, new_direc: Direction)
src/snake.py:96
↓ 1 callers
Method
new_head_cell_after_move
(self, new_direc: Direction)
src/snake.py:142
↓ 1 callers
Method
new_snake
(self)
src/agents/rl.py:231
↓ 1 callers
Method
next_epsilon
(self, episode: int)
src/agents/rl.py:341
↓ 1 callers
Method
num_reachable
(self, snake: Snake)
src/agents/graph.py:224
↓ 1 callers
Method
old_head_cell_after_move
(self, new_direc: Direction)
src/snake.py:111
↓ 1 callers
Method
opposite
(self)
src/direc.py:21
↓ 1 callers
Function
parse_args
()
main.py:19
↓ 1 callers
Method
print_info
(self)
src/game.py:71
↓ 1 callers
Method
print_model_info
(self, net: RLNet)
src/agents/rl.py:409
↓ 1 callers
Function
print_round_stats
( mode: Mode, round: int, elapsed: float, steps: int, snake: Snake, )
src/bench.py:68
↓ 1 callers
Method
print_score
(self)
src/game.py:80
↓ 1 callers
Function
print_summary
( num_rounds: int, history_seeds: list[int], history_elapsed: list[float], history_steps: list
src/bench.py:89
↓ 1 callers
Method
print_summary
( self, episode: int, tot_rewards_history: Sequence[float], tot_scores_history
src/agents/rl.py:418
↓ 1 callers
Method
refresh_screen
(self)
src/game.py:164
↓ 1 callers
Method
right
(self)
src/direc.py:43
↓ 1 callers
Function
run_bench
( mode: Mode, num_rounds: int, rand_seed: int | None = None, max_steps: int = 1000, )
src/bench.py:9
↓ 1 callers
Method
save_states
(self)
src/game.py:293
↓ 1 callers
Method
serialize_states
(self)
src/snake.py:201
↓ 1 callers
Method
should_learn
(self, step: int, mem: Sequence[RLExperience])
src/agents/rl.py:333
↓ 1 callers
Method
snake_color
(self)
src/game.py:266
↓ 1 callers
Method
soft_update
(self, q_net: RLNet, q_net_target: RLNet)
src/agents/rl.py:393
↓ 1 callers
Method
tensorize
( experiences: Iterable["RLExperience"], )
src/agents/rl.py:118
↓ 1 callers
Method
timeout_steps
(self, snake: Snake)
src/agents/rl.py:330
↓ 1 callers
Method
train
(self)
src/agents/rl.py:157
↓ 1 callers
Method
will_die
(self, new_head: Pos)
src/snake.py:102
↓ 1 callers
Method
will_grow
(self, new_head: Pos)
src/snake.py:99
Method
__eq__
(self, other: object)
src/pos.py:12
Method
__hash__
(self)
src/pos.py:9
Method
__init__
(self, row: int, col: int)
src/pos.py:5
Method
__init__
( self, grid_size: int, coords: Iterable[Pos], cells: Iterable[CellType],
src/snake.py:18
Method
__init__
( self, mode: Mode, move_freq: int, show_grid: bool, record_frames: bo
src/game.py:22
Method
__init__
(self)
src/agents/graph.py:14
Method
__init__
(self)
src/agents/rl.py:51
Method
__init__
( self, state: torch.Tensor, action: torch.types.Number, reward: float,
src/agents/rl.py:103
Method
__init__
(self)
src/agents/rl.py:141
Method
forward
(self, x: torch.Tensor)
src/agents/rl.py:71
Method
next_direc
(self, snake: Snake)
src/agents/graph.py:27
Method
next_direc
(self, snake: Snake)
src/agents/rl.py:148