SoFunction
Updated on 2025-03-05

Implementation of Goji prediction algorithm written in go

For details, please see Github:/shanhuijie/GoWatch/tree/master/fiveinarow

five in a row (Gozi success prediction)

Judging from the four angles: horizontal, vertical, left slant rise and left slant fall

const( 
  matrix = 50*50 
  point = 3 
) 
  type Coordinat struct{
    x  int
    y  int
  }

type Allinat struct{
  key   []Coordinat
}

func InArray(need Coordinat, needArr []Coordinat) bool {
  for _,v := range needArr{
    if need == v{
      return true
    }
  }
  return false
}

func inverted(tmp []int) bool {   //Reverse order check  var i int
  for k := len(tmp)-1; k>=0;k--{
    if k == 0{         //The last subscript indicates that it cannot be compared      return false
    }
    if tmp[k]-1 == tmp[k]{   //Indicate that the value is a continuous number      i++
      if i == point{     //If the continuous number is reached, return        return true
      }
    }else{
      return false
    }
  }
  return false
}

func postive(tmp []int) bool {   //Foreign order check  var i int
  for ck, cv := range tmp {
    if ck == len(tmp)-1{    //The last subscript indicates that it cannot be compared      return false
    }
    if cv+1 == tmp[ck+1] {   //Indicate that the value is a continuous number      i++
      if i == point{     //If the continuous number is reached, return        return true
      }
    }else{
      return false
    }
  }
  return false
}

func Slope(inat *Allinat,coor Coordinat) bool {
  var (
    Xmax,Xmin int = +4,-4
    Ymax,Ymin int = +4,-4
    j,p   int
    lrise,lfall Coordinat
    //tmp []int
  )
  if Xmin < 0 {
    Xmin = 0
  }
  if Ymin < 0 {
    Ymin = 0
  }
  for i:=Xmin; i<=Xmax; i++{
    Xmin = Xmin+1
    Ymin = Ymin+1
     = Xmin
     = Ymin
    if InArray(lrise,) {
      j++
      //(lrise,j)
      if j == point{
        return true
      }
    }

    if Ymin == Ymax {
      break
    }
  }
  for ii := Xmax; ii>=Xmin; ii--{
    Xmax = Xmax-1
    Ymin = Ymin+1
     = Xmax
     = Ymin

    if InArray(lfall,) {
      p++
      //(lfall,p)
      if p == point{
        return true
      }
    }
    if Ymin == Ymax {
      return false
    }
  }
  return false

}

func lengthways(inat *Allinat,coor Coordinat) bool {
  var (
    max,min int = +4,-4
    tmp []int
  )
  if min < 0 {
    min = 0
  }
  for _,c := range {
    if (max >=  &&  == ) || (min >=  &&  == ){
      tmp = append(tmp,)
    }
  }
  (tmp)
  if (inverted(tmp) == true) || (postive(tmp) == true) {
    return true
  }
  return false
}

func crosswise(inat *Allinat,coor Coordinat) bool {
  var (
    max,min int = +4,-4
    tmp []int
  )
  for _,c := range {
    if (max >=  &&  == ) || (min >=  &&  == ){
      tmp = append(tmp,)
    }
  }
  (tmp)
  if (inverted(tmp) == true) || (postive(tmp) == true) {
    return true
  }
  return false
}

func IsFive(inat *Allinat,coor Coordinat) bool {
  ok := crosswise(inat,coor)
  ok2 := lengthways(inat,coor)
  ok3 := Slope(inat,coor)
  //slope(inat)
  if ok == true || ok2 == true || ok3 == true{
    return true
  }
  return false
}

func (inat *Allinat)AddCoordinat(coor Coordinat){
  for _,coslice := range {
    if coslice == coor {
      return 
    }
  }
  c := IsFive(inat,coor)
  (c,"*****",coor)
  if c == false{   //not finish five
     = append(,coor)
    ("No connection")
    return 
  }
  ("Connect into points")
  return 

}

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.