Effect snake now uses a "proper", albeit simple neural network instead of simple decisions.
This commit is contained in:
@ -18,17 +18,16 @@ private:
|
||||
uint8_t _length;
|
||||
unsigned long _last_apple_at;
|
||||
unsigned long _last_move_at;
|
||||
// The following code is a handwritten "ai". Useful for testing and stuff.
|
||||
//int8_t _decisions[64] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,-1,0,0,0,0,-1,-1,0,0,0,1,0,0,-1,-1,0,0};
|
||||
int8_t _decisions[64] = {0, 1, 1, -1, 0, 1, 1, -1, 0, -1, 1, -1, -1, 0, 1, -1, -1, 0, 0, 1, -1, -1, 0, 0, -1, 0, 0, -1, 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 1, -1, -1, 1, 1, -1, -1, 1, -1, 0, 0, 1, 0, 1, -1, -1, 0, 0, 0, -1, 0, 1, 0, -1, 0, -1};
|
||||
//int8_t _decisions[64] = {1, 1, 0, 0, 1, 1, -1, -1, 0, -1, 0, -1, -1, 0, -1, 1, 1, -1, 0, 0, 1, -1, 0, 1, 0, -1, 0, -1, 0, 1, 1, 1, -1, 0, 0, 0, -1, -1, -1, 1, -1, -1, 1, 1, -1, 0, 1, 1, 1, 0, 0, -1, -1, 0, -1, 1, 0, 0, 0, -1, 0, -1, 1, 1};
|
||||
// 204.6 points, length 35, 58% stopped, 42% dead
|
||||
float _weights[18] = {0.8613356309729567, 0.1010670216231977, -0.03801953620401166, 0.7556556498067926, -0.9925124063206012, 0.6375227768823608, 0.7216340201735381, 0.5557451907997892, 0.03496949604344035, 0.7238725631217913, 0.9070987343528141, 0.6518810721526125, -0.17322587217593544, -0.7726195238221361, 0.8044226332955624, 0.8434782354002677, 0.8508760698750302, 0.47735675603010397};
|
||||
uint16_t _xy2i(uint8_t x, uint8_t y);
|
||||
uint16_t _xy2i(Coords c);
|
||||
Coords _i2xy(uint16_t i);
|
||||
Coords _new_pos(uint8_t dir);
|
||||
uint8_t _dying = 0;
|
||||
bool _is_free(uint8_t dir);
|
||||
bool _to_apple(uint8_t dir);
|
||||
uint8_t _free_spaces(uint8_t dir);
|
||||
uint8_t _to_apple(uint8_t dir);
|
||||
void _place_apple();
|
||||
void _init();
|
||||
void _decide();
|
||||
|
Reference in New Issue
Block a user