What has gone wrong with my pathfinding code (C#), trying to implement A* method?

I am trying to code a simple pathfinding algorithm to find the path from a location to an end goal given a list of blocked points (squares). however my code just keeps running even if the end goal is right next to the location. I have attached screenshots of all relevant pieces of my code.

The idea is I find the path and then from the list of points (path) I can print what direction the player needs to move.

`private readonly Contains contains;
static Contains checkcontains = new Contains();
static Checker directionCheck = new Checker(checkcontains);

    public Path(Contains contains) {
        this.contains = contains;
    }
    public void checkPath(Points location, Points endGoal, List<Points> obstacles, List<string> Path){
        List<Points> openList = new List<Points>();
        List<Points> closedList = new List<Points>();
        List<Points> pointPath = new List<Points>();
        List<int> openFscore = new List<int>();
        openList.Add(location);
        int locationFscore = Fscore(location, location, endGoal);
        openFscore.Add(locationFscore);
        Points CurrentSq = location;
        Path.Add("Start");
        while(CurrentSq != endGoal){
            int Closest = openFscore.Min();
            Points Current = openList[openFscore.LastIndexOf(Closest)];
            pointPath.Add(Current);
            closedList.Add(Current);
            openFscore.Remove(openFscore[openList.IndexOf(Current)]);
            openList.Remove(Current);
            List<Points> adjacent = [Current.northPoint(), Current.southPoint(), Current.eastPoint(), Current.westPoint()];
            foreach (Points square in adjacent){
                if (contains.Containers(closedList, square) == true || contains.Containers(obstacles, square) == true){
                    continue;
                }
                else if(contains.Containers(openList, square) == false){
                    openList.Add(square);
                    openFscore.Add(Fscore(location, square, endGoal));
                }
            }
            CurrentSq = Current;
           
        }
        for(int i = 1; i <= pointPath.Count; i++){
            int NS = pointPath[i].Y - pointPath[i-1].Y;
            int EW = pointPath[i].X - pointPath[i-1].X;
            string direction;
            if (NS < 0){
                direction = "South";
            }
            else if (NS > 0){
                direction = "North";
            }
            else if (EW < 0){
                direction = "West";
            }
            else if (EW > 0){
                direction = "East";
            }
            else {
                direction = "";
            }
            Path.Add(direction);
        } 

        }
          
        
        static int Gscore(Points location, Points current){
            int score = Math.Abs(location.X - current.X) + Math.Abs(location.Y - current.Y);
            return score;
        }
        static int Hscore(Points current, Points endGoal){
            int score =Math.Abs(endGoal.X - current.X) + Math.Abs(endGoal.Y - current.Y); 
            return score;
        }
        static int Fscore(Points location, Points current, Points endGoal){
            int score = Gscore(location, current) + Hscore(current, endGoal);
            return score;
        }


    }`

Here is the code from the Points class:

public class Points {
public int X {get; private set;}
public int Y {get; private set;}

        public Points(int x, int y){
            X = x;
            Y = y;
        }
    
        // store methods!!!!! for finding the NESW of each point  
        public Points readPoint(string[] input, int X, int Y) {
                int x = int.Parse(input[X]);
                int y = int.Parse(input[Y]);
                return new Points(x, y);
            }
    
        public Points eastPoint() {
            return new Points(X + 1, Y);
        }
    
        public Points westPoint(){
            return new Points(X - 1, Y);
        }
    
        public Points northPoint(){
            return new Points(X, Y + 1);
        }
    
        public Points southPoint(){
            return new Points(X, Y - 1);
        }
        //modified modified modified 
    }

}

and the code from the contains class:

public bool Containers(List<Points> obstacles, Points point){
// check x co ords and then check y co ords
// default to false
// create new list (separate obstacles into x and y values)

            string contains = "false";
        
            // iterate through the given list to see if the x value is blocked
            for (int i = 0; i < obstacles.Count; i ++){
                if(obstacles[i].X == point.X){
                   if(obstacles[i].Y == point.Y){
                    contains = "true";
                   }
                }
            }
    
            if (contains == "true"){
                return true;
            }
            else {
                return false;
            }
        }
    }

New contributor

user25197772 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật