source: cpp/frams/genetics/f9/f9_conv.h @ 1187

Last change on this file since 1187 was 1157, checked in by Maciej Komosinski, 3 years ago

Improved f9 mutation

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _F9_CONV_H_
6#define _F9_CONV_H_
7
8#include <ctype.h>
9#include <common/nonstd_math.h>
10#include <frams/model/modelparts.h>
11#include <frams/util/multimap.h>
12#include <frams/util/sstring.h>
13#include <frams/genetics/genoconv.h>
14#include <vector>
15using std::vector;
16
17
18extern const char* turtle_commands_f9;
19extern int turtle_commands_f9_count;
20
21
22struct XYZ_LOC
23{
24        int x, y, z; //coordinates xyz of a vertex - represented as int's so that it is easy and safe to check identity. Could also be done using lists of Model's Parts, but that would involve comparing floats
25        XYZ_LOC() { x = y = z = 0; }
26        void add(int delta[3]) { x += delta[0]; y += delta[1]; z += delta[2]; }
27        bool same_coordinates(const XYZ_LOC &loc) { return x == loc.x && y == loc.y && z == loc.z; }
28};
29
30
31// The f9->f0 converter
32class GenoConv_f90 : public GenoConverter
33{
34public:
35        GenoConv_f90();
36
37        //implementation of the GenoConverter method
38        SString convert(SString &in, MultiMap *map, bool using_checkpoints);
39
40protected:
41        //auxiliary methods
42        int addSegment(Model &m, int genenr, vector<XYZ_LOC> &vertices, const XYZ_LOC &new_vertex, int recently_added);
43        int findVertexAt(vector<XYZ_LOC> &vertices, const XYZ_LOC &new_vertex);
44        int addNewVertex(Model &m, vector<XYZ_LOC> &punkty, const XYZ_LOC &nowypunkt);
45        void setColors(Model &m, int last_added_part); //sets fixed (independent from genes) colors and widths on a model, purely for aesthetic purposes
46        void perturbPartLocations(Model &m); //deterministic "body noise", see APPLY_DETERMINISTIC_BODY_NOISE
47};
48
49#endif
Note: See TracBrowser for help on using the repository browser.