Skip to content

Instantly share code, notes, and snippets.

@Crilou
Created November 20, 2018 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Crilou/8e28aba817fe5c9c15263057c8980638 to your computer and use it in GitHub Desktop.
Save Crilou/8e28aba817fe5c9c15263057c8980638 to your computer and use it in GitHub Desktop.
MARS LANDER 2
package main
import "fmt"
//import "os"
type XY struct {
X int
Y int
}
func main() {
var surfaceN int
fmt.Scan(&surfaceN)
var (
landA = XY{-1,-1}
landB = XY{-1,-1}
)
var OK bool = true
for i := 0; i < surfaceN; i++ {
var landX, landY int
fmt.Scan(&landX, &landY)
if landY==landA.Y {
landB.X=landX
landB.Y=landY
OK = false
} else {
if OK {
landA.X=landX
landA.Y=landY
}
}
}
for {
var X, Y, hSpeed, vSpeed, fuel, rotate, power int
fmt.Scan(&X, &Y, &hSpeed, &vSpeed, &fuel, &rotate, &power)
var angle, vitesse int
if X<landA.X {
angle=-30
vitesse=4
} else {
if X>landB.X {
angle=30
vitesse=4
} else {
if hSpeed < (-10) {
angle=-60
vitesse=4
} else {
if hSpeed>10 {
angle=60
vitesse=4
}
}
}
}
if (0-vSpeed)>35 {
vitesse=4
}
// rotate power. rotate is the desired rotation angle. power is the desired thrust power.
fmt.Printf("%v %v\n", angle, vitesse)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment