Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Abdi Danny 2019 ZHAC232 100938755 FINAL YEAR PROJECT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Abdi Danny (2019) ZHAC232
Abdi Danny 2019 ZHAC232 100938755 FINAL YEAR PROJECT
Commits
2f52cd3e
Commit
2f52cd3e
authored
1 year ago
by
DannyAbdi
Browse files
Options
Downloads
Patches
Plain Diff
Created basic game logic
parent
0a6bfc83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Single and Multi-Agent Pathfinding in Maze games
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game.py
+60
-0
60 additions, 0 deletions
game.py
with
60 additions
and
0 deletions
game.py
0 → 100644
+
60
−
0
View file @
2f52cd3e
class
Game
:
def
__init__
(
self
,
maze
):
self
.
maze
=
maze
self
.
player_position
=
(
1
,
1
)
self
.
enemy_positions
=
self
.
get_enemy_positions
()
def
get_player_position
(
self
):
for
i
in
range
(
len
(
self
.
maze
)):
for
j
in
range
(
len
(
self
.
maze
[
0
])):
if
self
.
maze
[
i
][
j
]
==
0
:
return
i
,
j
return
None
def
get_enemy_positions
(
self
):
# Implement logic to find the opponents' positions in the maze
pass
def
update_positions
(
self
):
# Update the positions of the player and opponents based on the current state of the maze
self
.
player_position
=
self
.
get_player_position
()
self
.
enemy_positions
=
self
.
get_enemy_positions
()
def
move_player
(
self
,
direction
):
# Implement logic to move the player in the specified direction
pass
def
move_opponents
(
self
):
# Implement logic to move the opponents based on their behavior
pass
def
check_game_over
(
self
):
# Implement logic to check if the game is over (e.g., player reached the goal or caught by opponent)
pass
def
play_game
(
self
):
# Main game loop
while
not
self
.
check_game_over
():
# Update positions
self
.
update_positions
()
# Move opponents
self
.
move_opponents
()
# Render the game state
self
.
render
()
# Handle player input and move player
player_input
=
self
.
get_player_input
()
self
.
move_player
(
player_input
)
# Game over, print result
print
(
"
Game Over!
"
)
def
render
(
self
):
# Implement logic to render the current state of the maze with player and opponent positions
pass
def
get_player_input
(
self
):
# Implement logic to get player input (e.g., arrow keys) for movement
pass
\ No newline at end of file
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