Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Genetic Learning Algorithm (C)

A lightweight, bare-metal Genetic Algorithm implementation written in pure C. This project was developed to explore evolutionary computing principles, focusing on high-performance logic and cross-platform consistency.

Overview

This program simulates an evolutionary process where a population of "players" attempts to evolve a specific sequence of binary moves to match a target goal array. Unlike standard implementations that rely on OS-specific random libraries, this project implements a custom Xorshift32 pseudo-random number generator to ensure identical behavior across different operating systems (Windows/Linux) and to maintain high performance in resource-constrained environments.

Technical Highlights

  • Bare-Metal Logic: Zero dependencies on external libraries (pure C standard library only).
  • Deterministic Randomization: Implemented a custom Xorshift32 algorithm to replace standard rand(), ensuring portability, speed, and better statistical distribution of bits.
  • Efficient Memory Management: Manual heap allocation and management (malloc/calloc/free) for dynamically sized populations and move sets.
  • Performance Focused: Built for scalability, utilizing bitwise operations and efficient sorting algorithms (qsort) to handle population evolution.

Project Structure

  • genetic_learning_algorithm.c: Core logic, evolution loop, and implementation of the Xorshift PRNG.
  • genetic_learning_algorithm.h: API definitions, data structures, and project configurations.
  • Makefile: Automates the build process for different environments.

Why this project?

This implementation demonstrates a deep understanding of:

  1. Memory safety: Manual heap management and avoiding memory leaks.
  2. Computational efficiency: Writing low-level logic that minimizes CPU cycles.
  3. Cross-platform development: Solving platform-specific inconsistencies in standard libraries through custom implementations.

Build & Run

Ensure you have gcc and make installed.

# Build the project
make

# Run the simulation
make run

# Clean build artifacts
make clean

About

A lightweight, bare-metal Genetic Learning Algorithm implemented in pure C, focusing on custom PRNG and evolutionary optimization

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages