func updateWeight(p *utils.Point) {
	if checkRelativePos(*p) == 1 {
		p.G = p.Parent.G + 10
	} else {
		p.G = p.Parent.G + 14
	}
	absx := (int)(math.Abs((float64)(dest.X - p.X)))
	absy := (int)(math.Abs((float64)(dest.Y - p.Y)))
	p.H = (absx + absy) * 10
	p.F = p.G + p.H
}
Update G, H, F of the point
package main
import (
	"fmt"
	"github.com/dyzdyz010/Golang-AStar/utils"
	"math"
	"os"
)
var origin, dest utils.Point
var openList, closeList, path []utils.Point
func setOrig(s *Scene) {
	origin = utils.Point{utils.GetRandInt(s.rows-2) + 1, utils.GetRandInt(s.cols-2) + 1, 0, 0, 0, nil}
	if s.scene[origin.X][origin.Y] == ' ' {
		s.scene[origin.X][origin.Y] = 'A'
	} else {
		setOrig(s)
	}
}
func setDest(s *Scene) {
	dest = utils.Point{utils.GetRandInt(s.rows-2) + 1, utils.GetRandInt(s.cols-2) + 1, 0, 0, 0, nil}
	if s.scene[dest.X][dest.Y] == ' ' {
		s.scene[dest.X][dest.Y] = 'B'
	} else {
		setDest(s)
	}
}
func initAstar(s *Scene) {
	setOrig(s)
	setDest(s)
	openList = append(openList, origin)
}
func findPath(s *Scene) {
	current := getFMin()
	addToCloseList(current, s)
	walkable := getWalkable(current, s)
	for _, p := range walkable {
		addToOpenList(p)
	}
}
func getFMin() utils.Point {
	if len(openList) == 0 {
		fmt.Println("No way!!!")
		os.Exit(-1)
	}
	index := 0
	for i, p := range openList {
		if (i > 0) && (p.F <= openList[index].F) {
			index = i
		}
	}
	return openList[index]
}
func getWalkable(p utils.Point, s *Scene) []utils.Point {
	var around []utils.Point
	row, col := p.X, p.Y
	left := s.scene[row][col-1]
	up := s.scene[row-1][col]
	right := s.scene[row][col+1]
	down := s.scene[row+1][col]
	leftup := s.scene[row-1][col-1]
	rightup := s.scene[row-1][col+1]
	leftdown := s.scene[row+1][col-1]
	rightdown := s.scene[row+1][col+1]
	if (left == ' ') || (left == 'B') {
		around = append(around, utils.Point{row, col - 1, 0, 0, 0, &p})
	}
	if (leftup == ' ') || (leftup == 'B') {
		around = append(around, utils.Point{row - 1, col - 1, 0, 0, 0, &p})
	}
	if (up == ' ') || (up == 'B') {
		around = append(around, utils.Point{row - 1, col, 0, 0, 0, &p})
	}
	if (rightup == ' ') || (rightup == 'B') {
		around = append(around, utils.Point{row - 1, col + 1, 0, 0, 0, &p})
	}
	if (right == ' ') || (right == 'B') {
		around = append(around, utils.Point{row, col + 1, 0, 0, 0, &p})
	}
	if (rightdown == ' ') || (rightdown == 'B') {
		around = append(around, utils.Point{row + 1, col + 1, 0, 0, 0, &p})
	}
	if (down == ' ') || (down == 'B') {
		around = append(around, utils.Point{row + 1, col, 0, 0, 0, &p})
	}
	if (leftdown == ' ') || (leftdown == 'B') {
		around = append(around, utils.Point{row + 1, col - 1, 0, 0, 0, &p})
	}
	return around
}
func addToOpenList(p utils.Point) {
	updateWeight(&p)
	if checkExist(p, closeList) {
		return
	}
	if !checkExist(p, openList) {
		openList = append(openList, p)
	} else {
		if openList[findPoint(p, openList)].F > p.F {  
			openList[findPoint(p, openList)].Parent = p.Parent
		}
	}
}