Skip to content

Langton's Ant implementation for a university project. The project was created together with Martyna Kochalska (pyskaa0506)

License

Notifications You must be signed in to change notification settings

nesterova-p/LangtonsAnt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Langtron's Ant

This program simulates Langton's ant, a two-dimensional universal Turing machine characterized by a simple rule set that produces complex emergent behavior, as designed by Christopher Langton in 1986. The simulation features a customizable board, ant movement with optional obstacles.

Prerequisites

  • GCC Compiler

Compilation

To compile the program, navigate to the directory containing the source code files and execute the following command:

cc -o ant_simulation -std=c11 main.c ant_simulation.c board.c display.c input.c saving_to_file.c 

Usage

You can run the program using the following command:

./ant_simulation <rows> <columns> <iterations> <name_prefix> <initial_direction> -o <obstacle_percentage> -f <map_filename>

Where:

  • <rows>: The number of rows in the board.
  • <columns>: The number of columns in the board.
  • <iterations>: The number of moves for the ant.
  • <name_prefix>: Prefix for files that will store the generated boards.
  • <initial_direction>: The starting direction of the ant, which can be 'N' (North), 'S' (South), 'E' (East), or 'W' (West).
  • <obstacle_percentage>: The percentage of the board that will contain obstacles. If omitted, no obstacles will be created.
  • <map_filename>: The name of the file from which the board will be loaded. If this is not specified, a random board will be generated.

Example

./ant_simulation 10 10 215 test N

This command runs a simulation on a 10x10 board for 215 iterations. The generated files will have the prefix "file," the ant will begin facing North.

git config --global user.name nesterova-p

Result

Iteration 1

░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ▲ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░

Iterating in the middle of the program running

░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ◀ ░ █ ░ ░
░ ░ ░ ░ ░ ░ █ ░ █ ░
░ ░ ░ ░ █ ░ ░ ░ █ ░
░ ░ ░ █ ░ ░ ░ █ ░ ░
░ ░ █ ░ ░ █ ░ ░ ░ ░
░ ░ █ ░ ░ █ ░ ░ ░ ░
░ ░ ░ █ ░ ░ █ ░ ░ ░
░ ░ ░ ░ █ █ ░ ░ ░ ░

Iteration 215

░ █ █ █ ░ ░ ░ ░ █ ░
░ █ █ █ █ █ █ █ █ ░
░ ░ █ █ ░ █ ░ ░ █ ░
░ ░ █ ░ ░ ░ █ ░ █ █
░ █ ░ ░ █ █ ░ █ █ █
█ ▶ █ ░ ░ ░ ░ ░ █ ░
█ █ ░ ░ █ █ █ █ ░ ░

About

Langton's Ant implementation for a university project. The project was created together with Martyna Kochalska (pyskaa0506)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published