Prolog Project

job(matt,alice). driver(matt). driver(ford). driver(adrien). customer(alice). customer(bob). customer(bill). customer(charlie). % Person - driver/customer is at location Loc. is_at(Person,Loc). is_at(matt,ubc). is_at(bob,sfu). location(ubc,49.26,-123.25). location(sfu,49.29,-122.92). location(pacificCentre,49.28,-123.12). location(scienceWorld,49.27,-123.10). location(granvilleIsland,49.27,-123.13). location(stGeorgeSchool,49.24,-123.19). location(aquarium,49.30,-123.13). location(jerichoBeach,49.27,-123.19). location(mcArthurGlen,49.20,-123.14). location(mountainViewCemetary,49.24,-123.09). location(oakridge,49.23,-123.11). location(langara,49.22,-123.10). location(metrotownMall,49.22,-122.10). location(vancouverGeneralHospital,49.26,-123.12). location(broadwayCinema,49.26,-123.13). location(museumOfVancouver,49.27,-123.15). location(yvr,49.16,-123.18). location(shaughnessyGolfClub,49.24,-123.20). location(ikeaRichmond,49.19,-123.08). location(bcit,49.25,-123.00). location(nikkeiMuseum,49.21,-122.96). location(sunYatSenGarden,49.28,-123.10). location(canadaPlace,49.28,-123.11). % list of all places nodes([ubc, sfu, pacificCentre, scienceWorld, granvilleIsland, stGeorgeSchool, aquarium, jerichoBeach, mcArthurGlen, mountainViewCemetary, oakridge, langara, metrotownMall, vancouverGeneralHospital, broadwayCinema, museumOfVancouver, yvr, shaughnessyGolfClub, ikeaRichmond, bcit, nikkeiMuseum, sunYatSenGarden, canadaPlace]). edge(Loc1,Loc2,Weight) :- location(Loc1,X1,Y1), location(Loc2,X2,Y2), X is (X2 - X1), Y is (Y2 - Y1), Weight is sqrt(X^2 + Y^2). % Dijkstra algorithm

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.