Compare commits

..

2 Commits

2 changed files with 9 additions and 7 deletions

View File

@ -22,27 +22,27 @@ void Step(struct SS13ArcadeEnv* instance, const int action, struct Observation*
switch (action) {
case 0: // Attack
instance->enemy_hp -= rand() % 4 + 2;
instance->enemy_hp -= (rand() % 5) + 2; // 2-6
break;
case 1: // Heal
instance->player_hp += rand() % 6 + 2;
instance->player_mp -= rand() % 1 + 2;
instance->player_hp += (rand() % 3) + 6; // 6-8
instance->player_mp -= (rand() % 3) + 1; // 1-3
break;
case 2: // Charge
instance->player_mp += rand() % 4 + 3;
instance->player_mp += (rand() % 4) + 4; // 4-7
break;
}
if(instance->enemy_hp <= 0 || instance->enemy_mp <= 0) { // Enemy Defeated
reward = 1;
terminated = true;
} else if(instance->enemy_mp <= 5 && rand() % 1 + 9 >= 7) { // Enemy Drain Player MP
instance->player_mp -= rand() % 2 + 1;
} else if(instance->enemy_mp <= 5 && (rand() % 10) + 1 >= 7) { // Enemy Drain Player MP 1-10
instance->player_mp -= (rand() % 2) + 2; // 2-3
} else if(instance->enemy_hp <= 10 && instance->enemy_mp > 4) { // Enemy Heal
instance->enemy_hp += 4;
instance->enemy_mp -= 4;
} else {
instance->player_hp -= rand() % 3 + 3;
instance->player_hp -= (rand() % 4) + 3; // 3-6
}
if(instance->player_hp <= 0 || instance->player_mp <= 0) {

2
main.c
View File

@ -9,6 +9,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <time.h>
int SetupServer(int* socket_fd, int port) {
printf("[Client] Starting Server\n");
@ -65,6 +66,7 @@ int StartEnv(int port) {
int client_size = sizeof(client_addr);
int client_sock = accept(socket_fd, (struct sockaddr*)&client_addr, &client_size);
srand(time(NULL));
int obs_size = sizeof(struct Observation);
struct SS13ArcadeEnv env;
CreateEnvironment(&env);