Skip to main content
Added the rest of the challenge and formatted it.
Source Link
anon
anon

This code is my solution to this Reddit challenge.

Challenge:

You are given N -- you generate a NxN 2-D map 30% of the spots are "A" asteroids 10% of the spots are "G" gravity wells (explained below) 60% of the spots are "." empty space. When you generate the map you must figure out how many of each spaces is needed to fill the map. The map must then be randomly populated to hold the amount of Gravity Wells and Asteroids based on N and the above percentages.

N and Obstacles

As n changes so does the design of your random space map. Truncate the amount of obstacles and its always a min size of 1. (So say N is 11 so 121 spaces. At 10% for wells you need 12.1 or just 12 spots) N can be between 2 and 1000. To keep it simple you will assume every space is empty then populate the random Asteroids and Gravity wells (no need to compute the number of empty spaces - they will just be the ones not holding a gravity well or asteroid)

Asteroids

Probes cannot enter the space of an Asteroid. It will just be destroyed.

Empty Spaces

Probes can safely cross space by the empty spaces of space. Beware of gravity wells as described below.

Gravity Wells

Gravity wells are interesting. The Space itself is so dense it cannot be travelled in. The adjacent spaces of a Gravity well are too strong and cannot be travelled in. Therefore you might see this. . = empty space, G = gravity well

.....

.....

..G..

.....

.....

But due to the gravity you cannot pass (X = unsafe)

.....

.XXX.

.XGX.

.XXX.

.....

###Description:

NASA has contracted you to program the AI of a new probe. This new probe must navigate space from a starting location to an end location. The probe will have to deal with Asteroids and Gravity Wells. Hopefully it can find the shortest path.

###Map and Path:

This challenge requires you to establish a random map for the challenge. Then you must navigate a probe from a starting location to an end location.

###Map:

You are given N -- you generate a NxN 2-D map.

  • 30% of the spots are "A" asteroids
  • 10% of the spots are "G" gravity wells (explained below)
  • 60% of the spots are "." empty space. When you generate the map you must figure out how many of each spaces is needed to fill the map. The map must then be randomly populated to hold the amount of Gravity Wells and Asteroids based on N and the above percentages.

###N and Obstacles

As n changes so does the design of your random space map. Truncate the amount of obstacles and its always a min size of 1. (So say N is 11 so 121 spaces. At 10% for wells you need 12.1 or just 12 spots) N can be between 2 and 1000. To keep it simple you will assume every space is empty then populate the random Asteroids and Gravity wells (no need to compute the number of empty spaces - they will just be the ones not holding a gravity well or asteroid)

###Asteroids

Probes cannot enter the space of an Asteroid. It will just be destroyed.

###Empty Spaces

Probes can safely cross space by the empty spaces of space. Beware of gravity wells as described below.

###Gravity Wells

Gravity wells are interesting. The Space itself is so dense it cannot be travelled in. The adjacent spaces of a Gravity well are too strong and cannot be travelled in. Therefore you might see this. . = empty space, G = gravity well

 .....
 .....
 ..G..
 .....
 .....

But due to the gravity you cannot pass (X = unsafe)

 .....
 .XXX.
 .XGX.
 .XXX.
 .....

You might get Gravity wells next to each other. They do not effect each other but keep in mind the area around them will not be safe to travel in.

 ......
 .XXXX.
 .XGGX.
 .XXXX.
 ......

This code is my solution to this Reddit challenge.

Challenge:

You are given N -- you generate a NxN 2-D map 30% of the spots are "A" asteroids 10% of the spots are "G" gravity wells (explained below) 60% of the spots are "." empty space. When you generate the map you must figure out how many of each spaces is needed to fill the map. The map must then be randomly populated to hold the amount of Gravity Wells and Asteroids based on N and the above percentages.

N and Obstacles

As n changes so does the design of your random space map. Truncate the amount of obstacles and its always a min size of 1. (So say N is 11 so 121 spaces. At 10% for wells you need 12.1 or just 12 spots) N can be between 2 and 1000. To keep it simple you will assume every space is empty then populate the random Asteroids and Gravity wells (no need to compute the number of empty spaces - they will just be the ones not holding a gravity well or asteroid)

Asteroids

Probes cannot enter the space of an Asteroid. It will just be destroyed.

Empty Spaces

Probes can safely cross space by the empty spaces of space. Beware of gravity wells as described below.

Gravity Wells

Gravity wells are interesting. The Space itself is so dense it cannot be travelled in. The adjacent spaces of a Gravity well are too strong and cannot be travelled in. Therefore you might see this. . = empty space, G = gravity well

.....

.....

..G..

.....

.....

But due to the gravity you cannot pass (X = unsafe)

.....

.XXX.

.XGX.

.XXX.

.....

This code is my solution to this Reddit challenge:

###Description:

NASA has contracted you to program the AI of a new probe. This new probe must navigate space from a starting location to an end location. The probe will have to deal with Asteroids and Gravity Wells. Hopefully it can find the shortest path.

###Map and Path:

This challenge requires you to establish a random map for the challenge. Then you must navigate a probe from a starting location to an end location.

###Map:

You are given N -- you generate a NxN 2-D map.

  • 30% of the spots are "A" asteroids
  • 10% of the spots are "G" gravity wells (explained below)
  • 60% of the spots are "." empty space. When you generate the map you must figure out how many of each spaces is needed to fill the map. The map must then be randomly populated to hold the amount of Gravity Wells and Asteroids based on N and the above percentages.

###N and Obstacles

As n changes so does the design of your random space map. Truncate the amount of obstacles and its always a min size of 1. (So say N is 11 so 121 spaces. At 10% for wells you need 12.1 or just 12 spots) N can be between 2 and 1000. To keep it simple you will assume every space is empty then populate the random Asteroids and Gravity wells (no need to compute the number of empty spaces - they will just be the ones not holding a gravity well or asteroid)

###Asteroids

Probes cannot enter the space of an Asteroid. It will just be destroyed.

###Empty Spaces

Probes can safely cross space by the empty spaces of space. Beware of gravity wells as described below.

###Gravity Wells

Gravity wells are interesting. The Space itself is so dense it cannot be travelled in. The adjacent spaces of a Gravity well are too strong and cannot be travelled in. Therefore you might see this. . = empty space, G = gravity well

 .....
 .....
 ..G..
 .....
 .....

But due to the gravity you cannot pass (X = unsafe)

 .....
 .XXX.
 .XGX.
 .XXX.
 .....

You might get Gravity wells next to each other. They do not effect each other but keep in mind the area around them will not be safe to travel in.

 ......
 .XXXX.
 .XGGX.
 .XXXX.
 ......
Added challenge
Source Link
Levon
  • 295
  • 1
  • 2
  • 9

Challenge:

You are given N -- you generate a NxN 2-D map 30% of the spots are "A" asteroids 10% of the spots are "G" gravity wells (explained below) 60% of the spots are "." empty space. When you generate the map you must figure out how many of each spaces is needed to fill the map. The map must then be randomly populated to hold the amount of Gravity Wells and Asteroids based on N and the above percentages.

N and Obstacles

As n changes so does the design of your random space map. Truncate the amount of obstacles and its always a min size of 1. (So say N is 11 so 121 spaces. At 10% for wells you need 12.1 or just 12 spots) N can be between 2 and 1000. To keep it simple you will assume every space is empty then populate the random Asteroids and Gravity wells (no need to compute the number of empty spaces - they will just be the ones not holding a gravity well or asteroid)

Asteroids

Probes cannot enter the space of an Asteroid. It will just be destroyed.

Empty Spaces

Probes can safely cross space by the empty spaces of space. Beware of gravity wells as described below.

Gravity Wells

Gravity wells are interesting. The Space itself is so dense it cannot be travelled in. The adjacent spaces of a Gravity well are too strong and cannot be travelled in. Therefore you might see this. . = empty space, G = gravity well

.....

.....

..G..

.....

.....

But due to the gravity you cannot pass (X = unsafe)

.....

.XXX.

.XGX.

.XXX.

.....

Prompt: (diagonal movement = true & each step = false)

prompt http://i.imgur.com/QrkUQui.png

Prompt: (diagonal movement = true & each step = false)

prompt http://i.imgur.com/QrkUQui.png

Challenge:

You are given N -- you generate a NxN 2-D map 30% of the spots are "A" asteroids 10% of the spots are "G" gravity wells (explained below) 60% of the spots are "." empty space. When you generate the map you must figure out how many of each spaces is needed to fill the map. The map must then be randomly populated to hold the amount of Gravity Wells and Asteroids based on N and the above percentages.

N and Obstacles

As n changes so does the design of your random space map. Truncate the amount of obstacles and its always a min size of 1. (So say N is 11 so 121 spaces. At 10% for wells you need 12.1 or just 12 spots) N can be between 2 and 1000. To keep it simple you will assume every space is empty then populate the random Asteroids and Gravity wells (no need to compute the number of empty spaces - they will just be the ones not holding a gravity well or asteroid)

Asteroids

Probes cannot enter the space of an Asteroid. It will just be destroyed.

Empty Spaces

Probes can safely cross space by the empty spaces of space. Beware of gravity wells as described below.

Gravity Wells

Gravity wells are interesting. The Space itself is so dense it cannot be travelled in. The adjacent spaces of a Gravity well are too strong and cannot be travelled in. Therefore you might see this. . = empty space, G = gravity well

.....

.....

..G..

.....

.....

But due to the gravity you cannot pass (X = unsafe)

.....

.XXX.

.XGX.

.XXX.

.....

added 104 characters in body
Source Link
Levon
  • 295
  • 1
  • 2
  • 9

Prompt: (diagonal movement = true & each step = false)

prompt http://i.imgur.com/QrkUQui.png

Prompt: (diagonal movement = true & each step = false)

prompt http://i.imgur.com/QrkUQui.png

Removed non-SE compliant fluff. Minor rewording.
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
Removed non-SE compliant fluff. Minor rewording.
Source Link
Loading
Source Link
Levon
  • 295
  • 1
  • 2
  • 9
Loading