Hide and Seek

A theoretical game of Hide and Seek done by (hopefully) intelligent agents, as a 're-do' of a given assignment in the Artificial Intelligence course.

python

Previews

Preview image #1Preview image of project Hide and Seek

Warning!!!

This project is “abandoned” for the time being. I have no plans to continue this project!

Motivation

Originally, this was done for a project due in a course of Artificial Intelligence. But as I do it, I feel like it’s not a fun project to work on. So I deviated and started to redesign the project to be more fun and interesting. Starting the project, I had a goal in mind: to make this as a learning opportunity, and using what I studied in AIMA (Artificial Intelligence: A Modern Approach).

The original project requirements is here.

Overview

This project is a simulation of a game of Hide and Seek, where the hiders and seekers are intelligent agents. The hiders are tasked with hiding in the environment, while the seekers are tasked with finding the hiders. Only 1 seeker, though.

Project Structure Overview:

.
|-- src
    |-- agent.py
    |-- hide_and_seek.py
    |-- hider.py
    |-- seeker.py
    |-- map_state.py
    |-- vector2d.py
    |-- main.py
|-- maps
    |-- lX_mY.txt
    |-- ...

Where:

Structural Integrity

The map files are stored in the maps/lX_mY.txt directories (X being the target level and Y is the number of the map, this does not serve any purpose, just to split into levels and maps). It follows a common format:

<TIME>
<SEEKER_VISION> <SEEKER_MAX_STEP>
<HIDER_VISION> <HIDER_MAX_STEP>
<MAP>

Where:

Example Map
1000000000
3 1
0 0
.........................
................XX.......
................X........
..........X...X.X.XXXXXXX
..........X...X..........
XXXXXXXX..X...X..........
..........X...XXX........
...S......X.....X........
..........X.....X........
................X.......H

This map has a time limit of 1000000000, a seeker vision of 3, a seeker max step of 1, a hider vision of 0, and a hider max step of 0. The map is a 10x25 grid. All . cells are traversable.

The Game

The game is a simple simulation of states. The game is played in a 2D grid, where the agents can move in 8 directions (up, down, left, right, and diagonals). The agents have a vision range, which is the number of squares they can see around themselves. The agents can only see in a square around themselves, and they can only see the current state of the map, without knowing about opponents.

The game is played accordingly:

  1. Check if the game is over (time limit reached, or all hiders caught). If it is over, go to step 6.
  2. Tick the seeker. The seeker looks around itself, updates its internal state, and moves.
  3. Tick the game board. Check if the seeker overlaps any hiders, if it does, the hider is caught. Update the game board accordingly.
  4. Tick the hiders. The remaining hiders look around themselves, update their internal state, and move (if possible).
  5. The score and time is ticked. Score gets deducted by 1 for each step. Time gets incremented by 1 for each step. If the time limit is reached, the game is over. For each hider the seeker caught in this tick, the score gets increased by 20.
  6. Finished 1 state. Wait for next tick.

The game board is displayed with the following characters:

Seeker

A step is defined as a movement in any of the 8 directions, or staying in place. The seeker goes through 2 stages: perceive and accept.

Hider

Level 1 - Level 2

These two levels are basically the same, with the only difference being the number of hiders. In level 1, there is only 1 hider, while in level 2, there are multiples.

Demo

Level 3

Assuming, with similar configurations, this means the hider is a reverse-seeker. It wants to move to the coldest place possible, where the heatmap starts out to be hot. This is probably not it, as if the hider wants to move the shortest path too, the chance of it colliding with the seeker is very high.