| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #ifndef CPROGRAM_H
- #define CPROGRAM_H
- #include <array>
- #include <vector>
- #include <memory>
- #include <climits>
- #include <stdint.h>
- #include <QColor>
- 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> team;
- vector<Instruction> instructions;
- Bank(shared_ptr<Team> team, const vector<Instruction>& 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<Bank> 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> team;
- Position position;
- vector<Task> tasks;
- TaskIndex taskIndex = 0;
- vector<shared_ptr<Bank>> banks;
- array<int32_t, 20> 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> team, Direction direction, Position position, int32_t instructionSet, int32_t slotCount, int32_t mobile);
- };
- #endif // CPROGRAM_H
|