#ifndef CPROGRAM_H #define CPROGRAM_H #include #include #include #include #include #include using namespace std; #include "instruction.h" enum Direction { Right, Down, Left, Up, }; struct Position { size_t x = 0; size_t y = 0; Position() : x(0) , y(0) {} Position(size_t _x, size_t _y) : x(_x) , y(_y) {} Position(const Position& _pos) : x(_pos.x) , y(_pos.y) {} }; struct Team { int32_t programCount = 0; int32_t id = 0; int32_t var = 0; QColor color = Qt::red; Team(QColor color) : programCount(0) , color(color) , id(rand()) , var(0) { } }; struct Bank { shared_ptr team; vector instructions; Bank(shared_ptr team, const vector& instructions) : team(team) , instructions(instructions) { } Bank(const Bank& bank) : team(bank.team) , instructions(bank.instructions) { } }; using BankIndex = size_t; using InstIndex = size_t; using TaskIndex = size_t; struct Task { bool paused = false; Direction direction = Right; BankIndex bankIndex = 0; InstIndex instIndex = 0; int remainingCycles = 0; shared_ptr execBank; int32_t a = 0; int32_t b = 0; int32_t c = 0; int32_t* var_a = nullptr; int32_t* var_b = nullptr; int32_t* var_c = nullptr; }; struct Program { int active = 0; int instructionSet = 0; int mobile = 0; int creationCycle = 0; int generation = 0; Error error = NoError; shared_ptr team; Position position; vector tasks; TaskIndex taskIndex = 0; vector> banks; array vars{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; Program(shared_ptr team, Direction direction, Position position, int32_t instructionSet, int32_t slotCount, int32_t mobile); }; #endif // CPROGRAM_H