Score:
0
packages = ['ssl', 'pyodide-http', 'geopy',"pycountry"] import js import pyodide_http pyodide_http.patch_all() # Patch urllib3 and requests from geopy.geocoders import Nominatim import pycountry import random import time score = 0 facing = "N" lati = 8 longi = 77 #minZoom : 1, #maxZoom : 1 #`In Python right now, x = ${pyscript.interpreter.globals.get('main')}` baned_country = ["Nauru","Lebanon","Israel","Malawi","Lesotho","Eswatini","Andorra","Swaziland","Congo","Dominica","Guadeloupe",""] recognized_country_list = [country.name for country in pycountry.countries if hasattr(country, "official_name") and len(country.name) < 10 and country.name not in baned_country] geolocator = Nominatim(user_agent="airdrop", scheme='https') hintbool = False planevel = 0.2 buffbool = False def moveright(): global facing facing = "E" def moveforward(): global facing facing = "N" def moveback(): global facing facing = "S" def moveleft(): global facing facing = "W" def packagedrop(): global score,hintbool,hintstart,buffbool buffbool = True position = js.plane.getLatLng() location = geolocator.reverse([position.lat, position.lng]) select_country = location.raw['address']['country'] js.document.getElementById('lastcountry').innerHTML = select_country if select_country == objection: if hintbool: score += 0.5 else: score += 1 hintbool = False js.document.getElementById('Score_No').innerHTML = score obj_country() hintstart = time.time() def obj_country(): global objection objection = random.choice(recognized_country_list) js.document.getElementById('objcountry').innerHTML = objection def counthint(): global hintbool,hintstart,buffbool hintcount = geolocator.geocode(objection) hintpos = js.L.latLng(hintcount.latitude, hintcount.longitude) js.m.panTo(hintpos) hintbool = True buffbool = True hintstart = time.time() def main(): global lati,longi,facing,planevel if buffbool: current_time = time.time() if current_time - hintstart <= 5: planevel = 0.5 else: planevel = 0.2 if facing == "N": lati += planevel js.plane.setRotationAngle(0) elif facing == "E": longi += planevel js.plane.setRotationAngle(90) elif facing == "S": lati -= planevel js.plane.setRotationAngle(180) elif facing == "W": longi -= planevel js.plane.setRotationAngle(270) posi = js.L.latLng(lati, longi) js.plane.setLatLng(posi) obj_country() js.ispython = True