Add readme
This commit is contained in:
104
Readme.md
104
Readme.md
@@ -1,26 +1,90 @@
|
|||||||
|
# Treender
|
||||||
|
|
||||||
# Code style
|
A genetic algorithm visualization tool with interactive evolution simulation.
|
||||||
|
|
||||||
## Naming Conventions:
|
## Overview
|
||||||
- PascalCase:
|
|
||||||
- Functions
|
|
||||||
- Class names
|
|
||||||
- Struct names
|
|
||||||
|
|
||||||
- camelCase:
|
Treender is a C++ application that simulates genetic algorithms through an interactive visual interface. Users can observe and influence the evolution of digital organisms represented as visual patterns.
|
||||||
- Class attributes
|
|
||||||
- Class methods
|
|
||||||
- Struct attributes
|
|
||||||
- Variables
|
|
||||||
|
|
||||||
## Class Structure:
|
## Features
|
||||||
|
|
||||||
- Header (.h) Files:
|
- **Interactive Evolution**: Like/dislike organisms to guide evolution
|
||||||
- Declare public methods and attributes first, followed by private members.
|
- **Genetic Algorithm**: DNA-based reproduction with mutation
|
||||||
- Implementation (.cpp) Files:
|
- **Visual Representation**: Organisms displayed as colorful patterns
|
||||||
- Implement methods in the same order as declared in the corresponding header file.
|
- **Client-Server Architecture**: Separate app and server components
|
||||||
|
- **Cross-Platform**: Supports Web, Android, and Desktop platforms
|
||||||
|
|
||||||
## Include order
|
## Architecture
|
||||||
- Std
|
|
||||||
- local ( form inc dir )
|
```
|
||||||
- external raylib
|
Treender
|
||||||
|
├── app/ # Main application (Raylib + Dear ImGui)
|
||||||
|
├── server/ # TCP server for data management
|
||||||
|
├── shared/ # Shared code (DNA logic, networking)
|
||||||
|
├── external/ # Third-party libraries
|
||||||
|
└── data.db # SQLite database
|
||||||
|
```
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
### Application
|
||||||
|
- **Main Entry**: `app/src/main.cpp`
|
||||||
|
- **Core Class**: `App` class handles rendering, input, and evolution logic
|
||||||
|
- **Visualization**: Uses Raylib for graphics and Dear ImGui for UI
|
||||||
|
|
||||||
|
### Server
|
||||||
|
- **TCP Server**: Handles client connections and data persistence
|
||||||
|
- **Database**: SQLite for storing organism data and user preferences
|
||||||
|
- **Block Management**: Tracks warnings and blocked organisms
|
||||||
|
|
||||||
|
### Shared Library
|
||||||
|
- **DNA System**: Genetic algorithm implementation (`Dna.cpp`)
|
||||||
|
- **Networking**: TCP socket communication
|
||||||
|
- **Data Structures**: Shared between app and server
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
- CMake 3.10+
|
||||||
|
- C++17 compiler
|
||||||
|
- Raylib
|
||||||
|
- Dear ImGui
|
||||||
|
- SQLite3
|
||||||
|
|
||||||
|
### Build Instructions
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
## Running
|
||||||
|
|
||||||
|
1. Start the server:
|
||||||
|
```bash
|
||||||
|
./build/server
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run the application:
|
||||||
|
```bash
|
||||||
|
./build/app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
- **Like/Disike**: Click on organisms to influence evolution
|
||||||
|
- **Rotation**: Drag to rotate the view
|
||||||
|
- **Statistics**: View similarity scores and generation information
|
||||||
|
|
||||||
|
## Database
|
||||||
|
|
||||||
|
The application uses SQLite database (`data.db`) to store:
|
||||||
|
- Organism DNA data
|
||||||
|
- User preferences
|
||||||
|
- Blocked/warned organisms
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|||||||
BIN
pictures/capture_show_noraml.jpg
Executable file
BIN
pictures/capture_show_noraml.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
@@ -47,10 +47,13 @@ namespace sql
|
|||||||
int exec(sqlite3 *db, const char *sql, int (*callback)(void *, int, char **, char **), void *first_arg, char **errmsg);
|
int exec(sqlite3 *db, const char *sql, int (*callback)(void *, int, char **, char **), void *first_arg, char **errmsg);
|
||||||
int prepare_v2(sqlite3 *db, const char *zSql, int nByte, sqlite3_stmt **pStmt, const char **pzTail);
|
int prepare_v2(sqlite3 *db, const char *zSql, int nByte, sqlite3_stmt **pStmt, const char **pzTail);
|
||||||
int bind_int64(sqlite3_stmt *pStmt, int column, int64_t value);
|
int bind_int64(sqlite3_stmt *pStmt, int column, int64_t value);
|
||||||
|
int bind_blob(sqlite3_stmt*pStmt, int column, const void* data, int size);
|
||||||
int step(sqlite3_stmt *pStmt);
|
int step(sqlite3_stmt *pStmt);
|
||||||
int column_count(sqlite3_stmt *pStmt);
|
int column_count(sqlite3_stmt *pStmt);
|
||||||
int column_type(sqlite3_stmt *pStmt, int column);
|
int column_type(sqlite3_stmt *pStmt, int column);
|
||||||
int64_t column_int64(sqlite3_stmt *pStmt, int column);
|
int64_t column_int64(sqlite3_stmt *pStmt, int column);
|
||||||
|
const void* column_blob(sqlite3_stmt *pStmt, int column);
|
||||||
|
int64_t column_bytes(sqlite3_stmt* pStmt, int column);
|
||||||
int finalize(sqlite3_stmt *pStmt);
|
int finalize(sqlite3_stmt *pStmt);
|
||||||
int reset(sqlite3_stmt *pStmt);
|
int reset(sqlite3_stmt *pStmt);
|
||||||
int close(sqlite3 *db);
|
int close(sqlite3 *db);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class DnaDB
|
|||||||
public:
|
public:
|
||||||
void init(const char *db_name = "data.db");
|
void init(const char *db_name = "data.db");
|
||||||
void deinit();
|
void deinit();
|
||||||
|
|
||||||
std::vector<int64_t> getUserIds();
|
std::vector<int64_t> getUserIds();
|
||||||
int insertUser(int64_t id, int64_t max_gen);
|
int insertUser(int64_t id, int64_t max_gen);
|
||||||
int updateUser(int64_t id, int64_t max_gen);
|
int updateUser(int64_t id, int64_t max_gen);
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ namespace sql
|
|||||||
{
|
{
|
||||||
return sqlite3_bind_int64(pStmt, column, value);
|
return sqlite3_bind_int64(pStmt, column, value);
|
||||||
}
|
}
|
||||||
|
int bind_blob(sqlite3_stmt *pStmt, int column, const void *data, int size)
|
||||||
|
{
|
||||||
|
return sqlite3_bind_blob(pStmt, column, data, size, SQLITE_STATIC);
|
||||||
|
}
|
||||||
int step(sqlite3_stmt *pStmt)
|
int step(sqlite3_stmt *pStmt)
|
||||||
{
|
{
|
||||||
return sqlite3_step(pStmt);
|
return sqlite3_step(pStmt);
|
||||||
@@ -106,6 +110,14 @@ namespace sql
|
|||||||
{
|
{
|
||||||
return sqlite3_column_int64(pStmt, column);
|
return sqlite3_column_int64(pStmt, column);
|
||||||
}
|
}
|
||||||
|
const void *column_blob(sqlite3_stmt *pStmt, int column)
|
||||||
|
{
|
||||||
|
return sqlite3_column_blob(pStmt, column);
|
||||||
|
}
|
||||||
|
int64_t column_bytes(sqlite3_stmt *pStmt, int column)
|
||||||
|
{
|
||||||
|
return sqlite3_column_bytes(pStmt, column);
|
||||||
|
}
|
||||||
int finalize(sqlite3_stmt *pStmt)
|
int finalize(sqlite3_stmt *pStmt)
|
||||||
{
|
{
|
||||||
return sqlite3_finalize(pStmt);
|
return sqlite3_finalize(pStmt);
|
||||||
|
|||||||
Reference in New Issue
Block a user