diff --git a/include/stalker320/common.h b/include/stalker320/common.h index 51af7d2..295aa49 100644 --- a/include/stalker320/common.h +++ b/include/stalker320/common.h @@ -1,6 +1,8 @@ #ifndef __common_h #define __common_h +#define _Consume + #define min(a, b) (a < b ? a : b) #define max(a, b) (a > b ? a : b) diff --git a/include/stalker320/field/applicant.h b/include/stalker320/field/applicant.h index 7702c21..232b508 100644 --- a/include/stalker320/field/applicant.h +++ b/include/stalker320/field/applicant.h @@ -2,10 +2,8 @@ #define __applicant_h #include -#define _Consume -#define PROGRAM_LENGTH 256 -#define MEMORY_CAPACITY 32 - +#include +#include typedef struct applicant applicant; typedef unsigned char buffsz_t; typedef @@ -50,8 +48,8 @@ void applicantConnectBuffer(applicant* applicant, unsigned char* buffer, buffsz_ void applicantSetFlushCallback(void* caller, applicant* applicant, void (*flushcallback)(void* restrict receiver, struct applicant* restrict _applicant, int index)); unsigned char applicantGetTop(applicant* applicant); -unsigned char applicantGetMemoryCursor(applicant* applicant); -unsigned char applicantGetProgramCursor(applicant* applicant); +uint32_t applicantGetMemoryCursor(applicant* applicant); +uint32_t applicantGetProgramCursor(applicant* applicant); unsigned char applicantGetProgramAt(applicant* applicant, char at); unsigned char applicantGetMemoryAt(applicant* applicant, char at); unsigned char applicantGetHeatAt(applicant* applicant, char at); diff --git a/include/stalker320/field/bot.h b/include/stalker320/field/bot.h index 01d0d15..6c76712 100644 --- a/include/stalker320/field/bot.h +++ b/include/stalker320/field/bot.h @@ -36,11 +36,12 @@ bool botIsAlive(struct bot* bot); unsigned char botGetHp(struct bot* bot); unsigned char botGetHunger(struct bot* bot); int botGetSteps(struct bot* bot); -unsigned char botGetApplicantAccum(bot* bot); + unsigned char botGetApplicantTop(bot* bot); -unsigned char botGetApplicantMemoryCursor(bot* bot); unsigned char botGetOutputBuffer(bot* bot, int idx); -unsigned char botGetApplicantProgramCursor(bot* bot); + +uint32_t botGetApplicantMemoryCursor(bot* bot); +uint32_t botGetApplicantProgramCursor(bot* bot); unsigned char botGetApplicantProgramAt(bot* bot, int idx); unsigned char botGetApplicantMemoryAt(bot* bot, int idx); unsigned char botGetApplicantHeatAt(bot* bot, int idx); diff --git a/include/stalker320/field/config.h b/include/stalker320/field/config.h index 8931fd4..ec4f860 100644 --- a/include/stalker320/field/config.h +++ b/include/stalker320/field/config.h @@ -1,6 +1,8 @@ #ifndef __config_h #define __config_h +#define PROGRAM_LENGTH 1024 +#define MEMORY_CAPACITY 64 #define min(a, b) (a < b ? a : b) #define max(a, b) (a > b ? a : b) diff --git a/src/applicant.c b/src/applicant.c index b6a2909..9734c1a 100644 --- a/src/applicant.c +++ b/src/applicant.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -20,7 +21,7 @@ struct applicantContent { struct applicant { struct applicantContent content; uint8_t memory[MEMORY_CAPACITY]; - unsigned char programCursor, memoryCursor; + uint32_t programCursor, memoryCursor; unsigned char bufferCount; struct applicantFlags flags; int generation; @@ -82,6 +83,9 @@ applicant* createApplicant(applicant* src, bool mutate, bool zero) { if (src->content.heat[i] < 0x1F) { applicant->content.heat[i] = src->content.heat[i]; } + else { + applicant->content.heat[i] = src->content.heat[i] / 2; + } } } @@ -144,11 +148,11 @@ unsigned char applicantGetTop(applicant* applicant) { if (!applicant) return 0x00; return applicant->memory[(applicant->memoryCursor - 1) % MEMORY_CAPACITY]; } -unsigned char applicantGetMemoryCursor(applicant* applicant) { +uint32_t applicantGetMemoryCursor(applicant* applicant) { if (!applicant) return 0x00; return applicant->memoryCursor % MEMORY_CAPACITY; } -unsigned char applicantGetProgramCursor(applicant* applicant) { +uint32_t applicantGetProgramCursor(applicant* applicant) { if (!applicant) return 0x00; return applicant->programCursor % PROGRAM_LENGTH; } diff --git a/src/bot.c b/src/bot.c index 1180fcf..4d649e6 100644 --- a/src/bot.c +++ b/src/bot.c @@ -155,7 +155,7 @@ unsigned char botGetApplicantTop(bot* bot) { if (!bot) return 0x00; return applicantGetTop(bot->applicant); } -unsigned char botGetApplicantMemoryCursor(bot* bot) { +uint32_t botGetApplicantMemoryCursor(bot* bot) { if (!bot) return 0x00; return applicantGetMemoryCursor(bot->applicant); } @@ -163,7 +163,7 @@ unsigned char botGetOutputBuffer(bot* bot, int idx) { if (!bot) return 0x00; return bot->outputBuffer[idx % 1]; } -unsigned char botGetApplicantProgramCursor(bot* bot) { +uint32_t botGetApplicantProgramCursor(bot* bot) { if (!bot) return 0x00; return applicantGetProgramCursor(bot->applicant); }