-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosition.h
More file actions
72 lines (62 loc) · 1.22 KB
/
Position.h
File metadata and controls
72 lines (62 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <vector>
enum class Direction
{
RIGHT = 0,
LEFT,
UP,
DOWN,
PASS
};
struct Square
{
Square( )
: x( 0 )
, y( 0 )
{
}
Square( int32_t x, int32_t y )
: x( x )
, y( y )
{
}
bool
operator<( const Square& rhs ) const
{
if ( x != rhs.x )
{
return x < rhs.x;
}
else
{
return y < rhs.y;
}
}
int32_t x;
int32_t y;
};
class Position
{
public:
Position( int32_t width, int32_t heigth );
int32_t get_width( ) const;
int32_t get_heigth( ) const;
Direction get_direction( ) const;
int32_t get_score( ) const;
int32_t get_life( ) const;
void set_direction( Direction dir );
void move( );
void generate_new_food( );
void display( ) const;
bool end_game( ) const;
std::vector< double > get_neural_net_input( ) const;
std::vector< Direction > get_possible_directions( ) const;
private:
int32_t m_width;
int32_t m_heigth;
int32_t m_score;
int32_t m_life;
Square m_snake;
Square m_food;
Direction m_direction;
};