This project is meant to make you code a digital version of an ant farm

lem-in

Authors: Rik0 and Alika96

How to run

  • Type go run. [name_of_file]
  • Example: go run . example01.txt
  • Or type /bin/bash test.sh for testing every example

Algorithm

  1. We used Breadth First Search(BFS, Поиск в ширину) method for finding all the shortest paths in a graph.
  2. Then we used Bhandari algorithm, which is based on Suurballe's original algorithm, for finding edge-disjoint paths through a graph.
  3. After that knowing the paths the program decides in which path ants will go through.
  4. Then the program decides which algorithm is faster and outputs the answer.

Objectives

This project is meant to make you code a digital version of an ant farm.

Create a program lem-in that will read from a file (describing the ants and the colony) given in the arguments.

Upon successfully finding the quickest path, lem-in will display the content of the file passed as argument and each move the ants make from room to room.

How does it work?

  • You make an ant farm with tunnels and rooms.
  • You place the ants on one side and look at how they find the exit.

You need to find the quickest way to get n ants across a colony (composed of rooms and tunnels).

  • At the beginning of the game, all the ants are in the room ##start. The goal is to bring them to the room ##end with as few moves as possible.
  • The shortest path is not necessarily the simplest.
  • Some colonies will have many rooms and many links, but no path between ##start and ##end.
  • Some will have rooms that link to themselves, sending your path-search spinning in circles. Some will have too many/too few ants, no ##start or ##end, duplicated rooms, links to unknown rooms, rooms with invalid coordinates and a variety of other invalid or poorly-formatted input. In those cases the program will return an error message ERROR: invalid data format. If you wish, you can elaborate a more specific error message (example: ERROR: invalid data format, invalid number of Ants or ERROR: invalid data format, no start room found).

You must display your results on the standard output in the following format :

number_of_ants
the_rooms
the_links

Lx-y Lz-w Lr-o ...
  • x, z, r represents the ants numbers (going from 1 to number_of_ants) and y, w, o represents the rooms names.

  • A room is defined by "name coord_x coord_y", and will usually look like "Room 1 2", "nameoftheroom 1 6", "4 6 7".

  • The links are defined by "name1-name2" and will usually look like "1-2", "2-5".

Here is an example of this in practice :

##start
1 23 3
2 16 7
#comment
3 16 3
4 16 5
5 9 3
6 1 5
7 4 8
##end
0 9 5
0-4
0-6
1-3
4-3
5-2
3-5
#another comment
4-2
2-1
7-6
7-2
7-4
6-5

Instructions

  • You need to create tunnels and rooms.
  • A room will never start with the letter L or with # and must have no spaces.
  • You join the rooms together with as many tunnels as you need.
  • A tunnel joins only two rooms together never more than that.
  • A room can be linked to an infinite number of rooms and by as many tunnels as deemed necessary.
  • Each room can only contain one ant at a time (except at ##start and ##end which can contain as many ants as necessary).
  • To be the first to arrive, ants will need to take the shortest path or paths. They will also need to avoid traffic jams as well as walking all over their fellow ants.
  • You will only display the ants that moved at each turn, and you can move each ant only once and through a tunnel (the room at the receiving end must be empty).
  • The rooms names will not necessarily be numbers, and in order.
  • Any unknown command will be ignored.
  • The program must handle errors carefully. In no way can it quit in an unexpected manner.
  • The coordinates of the rooms will always be int.
  • Your project must be written in Go.
  • The code must respect the good practices.
  • It is recommended that the code should present a test file.

Allowed packages

  • Only the standard Go packages are allowed.

Usage

Example 1 :

$ go run . test0.txt
3
##start
1 23 3
2 16 7
3 16 3
4 16 5
5 9 3
6 1 5
7 4 8
##end
0 9 5
0-4
0-6
1-3
4-3
5-2
3-5
4-2
2-1
7-6
7-2
7-4
6-5

L1-3 L2-2
L1-4 L2-5 L3-3
L1-0 L2-6 L3-4
L2-0 L3-0
$

Example 2 :

$ go run . test1.txt
3
##start
0 1 0
##end
1 5 0
2 9 0
3 13 0
0-2
2-3
3-1

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

Example 3 :

$ go run . test1.txt
3
2 5 0
##start
0 1 2
##end
1 9 2
3 5 4
0-2
0-3
2-1
3-1
2-3

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

Bonus

  • As a bonus you can create an ant farm visualizer that shows the ants moving trough the colony.
    • Here is an usage example : ./lem-in ant-farm.txt | ./visualizer

    • The coordinates of the room will be useful only here.

This project will help you learn about :

  • Algorithmic
  • Ways to receive data
  • Ways to output data
  • Manipulation of strings
  • Manipulation of structures
Similar Resources

PHP functions implementation to Golang. This package is for the Go beginners who have developed PHP code before. You can use PHP like functions in your app, module etc. when you add this module to your project.

PHP Functions for Golang - phpfuncs PHP functions implementation to Golang. This package is for the Go beginners who have developed PHP code before. Y

Dec 30, 2022

A codename generator meant for naming software releases.

codename-generator This library written in Golang generates a random code name meant for naming software releases if you run short of inspiration. Cur

Jun 26, 2022

ant (alpha) is a web crawler for Go.

The package includes functions that can scan data from the page into your structs or slice of structs, this allows you to reduce the noise and complexity in your source-code.

Dec 30, 2022

beego 与 Ant Design Pro Vue 基础权限系统

beego Ant Design Pro Vue RBAC beego 与 Ant Design Pro Vue 基础权限系统 后端: http://beego.me ORM: gorm https://gorm.io/zh_CN/docs/ Ant Design Pro Vue文档: https:

Dec 2, 2022

The official container networking plugin for both OECP of Alibaba Cloud and SOFAStack of Ant Financial Co.

Rama What is Rama? Rama is an open source container networking solution, integrated with Kubernetes and used officially by following well-known PaaS p

Dec 29, 2022

基于go-kratos +Ant Design Pro的前后端分离微服务管理系统后端模块

基于go-kratos +Ant Design Pro的前后端分离微服务管理系统后端模块

项目前端是基于Ant Design Pro来创建的,后端是基于go-kratos来创建的一个前后端分离的管理系统

Nov 24, 2022

A BPMN engine, meant to be embedded in Go applications with minim hurdles, and a pleasant developer experience using it.

A BPMN engine, meant to be embedded in Go applications with minim hurdles, and a pleasant developer experience using it. This approach can increase transparency for non-developers.

Dec 29, 2022

Incomplete CRUD/RBAC service meant to be a practice for Go

Incomplete CRUD / RBAC Service in Go The repository name means nothing. But your task is to complete this repository on your own to be a functional CR

Nov 9, 2021

HellPot is a portal to endless suffering meant to punish unruly HTTP bots.

HellPot is a portal to endless suffering meant to punish unruly HTTP bots.

HellPot Summary HellPot is an endless honeypot based on Heffalump that sends unruly HTTP bots to hell. Notably it implements a toml configuration file

Jan 2, 2023

Simple Go/Chi powered http server meant for ad hoc use such as exposing a file system for testing HTML.

httphere httphere is a simple Go/Chi powered http server for ad hoc use such as testing HTML or temporarily exposing a local file system at the curren

Dec 10, 2021

Ant Chain CAFECMDB SDK for Go

English | 简体中文 Ant Chain CAFECMDB SDK for Go Requirements It's necessary for you to make sure your system have installed Go environment which version

Dec 2, 2021

A minimalistic LDAP server that is meant for test vulnerability to JNDI+LDAP injection attacks in Java, especially CVE-2021-44228.

jndi-ldap-test-server This is a minimalistic LDAP server that is meant for test vulnerability to JNDI+LDAP injection attacks in Java, especially CVE-2

Oct 3, 2022

Ant Chain COMMERCIALEXTERNAL SDK for Go

English | 简体中文 Ant Chain COMMERCIALEXTERNAL SDK for Go Requirements It's necessa

Dec 24, 2021

Account - Ant Chain ACCOUNT SDK for Go

English | 简体中文 Ant Chain ACCOUNT SDK for Go Requirements It's necessary for you

Jan 13, 2022

A minimal Crossplane Provider that is meant to be used as a template for implementing new Providers

provider-template provider-template is a minimal Crossplane Provider that is meant to be used as a template for implementing new Providers. It comes w

Jan 16, 2022

A tool to determine the highest version number that's smaller than a target version number

semver-highest A tool to determine the highest version number that's smaller than a target version number. Installation go install github.com/marten-s

Oct 13, 2021

Parallel Digital Universe - A decentralized identity-based social network

Parallel Digital Universe Golang implementation of PDU. What is PDU? Usage Development Contributing PDU PDU is a decentralized identity-based social n

Nov 20, 2022

Digital Signal Processing for Go

GO-DSP go-dsp is a digital signal processing package for the Go programming language. Packages dsputils - utilities and data structures for DSP fft -

Jan 3, 2023

Go Hosting Solution for AWS, Google Could and Digital Ocean

Go Hosting Solution for AWS, Google Could and Digital Ocean

Furnace Intro Brief Explanation Here is a very short description of what Furnace does in a handy IKEA manual format. In More Depth AWS Cloud Formation

Jan 3, 2023
xyr is a very lightweight, simple and powerful data ETL platform that helps you to query available data sources using SQL.

xyr [WIP] xyr is a very lightweight, simple and powerful data ETL platform that helps you to query available data sources using SQL. Supported Drivers

Dec 2, 2022
Dud is a lightweight tool for versioning data alongside source code and building data pipelines.

Dud Website | Install | Getting Started | Source Code Dud is a lightweight tool for versioning data alongside source code and building data pipelines.

Jan 1, 2023
ANT, ANT+, ANT-FS library and ANT-USB driver written in Go

go-ant ANT, ANT+, ANT-FS library and ANT-USB driver written in Go Instalation Install with: go get -u github.com/purpl3F0x/go-ant Import to project im

Dec 7, 2021
Go-ant-pattern: An ant pattern parser

go-ant-pattern - An ant pattern parser. Usage package main import ( "fmt" "github.com/cbuschka/go-ant-pattern" ) func main() { path := "

Dec 7, 2021
Tdtl - TKeel Digital Twins Language (TDTL) is language of Digital Twins in tKeel

TQL TKeel Digital Twins Language (TDTL) is language of Digital Twins in tKeel, w

Feb 18, 2022
Simple script for farm free books from PackPub.com

Bookgot BookGot is a simple boot for farm free books from PACKTPUB.COM #Install go get -u github.com/bregydoc/Bookgot Usage First import BookGot //..

Mar 26, 2019
Bump-version - Bump a given semantic version, following a given version fragment

bump-version Bump a given semantic version, following a given version fragment.

Feb 7, 2022
Golang project for looking up geo from an IP. Meant to be deployed on Render.

geoip-render-go Golang project for looking up geo from an IP. Meant to be deployed on Render. Dependencies In order to use this project, you'll need a

Dec 6, 2021
A simple download file manager that sorts your files into your desired folders, This was meant to be a small project and nothing big.

GoDFM Simply go to the tags and download the .exe file (or compile it yourself by running go build). Add it to your environment paths by going to sett

Aug 9, 2022
Go decoder for EU Digital COVID Certificate (EUDCC) QR code data

Go Corona QR Code Decoder This repository contains a decoder for EU Digital COVID Certificate (EUDCC) QR code data, written in Go. If you got vaccinat

Nov 30, 2022