TopVar[0] TopVar[1] TopVar[2] TopVar[3] Vektator -> [0.. (2 byte index) V [t1_A, t1_B, t2_Z, t2_Y, t2_U] // flottánként van a vektátor memóriaterület, ha túl sok, nem engedünk játszani enum BYTEKIND { IGNORE, NIL, NUMBER, INPUT, OUTPUT, OPCODE, ENGINE, HARDWARE, COMM, }; void f(game_state *gs, ship_tile *st, uint8_t byte_code[4], int byte_index); bool validate(uint8_t *byte_code, byte_code_element *byte_info) { if (bk <= OUTPUT) return true; bool ok = true; for (int i = 1; i < 4; ++i) { switch(byte_info->at(i)) { case IGNORE: return true; case NUMBER: ok &= validate_number(byte_code[i]); case OUTPUT: ok &= validate_variable(byte_code[i]); case INPUT: ok &= (validate_number(byte_code[i]) || validate_variable(byte_code[i])); case HARDWARE: ok &= hardwares.find(byte_code[i]) != hardwares.end(); } } return true; } #define LEVEL 0 {OPCODE, "HULL", 'H', hull, NUMBER, NUMBER, NUMBER}, // HULL - first command {OPCODE, "PAR", 'p', par, OUTPUT, NUMBER, NUMBER}, // PAR after HULL, before actual code {OPCODE, "MUL", '*', mul}, {OPCODE, "ADD", '+', add}, {OPCODE, "ENGINE", 'e', nextbyte?, ENGINE, IGNORE, IGNORE}, {OPCODE, "HW", 'h', nextbyte?, HARDWARE, IGNORE, IGNORE}, {OPCODE, "COMM", 'c', nextbyte?, COMM, IGNORE, IGNORE}, #define LEVEL 1 // ENGINE - if multiple ones are set, we choose randomly from the options given {ENGINE, "north", 'N', NIL, NIL, IGNORE}, {"east", 'E'}, {"west", 'W'}, {"south", 'S'}, // HARDWARE {HARDWARE, "cannon", 'c', cannon, INPUT, INPUT, IGNORE}, // destroys target ("returns" bool) {"sonar", 's'}, // shows tile + mine (radar) {"tracer", 't'}, // ray-trace a line ("returns" bool), doesn't detect mines {"jumbler", 'j'}, // randomizes parameters on target {"disruptor", 'd'}, // counters cannons {"mine", 'm'}, // places a mine (on your tile) that activates after P1 turns. When active and hit, it explodes {"blow", 'b'}, // blows mines towards a line (move to the next tile that is hit by the line) (should start from the end, so multiple mines don't hit each other) // COMM {"write", 'w'}, // HW write (write a number to a ship-wide channel) {"read", 'r'}, // HW read (read a number from a ship-wide channel) {"gps", 'G'}, // HW gps (gets global coordinates) {"fwrite", 'W'}, // HW write (write a number to a fleet-wide channel) {"fread", 'R'}, // HW read (read a number to a fleet-wide channel) Anti-cheat (Peer-to-peer-re): Mérjük a játékerejét a játékosnak külön hostként és kliensként. A kettő aránya ideális esetben 1. Ha kisebb, akkor 1-re felhozzuk. Az hostol, akinek ezután kisebb (vagy valami valószínűségi alapon)