Skip to content

reddit-pygame/planet-hopper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Planet Hopper

This challenge focuses on implementing an AI captain for a spaceship that transports goods between planets. You will need to download the github repo to test your AI code, but only the Captain class (components\captain.py) should be modified.

Challenge thread: https://www.reddit.com/r/pygame/comments/4qcgmd/challenge_planet_hopper/

#How it Works

###Goal

Accumulate 100,000 units of each resource (other than food). Resources onboard the ship don't count towards these totals.

###Planets

Each planet is capable of producing a particular resource. Each colonist on the planet is capable of producing 1 unit of the planet's resource per day if they have a sufficient amount of each resource. Each planet starts with 10 colonists and 1000 units of each resource.

###Resources

Each colonist needs a certain amount of each resource in order to harvest a planet's resource. If the planet doesn't have enough in its inventory no production will occur. Insufficient food will result in starvation of some or all of the colonists on the planet.

###Ship

The colonists have a single transport ship capable of interplanetary travel. The ship is responsible for distributing resources amongst the planets. Each time the ship docks on a planet all cargo and passengers are automatically offloaded.

###Captain

An instance of the Captain class is responsible for determining the destination and payload of the transport ship. Each day the ship is docked on a planet the Captain class's get_orders method will be called. Three dicts will be passed as arguments to Captain.get_orders: world_info, ship_info and distances.

world_info contains a dict for each planet (keyed by planet name) with the following structure

{"Planet name":
        {"pos": screen position of the planet,
        "inventory": {resource: amount of resource currently on the planet},
        "resource": name of the resource the planet produces,
        "consumption": {resource: planet's daily consumtion of resource},
        "num_colonists": number of colonists living on the planet}}            

ship_info a dict containg information about the transport ship

{"speed": the distance (in pixels) that the ship can travel in a day    
  "destination": the planet name of the ship's destination (this will be None when Captain.update is called)
  "pos": the current screen position of the ship (this will be equal to the position of the planet the ship is docked at)
  "cargo": {resource: number of units of resource currently onboard}
  "colonists": number of colonists onboard}

distances a dict of dicts containing the distance between each planet

{"planet name": {other_planet1: distance from planet to other_planet1,    
                         other_planet2: distance from planet to other_planet2,
                         ...}}

These dicts are also passed to Captain.__init__.

The Captain.get_orders method should return a dict representing the captain's orders

{"destination": planet name,
 "cargo": {resource: num units of resource to carry to destination planet},
 "colonists": num colonists to bring to destination planet}

###Controls

UP Increase simulation speed

DOWN Decrease simulation speed

SPACE Pause simulation

ESC Exit

F1 Toggle fullscreen

Hover mouse over ship or planet to display info window

#####Previous Challenges

Draw Order Challenge | Spawn, Collide, Wrap | Thruster Style Movement | Conway User Interaction | JSON Loading Challenge | Map Distance Challenge | Caching Pumpkins | A Puzzling World | Turkey Shoot | All Downhill From Here | Christmas Cannon | Color Picker | Minigolf Part I: Prototype | Skeet Shoot | Spin Class | Egg Lob | Build-A-Sprite | Matrix Digital Rain | Desktop Calculator

Good luck, have fun and feel free to ask for help if you need it

About

/r/pygame challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages