Skip to content

chinchay/hide-and-seek

Repository files navigation

Overview

The purpose of the hide-and-seek program is to bring entertainment through a simple game. It will integrate graphical and sound interfaces, event processing (keyboard and mouse), game logic, and network communication. This 2-dimensional game is inspired by the OpenAI research work where hiders and seekers compete to find new strategies and adapt to new situations. The game begins with sleeping seekers, allowing hiders to rearrange digital objects in their favor. As soon as seekers wake up, they start to look for the hiders and can create new strategies to find them. During the game, agents cannot see through objects, like blocks or walls so each player will see black areas rendered on the screen depending on the agent's position. The game ends when a hider is in the seeker's range of vision or when the seeker cannot find the hider after a certain time. This software also serves as a renderer for my next project on reinforcement learning.

How it works

The hide-and-seek program relies on PyGame. This code creates a platform game by using icons (or tile in the code) to build walls, movable blocks, and agents. An agent can be of type seeker or hider, and they respond to keyboard events. An agent cannot see through the walls or blocks, so a seeker will need to move ramps to see the other side of the wall, and hiders will need to use blocks smartly. Several features are still in development. The chart below shows an overview of the class relationships.

classDiagram
    Surface <|-- Tile
    Tile <|-- FixedTile
    Tile <|-- MovableTile
    MovableTile <|-- ActedObject
    MovableTile <|-- Agent
    ActedObject <|-- Cube
    ActedObject <|-- Ramp
    Agent <|-- Hider
    Agent <|-- Seeker
Loading

When the user quits the program, it will automatically save hider and seeker moves (files seeker.txt and hider.txt). These files will be loaded and the previous game will be recreated and rendered on the screen at the beginning of the next session. Since the files are human-readable, this feature allows developers to experiment and can be used as a renderer for similar console/terminal-based games.

A demonstration of the software running and a walkthrough of the code can be found here.

How to use it

Assuming Python and pip are installed on your machine, clone this repository

$ git clone https://github.com/chinchay/hide-and-seek.git

and run the game

$ python game.py

Seeker will respond to keys ↑ (up move), ↓ (down move), ← (left move), → (right move), while hider will respond to Command + s (up move), x (down move), z (left move), and c (right move). At this stage, both hider and seeker are played in the same machine.

Development Environment

  • Editor: Visual Studio Code
  • Language: Python 3.10.5
  • Version control system: Git
  • Cloud repository: GitHub
  • Python packages: PyGame

Pygame was chosen over Python Arcade because game rendering through a Docker container has been succesfully achieved via Pygame and XQuartz on a Mac machine. Future developments will include this feature.

Useful Websites

Video demonstrations

Simulate events

Buiding a map of tiles from file

For future development

Future work

  • Improve code performance to hide tiles behind walls or blocks
  • Implement ending game. The game should end when the hider is in the visible range of the seeker
  • Allow different machines to connect and play

Copyright and license

Code released under the MIT License

About

Play the hide-and-seek game!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published