Changeset 12838 for lang/cplusplus/hebilife
- Timestamp:
- 05/30/08 12:55:23 (5 years ago)
- Location:
- lang/cplusplus/hebilife
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/hebilife/brain.h
r9908 r12838 4 4 { 5 5 public: 6 // �p�[�Z�v�g�����̐� 6 7 // static const int N_NEURON_LAYER = 2; 7 8 // static const int N_NEURON = 2; -
lang/cplusplus/hebilife/field.cpp
r9908 r12838 9 9 10 10 Field::Field() 11 { 12 cnt = 0;13 steps = 0; 11 : cnt(0), 12 steps(0) 13 { 14 14 srand((unsigned int)time(NULL)); 15 15 for ( int y = 0 ; y < size_y ; y ++ ) … … 291 291 Field::~Field() 292 292 { 293 // release���� 293 294 for ( int i = 0 ; i < cnt ; i ++ ) 294 {295 295 delete snake[i]; 296 } 297 } 298 296 } 297 -
lang/cplusplus/hebilife/field.h
r9908 r12838 19 19 int random(int n); 20 20 21 static const int cnt_max= 1000;22 static const int length_max= 10;21 static const int CNT_MAX = 1000; 22 static const int LENGTH_MAX = 10; 23 23 24 Snake *snake[ cnt_max];24 Snake *snake[CNT_MAX]; 25 25 int cnt; 26 26 -
lang/cplusplus/hebilife/main.cpp
r9908 r12838 18 18 Field field; 19 19 20 // ���� 20 21 for ( int i = 0 ; i < 99 ; i ++ ) 21 22 field.makeSnake(); 22 23 24 // �ւ������� 23 25 field.view(); 24 26 for ( int j = 0 ; j < 1000 ; j ++ ) … … 29 31 field.view(); 30 32 } 33 // ���Ԃ�����������ɐ��� 31 34 // field.makeSnake(); 32 35 } -
lang/cplusplus/hebilife/snake.cpp
r9908 r12838 8 8 9 9 10 Snake::Snake(int id, Field *field) 11 { 12 this->id = id; 13 this->field = field; 14 15 is_dead = false; 10 Snake::Snake(int _id, Field *_field) 11 : id(_id), 12 field(_field), 13 is_dead(false) 14 { 16 15 17 16 // ���������� int r = field->random(4); … … 38 37 } 39 38 40 // ��W�̏��� length = field->random(field-> length_max-1) + 1;39 // ��W�̏��� length = field->random(field->LENGTH_MAX-1) + 1; 41 40 body_x[0] = field->random(field->size_x-length); 42 41 body_y[0] = field->random(field->size_y-length); … … 53 52 } 54 53 55 Snake::Snake(int id, Field *field, Snake *s) 56 { 57 this->id = id; 58 this->field = field; 59 60 is_dead = false; 61 54 // ������Ƃ��Ďւ� 55 Snake::Snake(int _id, Field *_field, Snake *s) 56 : id(_id), 57 field(_field), 58 is_dead(false) 59 { 62 60 length = s->length / 2; 63 61 for ( int i = 0 ; i < length ; i ++ ) … … 119 117 } 120 118 119 // �����_���ɓ��� 121 120 // if ( field->random(10) == 0 ) 122 121 // { … … 163 162 164 163 // wrap 165 if ( pre_body_x[0] == -1 )164 // �[�̓��b�v���� if ( pre_body_x[0] == -1 ) 166 165 pre_body_x[0] = field->size_x - 1; 167 166 if ( pre_body_y[0] == -1 ) … … 189 188 { 190 189 eat(); 191 if ( length >= field->length_max)190 if ( length >= Field::LENGTH_MAX ) 192 191 segmentation(); 193 192 } … … 226 225 } 227 226 228 void Snake::segmentation()227 // ����oid Snake::segmentation() 229 228 { 230 229 field->makeSnake(this); -
lang/cplusplus/hebilife/snake.h
r9908 r12838 13 13 // step�����Ɉ��q�ɂ��s����肵�A���ɍs������ void pre_move(); 14 14 15 // 1�X�e�b�v�i�� 15 16 void step(); 16 17 … … 32 33 void move(); 33 34 35 // ���ʁi�\���I���Ȃ��j 34 36 void die(); 35 37 36 void eat();38 // ������ׂ� void eat(); 37 39 38 void segmentation();40 // ���� void segmentation(); 39 41 40 42 // �S�Ă�nake��ield��Ƃ��� Field *field;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)