Skip to content

mous1985/lem-in

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lem-in

Overview

Lem-in is a project that simulates an ant colony. The program finds the most efficient path for a group of ants to travel from a start room to an end room through a network of tunnels. The goal is to move all ants from the start to the end in the fewest possible moves, while following specific constraints.

How It Works

The program:

  1. Reads a file describing the ants and the colony (rooms and tunnels)
  2. Finds the optimal path(s) for ants to traverse from the start room to the end room
  3. Displays the content of the input file and each move the ants make

Rules & Constraints

  • All ants begin in the room marked as ##start
  • The goal is to bring all ants to the room marked as ##end
  • Each room can contain only one ant at a time (except ##start and ##end)
  • Each tunnel can only be used by one ant per turn
  • An ant can only move once per turn
  • The shortest path isn't always the simplest due to bottlenecks and traffic jams

Input Format

The input file must follow this structure:

  • First line: number of ants
  • Room definitions: name coord_x coord_y
  • Special rooms marked with ##start and ##end before their definition
  • Tunnel definitions: name1-name2
  • Comments: lines starting with # are ignored

Example:

3
##start
0 1 0
##end
1 5 0
2 9 0
3 13 0
0-2
2-3
3-1

Output Format

The program outputs:

  1. The complete input file
  2. The sequence of ant movements in the format: Lx-y where:
    • x is the ant number (1 to number_of_ants)
    • y is the room name

Example:

L1-2
L1-3 L2-2
L1-1 L2-3 L3-2
L2-1 L3-3
L3-1

Error Handling

The program handles various errors including:

  • Invalid number of ants
  • Missing start or end room
  • Duplicate room names
  • Links to non-existent rooms
  • Invalid room coordinates
  • Rooms with invalid names (cannot start with 'L' or '#')
  • Paths that don't connect start to end

When errors are encountered, the program outputs: ERROR: invalid data format or a more specific error message.

Usage

go run . [filename]

Example:

go run . test0.txt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages