2025 COMSM0166 group 11a
🎮 Click this link to play our game!
🎬 Click this link to watch our game video!
đź’» Here are the links to our weekly homeworks.
| week 1 | week 2 | week 3 | week 4 | week 5 | week 7 | week 8 | week 9 | week 10
đź“‹ This is the link to our Kanban board.
Image 1: Team Members
Image 2: Classic Snake Game,
Source: analyticsindiamag
Image 3: Snake Battle,
Source: Youtube
Image 4: Our Game
This project draws inspiration from one of the most iconic classic games—Snake. However, in contrast to the traditional version, which restricts player movement to four directional keys (up, down, left, right), our goal was to provide a more fluid and intuitive control system on the PC platform. Inspired by the mobile game Snake Battle, where players use a virtual joystick to control the snake’s direction, we designed our version to allow players to guide the snake using mouse input. The p5.js library proved to be particularly suitable for this purpose, as it enables precise mouse-based direction control and allows for the snake’s body to be dynamically rendered using overlapping circles, eliminating the need for external sprite assets.
To enhance the game’s playability, we introduced a variety of power-up food items. When consumed, these items grant temporary buffs such as increased food collection range, short-term invincibility, or enhanced stamina for acceleration. Additionally, we designed multiple maps and difficulty levels, each incorporating unique gameplay mechanics. For example, swamp terrain reduces movement speed, fog limits visibility, and teleportation portals allow for quick relocation to different areas of the map.
An important feature of the game is the inclusion of AI-controlled snakes that compete with the player for food. To maintain balance and competitiveness, AI snakes drop food upon death. Since any collision between a snake’s head and a non-food object results in death, players can strategically eliminate AI opponents to gain additional resources.
Each member of our team independently researched game types they were personally interested in. We then came together to share and discuss our findings, evaluating each proposed concept based on feasibility, alignment with team members’ interests, and the potential for scalability within the scope of our project. Through this scoring process, two game types emerged as the highest-rated: side-scrolling platformers and arcade-style games, with Snake as a representative example.
Ultimately, we chose Snake as the foundation for our project. Our primary objective was to focus on enhancing our coding skills and gameplay design abilities, rather than investing a large portion of our time in level or map design, which would have been a significant part of a platformer. The simplicity and extensibility of Snake aligned well with our goal to experiment with control schemes, AI behavior, and game mechanics.
During the ideation phase, we also referenced modern adaptations of the classic Snake game, such as Slither.io and Snake Battle, which inspired us to explore mouse-based controls, dynamic gameplay elements, and multiplayer mechanics. We held structured brainstorming sessions using collaborative tools to consolidate ideas and assess the technical feasibility of each concept, especially within the capabilities of the p5.js library.
Additionally, you may notice that our team was divided into two subgroups, 11a and 11b. This decision arose during the this stage, as we encountered fundamental differences in creative direction that proved difficult to reconcile. To ensure smooth progress and allow each group to pursue its own vision effectively, we mutually agreed to split into two sub-teams and continue the development of two game projects independently.
To clarify the features we could realistically implement and to prioritize our development tasks, we discussed and formulated a series of user stories. The full list can be found in our week 4 assignment. Below are several key stories that had a significant impact on the final deliverable:
“As a player, I want to control the snake using touch or keyboard so that I can play easily.”
“As a player, I want different map modes, such as swamp, desert, and teleportation, each with unique characteristics, so that I can experience varied gameplay.”
“As a player, I want to adjust the game difficulty to match different challenge levels.”
“As a player, I want a timed mode where I can achieve the highest score within a limited time.”
In addition to player-centered stories, we also created developer and UI designer stories to guide the project from a broader perspective:
“As a developer, I want to implement modular managers (e.g., FoodManager, ObstacleManager, ItemManager) so that we can maintain and expand different gameplay elements independently.”
“As a developer, I want to implement AI snakes that can compete with players for food, so the game has an engaging and competitive challenge.”
“As a designer, I want to create a multi-step start menu (snake customization → map → difficulty), so players are guided smoothly into the game.”
“As a designer, I want to implement a victory and game-over screen with reasons (e.g., timeout, collision), so that players receive clear feedback.”
In designing user stories for our Snake Game, we adopted the “As a [user], I want to [goal] so that [reason]” structure to ensure clarity and player-centered design. This method helped us define features that directly address user needs and align with gameplay experience.
We also emphasized writing clear, testable acceptance criteria using the Given-When-Then format. For example, selecting the swamp map slows the snake with water hazards, while the desert mode increases difficulty by reducing food frequency. The teleportation mode repositions the snake across the screen, adding a unique twist. These outcomes help validate functionality effectively during development.
Importantly, we ensured that all user stories were feasible and supported gameplay diversity. Using frameworks like MoSCoW, we prioritized features and focused development on delivering a smooth, engaging experience. This systematic approach improved collaboration and guaranteed a balanced, player-friendly design.
Image 5: Prototype
To align with our development approach, we referred to the mobile game Snake Battle as our primary design inspiration. Although Snake Battle is a multiplayer online game, our target platform does not support multiplayer functionality. As a result, we had to explore alternative gameplay mechanics to enhance player engagement.
In the early stages of design, we proposed incorporating roguelike elements, including various buff and debuff items—such as candy (which grants a temporary speed boost), cookies (which reveal additional food locations), and trash (which causes damage or unexpected acceleration). We also considered implementing both single-player and two-player modes.
However, as development progressed, we realized that these ideas deviated from the core essence of the classic Snake game and introduced ambiguity in the win conditions, which undermined gameplay consistency. Therefore, we decided to retain only the buff system and the single-player mode, while continuously re-evaluating new gameplay ideas through weekly iteration and testing.
In the first sprint (initial deliverable version), our focus was on faithfully recreating the core mechanics of the reference game: the snake is controlled using the mouse to navigate, consuming food increases its length and score, and the game ends if the snake collides with the map boundary or any obstacle. To increase the level of challenge, we added AI-controlled snakes and obstacles to the map. A collision between the player’s snake head and an AI snake’s body also results in game over. AI snakes compete with the player for food, and in hard mode, food dropped upon the death of AI snakes becomes a crucial scoring resource.
Image 6: Use-Case Diagram
</div>
We used a use case diagram to preliminarily identify the functional components of the game, helping to provide a clear and intuitive understanding of the required features. During this phase, we held discussions to determine the key use cases of the game and how players would interact with each component. Players engage with the game through a linear interaction flow, starting from a specific screen shown after selecting "Start Game", after which they can choose a map and a difficulty mode. This design allows players to become familiar with the game before challenging themselves further.
In addition, each difficulty mode is associated with its own set of components. As players progress, these components increase the challenge within each mode. For instance, the “Swamp” map may extend into a “Slow Speed” challenge, while the “Desert” map could introduce a “Reduced Visibility” mechanic. During gameplay, players are able to move, gain scores, and collect buff items, but may also die if they encounter obstacles.
This use case diagram focuses solely on the game’s core gameplay functionality and supports the implementation of the features discussed in the early design phase. Since we adopted an agile development methodology, numerous additional features were introduced later in the project—such as pause functionality, sound effects, and more refined AI snake movement. All of these were integrated without disrupting the structure of the original use case diagram, which continued to serve as a foundation for iterative improvements.
### Requirements Definition
We conduct weekly requirement reviews based on the current state of the game to gather additional player feedback, refine gameplay mechanics, and address bugs. This iterative process is also reflected in our Kanban board. The finalized requirements for the deliverable version are as follows:
**1. Game Objective
**
The main goal of the game is for the player to control a snake and consume randomly generated food on the map. The player must reach a target score within a limited time in order to win.
**2. Player Controls
**
The snake’s direction is controlled using the mouse.
The player can accelerate the snake by holding the left mouse button. Acceleration consumes stamina, which is limited and regenerates over time or through specific items.
**3. Core Gameplay Mechanics
**
Each time the snake consumes a piece of food, its body length increases and the score is incremented.
If the player defeats an AI-controlled snake by colliding with it using their snake’s body (not head), the AI snake is destroyed and additional food or special items are dropped.
The game ends immediately if the player's snake collides with the edge of the map, any obstacles, or the head/body of an AI snake.
**4. Power-Ups and Items
**
Several power-up items are introduced to enhance gameplay.
**Charge Boost**: Instantly refills the stamina bar, allowing the player to accelerate again.
**Invincibility**: Grants temporary immunity to collisions with obstacles and AI snakes. However, the player can still die if they collide with the edge of the map.
**Foraging Radius Increase**: Temporarily enlarges the effective area around the snake’s head for collecting food, making it easier to gather items.
**5. Map Variations and Environmental Effects
**
To introduce variety and challenge, the game includes multiple map modes, each with unique effects.
**Swamp Map**: When the snake moves through swamp terrain, its movement speed decreases, and acceleration is less effective.
**Desert Map**: Occasional sandstorms obscure the player's vision, making navigation more difficult.
**Teleportation Map**: Teleportation portals allow the snake to instantly travel to different locations on the map, enabling strategic repositioning.
**6. Difficulty Modes
**
**Normal Mode**: Designed for casual gameplay, this mode includes a moderate number of AI snakes, a balanced distribution of obstacles, and a standard amount of food items across the map.
**Hard Mode**: Intended for experienced players seeking a challenge. In this mode, the game initializes with a significantly higher number of AI-controlled snakes, increased obstacles scattered throughout the map, and a reduced frequency of food item spawns. This setting requires more strategic movement and resource management to succeed.
**7. Win and Loss Conditions
**
**Victory Condition**: The player wins the game by achieving the target score within the allotted time limit.
**Defeat Conditions**: The player loses if they fail to reach the target score in time, or if their snake collides with the map boundary, any obstacle, or an AI-controlled snake.
# 4. Design
### Class diagram
The class diagram for the Snake Game represents the key components and their relationships. The Snake class serves as the base for PlayerSnake and AISnake, with attributes like body, direction, and movement methods, while PlayerSnake handles user input, stamina, and special states, and AISnake focuses on AI-controlled behavior such as tracking food and avoiding obstacles. The GameMap class manages grid size, borders, and environmental effects, interacting with specialized managers like SwampManager, FogManager, and TeleportManager to generate and process different terrain effects. The ItemManager controls in-game items such as stamina boosts and teleportation, while ObstacleManager generates and manages obstacles like ladders. The FoodManager governs food placement and properties, ensuring AI and player interactions. Enumerations define item types and difficulty modes. This structured design ensures modularity, clear responsibilities, and efficient game management.
Image 7: Class Diagram
Image 8: Sequence Diagram
Image 9: Control
### Challenge 2: AI enemy snake design To enhance the game's challenge, we designed an AI-controlled enemy snake with capabilities including autonomous pathfinding, obstacle avoidance, target tracking, and player interaction. The most technically demanding aspects of the AI snake implementation lie in path planning and obstacle avoidance. To simulate realistic movement behavior, we adopted a directional vector system combined with linear interpolation via the lerp() function, enabling smoother and more natural turns. To prevent collisions, the AI snake “predicts” whether its next movement step will result in a collision with an obstacle or boundary. This prediction is carried out through the predictCollision() method. If a potential collision is detected, the AI will promptly adjust its direction and attempt to navigate around the obstacle. Furthermore, the target tracking mechanism enhances the AI's strategic behavior. Instead of always pursuing the nearest food item, the AI selects one at random from the three closest food items using the findRandomNearestFood() method. This introduces a degree of unpredictability, thereby increasing gameplay diversity and challenge. Additionally, the AI evaluates the feasibility of pursuing a target based on distance, avoiding ineffective “blind chasing” behavior. Lastly, the interaction with the player and the death feedback mechanism further enrich gameplay dynamics. The AI actively detects collisions with the player's snake: if the player's head collides with the AI's body, the player is defeated; conversely, if the AI's head hits the player, the AI is destroyed. Upon death, the AI snake spawns a number of food items and power-ups proportional to its body length. This design not only increases the game's dynamism but also provides clear reward feedback to the player. To ensure these drops do not overlap or appear in invalid locations, the system shuffles the AI's body segments and applies coordinate offsets during placement.
Image 10: AI snake
### Challenge 3: Different maps and terrains To enrich the gameplay experience, we introduced several distinct map types: Swamp, Desert, and Teleport. Each map features unique terrain types and items, along with background color variations to enhance visual diversity. One of the major technical challenges was the terrain generation algorithm. For the swamp and desert regions, we employed a multi-layered Perlin noise approach combined with angular perturbations to produce irregular yet natural-looking organic boundaries. To further enhance the smoothness and visual appeal of these shapes, we applied cubic smoothing techniques and point displacement. The generation of such irregular regions requires both precision in graphical algorithms and a balance between real-time performance and layout diversity, while avoiding overlapping terrain or unreasonable map configurations. Another significant programming difficulty lies in the gameplay mechanics influenced by terrain. For example, when a snake enters a swamp or desert area, its movement speed is significantly reduced. Implementing this behavior necessitates real-time detection of whether the snake's head is within a complex polygon. To achieve this, we implemented a point-in-polygon collision detection algorithm, which involves ray casting and geometric computations. Although the logic is complex, it must operate efficiently to maintain game responsiveness. Additionally, the teleportation system posed a considerable technical challenge. Each teleport portal is randomly paired with a target location. When the snake enters a portal, its entire body must be repositioned to the corresponding target portal while preserving its current movement direction. A cooldown mechanism is also implemented to prevent immediate reactivation. To enhance player feedback and immersion, the teleportation process is accompanied by particle explosion effects, which must be precisely synchronized with the interaction logic to ensure seamless gameplay.
Image 11: Teleport
# 6. Evaluation ### Heuristic Evaluation The evaluation team conducted a comprehensive review of the Snake game, identifying multiple issues and scoring them by severity based on Nielsen's usability principles:Interface | Issue | Heuristic | Frequency | Impact | Persistence | Severity |
---|---|---|---|---|---|---|
Starting | Lack a description of gameplay mechanics, level selection, and the option to choose between single-player and multiplayer modes | Help and Documentation | 3 | 3 | 4 | 3.33 |
Gaming | Ai Snake won't die when it touches the player | Consistency and standards | 4 | 2 | 3 | 3 |
Gaming | Unable to pause the game and unable return to previous step | User control and freedom | 3 | 2 | 3 | 2.67 |
Ending | Lack of winning conditions | Consistency and standards | 2 | 4 | 2 | 2.67 |
Gaming | Lack of sufficient game feedback to players | Visibility of System Status | 2 | 3 | 3 | 2.67 |
Gaming | Background and player snake visually synchronized | Aesthetic and minimalist design | 3 | 1 | 2 | 2 |
Gaming | Restarting the game doesn't not clear the score | Consistency and standards | 1 | 1 | 1 | 1 |
Image 12: github
**2. Temporary Google Shared Document** We used a Shared Document to record outcomes from lab discussions, as well as ideas and task distributions discussed during each meeting. The shared document allowed real-time viewing and editing, greatly improving collaboration efficiency and transparency. **3. Kanban Board** Project management was mainly conducted using our [Kanban board](https://yiqing.atlassian.net/jira/software/projects/DP/summary). Yiqing was responsible for updating task statuses on a weekly basis, which included the categories “To Do,” “In Progress,” and “Completed.” Our team started working on the project in Week 6, which was relatively late compared to other groups, giving us a tighter schedule. The Kanban board helped us stay organized and on track under pressure. Weekly deadlines were set for Monday so that we could learn new topics in Tuesday’s lab session and then assign new tasks after class.
Image 13: kanban
**4. Online Meeting and WeChat Group** Most of our regular discussions took place online using Tencent Meeting. Screen sharing was frequently used to collaboratively debug. We also created a WeChat group, which served as the main channel for quick updates, Q&A, and file sharing. It played a key role in maintaining fast and effective communication. ### Reflection Looking back on the entire project process, our team demonstrated a high level of collaboration efficiency, with well-organized task allocation and effective progress management, resulting in the successful development of an ideal game. Each member made significant contributions and fully experienced the complete cycle of project development. # 8. Sustainability, ethics and accessibility ### Environmental Impact Our *Snake Rival* game demonstrates strong environmental sustainability through several key design choices and technical implementations. **Energy Efficiency:** We have implemented multiple green software patterns to minimize energy consumption. The game uses `frameRate(30)` to cap rendering at 30 frames per second, significantly reducing unnecessary CPU/GPU cycles while maintaining smooth gameplay. This can lower energy usage by up to 40% compared to uncapped frame rates. AI snakes are reused after death instead of being recreated, minimizing memory allocation and garbage collection cycles. This reduces the high energy cost of frequent object creation and destruction. Centralized managers for food, obstacles, and power-ups (Singleton Resource Managers) prevent redundant resource allocations, improving memory efficiency. **Carbon Awareness:** Although currently a local offline game, we’ve designed the architecture to support future carbon-aware features. These include a potential “Green Mode” that adjusts graphical fidelity based on the local grid’s carbon intensity, dynamic performance scaling to reduce energy usage during high-carbon periods, and zero data transmission by avoiding online features and logins. **Resource Optimization:** Our web-based implementation using **p5.js** ensures no physical materials or distribution logistics are required. It supports adaptive rendering based on device capabilities and has been tested on Windows, Linux, and Android. Additionally, efficient collision detection algorithms (for food, power-ups, AI snakes, obstacles, and boundaries) help reduce computational load. ### Individual Impact Our game prioritizes player health and well-being through multiple user-friendly design elements. **Health Considerations:** Customizable snake colors and map themes reduce eye strain, with swamp and desert themes offering low-contrast, soothing palettes. Rich sound effects and background music enhance immersion without being overwhelming. Planned improvements include periodic health reminders and optional forced pauses to prevent overplay. **Privacy Protection:** We fully implement Privacy by Design principles. The game collects no personal data. No login, user account, or profile is required, no gameplay data is stored or tracked—each session starts fresh—and no third-party analytics or advertising tools are used. **Accessibility Features:** Current accessibility implementations include simple mouse-based controls suitable for all ages, clear visual and audio feedback for all in-game events, and two difficulty levels (Normal and Hard) to accommodate different skill levels. Planned improvements inspired by WCAG include a high-contrast mode or maps for visually impaired players and screen reader compatibility for navigating menus. ### Social Impact Though primarily a single-player experience, our game design also considers broader social factors. **Inclusivity:** There are no language barriers as gameplay is fully visual and menus use basic English. There are no cultural references, as the snake protagonist is universal and inclusive. There are no competitive elements, removing negative social pressure, and no age-restricted or inappropriate content, making it safe for all ages. **Educational Value:** The game enhances hand-eye coordination and strategic thinking for players. For developers, the clean code structure showcases sustainable software architecture. It also highlights responsible use of environmental assets, such as swamp and desert ecosystems. ### Ethical Considerations We’ve addressed several ethical concerns during the game’s design process. **Algorithmic Fairness:** AI snakes operate on simple, transparent rules with no opaque machine learning or hidden difficulty adjustments that could cause frustration. **Responsible Design:** The game contains no addictive mechanics or variable reward loops. Win/lose conditions are clearly defined, with each session limited to a maximum of 120 seconds. There is no monetization or in-app purchases that could exploit players. **Transparency:** All game mechanics are intuitive and explained through gameplay. Basic instructions are available via the in-game Help screen, and the open-source code makes all implementation logic fully inspectable. ### Conclusion and Future Improvements Our *Snake Rival* game exhibits strong sustainability across environmental, individual, and social dimensions. Even as a simple game, it embraces thoughtful green software practices. **Key Strengths:** The game achieves excellent energy efficiency through frame rate limiting and object reuse. Privacy is built-in from the ground up, with no data collection or accounts. Accessibility is already supported at a baseline level, with plans for further expansion. The game is ethically designed, with no manipulation or monetization. **Planned Enhancements:** We plan to add dynamic performance scaling across devices (PC, tablet, mobile), local multiplayer support without requiring internet connectivity, and an extension of carbon-aware features as needed. This project shows that even small games can be built with sustainability in mind. The green software patterns applied here are practical, effective, and adaptable—setting an example for responsible game development. # 9. Conclusion The Snake Rival game project marks a significant milestone in our academic and professional development, demonstrating both technical achievement and collaborative growth within our four-member team—Yiqing Zhou, Xing Yang, Cheng Wang, and Jiayi Lin. Beginning as a simple snake game prototype, the project gradually evolved into a feature-rich, engaging gaming experience through the integration of AI opponents, multiple map environments, power-up systems, and sophisticated collision mechanics. This transformation challenged us to effectively apply object-oriented programming principles, establishing structured class hierarchies for different snake types (PlayerSnake, AISnake, AutoSnake) and managing key game elements through dedicated managers such as FoodManager, ObstacleManager, and ItemManager. Throughout this process, we not only enhanced our programming skills but also deepened our understanding of software engineering practices, iterative development, and team coordination. Our success stemmed from the complementary skill sets within the team and the clear distribution of responsibilities. Yiqing Zhou took on the role of project leader, ensuring that tasks were well-coordinated and project milestones met. Xing Yang focused on debugging and the technical implementation of core game mechanics and collision systems, while Cheng Wang designed item systems and power-up mechanics that gave the game its distinctive variety and strategy. Jiayi Lin contributed through visual design, creating user interface components, visual effects, and enhancing the overall user experience. We adopted an agile workflow, holding weekly stand-up meetings and managing our codebase through GitHub. This structure allowed us to break down the project into manageable components, assign tasks based on individual strengths, conduct regular code reviews, and merge features systematically. Through this, we gained valuable lessons about clear communication, constructive feedback, balancing creative ideas with technical feasibility, and maintaining consistent coding standards within a collaborative environment. Technically, several challenges tested our problem-solving abilities and resilience. AI pathfinding was one of the most difficult aspects, requiring intelligent behavior for AI-controlled snakes that could navigate the environment effectively, pursue food, avoid obstacles, and react dynamically to other snakes. Our final approach combined food targeting with obstacle avoidance, predictive collision detection, and behavioral state machines. Performance optimization was another key area, where we addressed frame rate drops by implementing object pooling for AI snakes, setting frame rate limits, and using efficient collision detection algorithms. The development of a multi-map system also introduced complexity, as each environment—Default, Swamp, Desert, and Portal—needed distinct mechanics, unique visual elements, and consistent physics behavior. Managing different game states, such as the main menu, gameplay, pause, and game over, required careful event handling and logical state transitions, which taught us the importance of comprehensive testing and prototyping. Beyond technical challenges, this project provided invaluable professional development experiences. We learned the importance of writing modular, well-documented code that could be easily understood and maintained by others. Using Git effectively for collaborative development, resolving merge conflicts, and performing code reviews became essential habits. Balancing this project alongside other coursework taught us to set realistic milestones, prioritize critical path features, and allocate buffer time for debugging. Additionally, we implemented a quality assurance process through peer code reviews, organized playtesting sessions, and incorporated automated testing where feasible. User experience emerged as a key focus, with feedback from playtesters leading to refinements in difficulty progression, visual feedback, and control responsiveness. Looking ahead, we have identified several future improvement opportunities. Technically, adding networked multiplayer functionality, procedural map generation, a replay/spectator system, and additional AI behavior patterns would significantly enhance the game’s depth and replayability. In terms of content, expanding map themes, introducing new environmental effects, adding power-up types, and offering customizable snake skins could further enrich the player experience. Performance optimization could also be refined through techniques like spatial partitioning and implementing Level of Detail (LOD) systems. We also recognize the importance of accessibility, and future versions of the game could benefit from colorblind modes, adjustable control schemes, and customizable difficulty settings. In conclusion, the Snake Rival project transformed our understanding of game development and software engineering, highlighting that successful projects require far more than just technical expertise. Effective communication, the ability to explain complex technical concepts, openness to integrating diverse ideas, and persistence in debugging complex systems all proved equally vital. We learned how to balance creative vision with practical constraints, and how teamwork can produce results that exceed the sum of individual contributions. This project served as a valuable practical application of our coursework in Software Engineering Discipline and Practice, reinforcing core principles while challenging us to address real-world development problems. The lessons we gained in collaborative development, systematic problem-solving, and maintaining user-focused design will undoubtedly benefit us as we continue our studies and pursue future professional opportunities. # 10. References ### Contribution Statement