Skip to content

Commit

Permalink
begin body development interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
julien.rodriguez-tao committed Oct 21, 2017
1 parent fd0388a commit 0dc160d
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(LIBS)

add_definitions(-std=c++11)
add_definitions(-D_USE_MATH_DEFINES) # Use math definitions (M_PI, etc...)
add_definitions(-Wall -Wextra -Werror) # Display all warnings, mark warnings as error
add_definitions(-O3 -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long$(THREADSCXXFLAGS)) # Display all warnings, mark warnings as error

if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DDEBUG)
Expand Down
10 changes: 9 additions & 1 deletion cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
#define CELL_H


#include "linkcell.h"

class Cell
{
public:

vector<LinkCell> stator;
vector<LinkCell> rotor;



Cell();
};

#endif // CELL_H
#endif // CELL_H
10 changes: 10 additions & 0 deletions cellmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ CellManager::CellManager()
{

}

int CellManager::TranslateHLCode(GeneticBase *gb, int pos)
{
return TranslateLLCode(gb,pos);
}

int CellManager::generateBody(GeneticData cg)
{
return 1;
}
11 changes: 10 additions & 1 deletion cellmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
#define CELLMANAGER_H

#include "cell.h"
#include "geneticdata.h"

class CellManager
class CellManager : public GeneticLowlevelGrammar
{
public:

vector<Cell> nodes;

CellManager();

int TranslateHLCode(GeneticBase *gb, int pos);


int generateBody (GeneticData cg);
};

#endif // CELLMANAGER_H
6 changes: 6 additions & 0 deletions geneticdata.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "geneticdata.h"

GeneticData::GeneticData()
{

}
68 changes: 68 additions & 0 deletions geneticdata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef GENETICDATA_H
#define GENETICDATA_H

#include <vector>
#include <deque>
#include <stdint.h>
#include <stddef.h>
using namespace std;

#define NCMD 4

class GeneticBase
{
public:
int8_t *data;
uint8_t size;

GeneticBase() {data=NULL;}
GeneticBase(int8_t *_data, uint8_t _size) : data(_data),size(_size) {}
};

class GeneticData
{
public:

deque<GeneticBase> data;

GeneticData();

};

class GeneticLowlevelGrammar
{
public :

GeneticLowlevelGrammar()
{
}

int TranslateLLCode(GeneticBase *gb, int pos)
{
switch (gb->data[0])
{
case 0://end transcription
{
return 256;
}
break;

case 1://test and branch instruction
{
if (pos<*(gb->data+1))
return *(gb->data+2);
else
return 1;
}
break;

default: //high level command
return 1;
break;
}

}

};

#endif // GENETICDATA_H
6 changes: 6 additions & 0 deletions linkcell.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "linkcell.h"

LinkCell::LinkCell()
{

}
15 changes: 15 additions & 0 deletions linkcell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef LINKCELL_H
#define LINKCELL_H

#include <vector>
using namespace std;

class LinkCell
{
public:
LinkCell();


};

#endif // LINKCELL_H
7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <GL/glu.h>
#include <GL/gl.h>

#include "cellmanager.h"

CellManager cellmanager;

void renderScene() // this function is called when you need to redraw the scene
{
Expand Down Expand Up @@ -93,6 +95,11 @@ void reshapeScene(int w, int h)

void init() // called to glEnable features or to init display lists
{

cellmanager.generateBody(GeneticData());



glEnable(GL_DEPTH_TEST); // to enable when you draw in 3D
}

Expand Down

0 comments on commit 0dc160d

Please sign in to comment.