test avoid bulled game

Dependencies:   C12832_lcd LCD_fonts mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
th_mbed
Date:
Mon Dec 12 10:44:00 2016 +0000
Parent:
23:33d7efd62537
Child:
26:6fe1d95b2b79
Commit message:
change make stage algolism

Changed in this revision

Stage.cpp Show annotated file Show diff for this revision Revisions of this file
models.h Show annotated file Show diff for this revision Revisions of this file
--- a/Stage.cpp	Mon Dec 12 10:19:12 2016 +0000
+++ b/Stage.cpp	Mon Dec 12 10:44:00 2016 +0000
@@ -1,14 +1,16 @@
 #include "point.h"
 #include "models.h"
+#include "mbed.h"
 #include <stdlib.h>
 #include <stdio.h> 
 
+#define MAX_LEN ONE_STEP_SIZE*3
+
 Stage::Stage(){
     length = LCD_X;
     for(int i = 0; i < LCD_X; i++){
         stage[i] = 1;
     }
-    srand(1);
 }
 
 int* Stage::getStage(){
@@ -40,6 +42,15 @@
     return stage;
 }
 
+int Stage::nextStep(){
+    if(stage[LCD_X - 1] == stage[LCD_X - 2 - ONE_STEP_SIZE]){
+        return stage[LCD_X - 1] + 4;
+    }else{
+        return rand()%(LCD_Y - 5);
+    }
+}
+
+
 int Stage::getLength(){
     return length;
 }
\ No newline at end of file
--- a/models.h	Mon Dec 12 10:19:12 2016 +0000
+++ b/models.h	Mon Dec 12 10:44:00 2016 +0000
@@ -56,6 +56,7 @@
 private:
     int length;
     int stage[LCD_X]; 
+    int nextStep();
 public:
     Stage();
     int* getStage();