Esempio n. 1
0
    def parse_planets(self, stars):
        PLANETS_COUNT_OFFSET = 0x162e7
        PLANETS_DATA_OFFSET = 0x162e9
        PLANET_RECORD_SIZE = 0x11
        planets = {}
        #        pl = {}

        c = 0
        for star_id in stars:
            star = stars[star_id]
            for o in star.get_objects():
                if o != 0xffff:
                    c += 1

        c = compose_int(ord(self.__data[PLANETS_COUNT_OFFSET]),
                        ord(self.__data[PLANETS_COUNT_OFFSET + 1]))
        #        c = 250

        #        print "Reading planetary objects ..."
        #        print "    count: %i" % c

        for i in range(c):
            planet_id = i
            offset = PLANETS_DATA_OFFSET + (PLANET_RECORD_SIZE * i)
            #        system_number = ord(self.__data[offset + 0x02])
            #        position = ord(self.__data[offset + 0x03])
            #            planets.append({
            planets[planet_id] = universe.Planet(planet_id)
            planets[planet_id].import_from_moo2(
                self.__data[offset:offset + PLANET_RECORD_SIZE])
#            pl[planet_id] = {
#                'planet_id':        planet_id,
#                'colony':           lbx.read_short_int(self.__data, offset),	# 0xffff = no colony here
#                'parent_star':      lbx.read_byte(self.__data, offset + 0x02),
#                'position':         lbx.read_byte(self.__data, offset + 0x03),
#                'type':             lbx.read_byte(self.__data, offset + 0x04),
#                'size':             lbx.read_byte(self.__data, offset + 0x05),
#                'gravity':          lbx.read_byte(self.__data, offset + 0x06),
#                'group':            lbx.read_byte(self.__data, offset + 0x07),   # not used
#                'terrain':          lbx.read_byte(self.__data, offset + 0x08),
#                'picture':          lbx.read_byte(self.__data, offset + 0x09),   # Background image on colony screen (0-5=image in planets.lbx)
#                'minerals':         lbx.read_byte(self.__data, offset + 0x0a),
#                'foodbase':         lbx.read_byte(self.__data, offset + 0x0b),
#                'terraformations':  lbx.read_byte(self.__data, offset + 0x0c),
#                'max_farms':        lbx.read_byte(self.__data, offset + 0x0d),   # unknown (Initial value is based on Planet Size but changes if colonized), 2=tiny, 4=small, 5=med, 7=large, A=huge
#                'max_population':   lbx.read_byte(self.__data, offset + 0x0e),
#                'special':          lbx.read_byte(self.__data, offset + 0x0f),
#                'flags':            lbx.read_byte(self.__data, offset + 0x10)    # (bit 2 = Soil Enrichment)
#            }
        return planets
Esempio n. 2
0
import universe
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
au = 1.496e11
day = 60 * 60 * 24
year = 365.242 * day

sun = universe.Planet("Sun", 1.989e30, np.array((0., 0.)), np.array((0., 0.)))
earth = universe.Planet("Earth", 5.9742e24, np.array((-1 * au, 0.)),
                        np.array((0., 29783.)))
mercury = universe.Planet("Mercury", 3.3e24, np.array((0, 0.466 * au)),
                          np.array((-47362., 0.)))
venus = universe.Planet("Venus", 4.8685e24, np.array((0.723 * au, 0.)),
                        np.array((0., 35020.)))
mars = universe.Planet("Mars", 6.417e23, np.array((0., -1.666 * au)),
                       np.array((24007., 0.)))
ss = universe.Universe()
ss.add_planet(sun)
ss.add_planet(earth)
ss.add_planet(mercury)
ss.add_planet(venus)
ss.add_planet(mars)

ss.evolve(5.0 * year)

fig = plt.figure(figsize=(10, 10))
plt.plot(sun.x, sun.y, label=sun.name, color="yellow", linewidth=5.0)
plt.plot(earth.x, earth.y, label=earth.name, color="blue")
plt.plot(mars.x, mars.y, label=mars.name, color="red")
plt.plot(mercury.x, mercury.y, label=mercury.name, color="orange")
Esempio n. 3
0
from matplotlib import pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation 
import universe 


au = 1.496e11
day = 60*60*24
year = 365.242*day

sun = universe.Planet("Sun", "yellow", 1.989e30, 0.696*1e9, np.array([0.,0.]), np.array([0.,0.]), )
mercury = universe.Planet("Mercury", "darkorange", 3.3e24, 2.439*1e6, np.array([0.,0.466 * au]), np.array([-47362.,0.]))
venus = universe.Planet("Venus", "red", 4.8685e24, 6.051*1e6, np.array([0.723 * au, 0.]), np.array([0.,35020.]))
earth = universe.Planet("Earth", "blue", 5.9742e24, 6.371*1e6, np.array([-1.*au,0.]), np.array([0.,-29783.]))
mars = universe.Planet("Mars", "brown", 6.417e23, 3.389*1e6, np.array([0., -1.666 * au]), np.array([24007., 0.]))

comet = universe.Planet("comet", "black", 60096328196739.71, 414.6548083733759, 
                        np.array([374898552652.16394, 241377690589.5441]),
                        np.array([-29345.44004345281, -35413.24135720836]))

ss = universe.Universe()
ss.add_planet(sun)
ss.add_planet(mercury)
ss.add_planet(venus)
ss.add_planet(earth)
ss.add_planet(mars)

ss.add_planet(comet)

ss.evolve(5.*year, day / 10)
Esempio n. 4
0
import universe
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

au = 1.496e11
day = 60*60*24
year = 365.242*day

sun = universe.Planet("Sun", 1.989e30, np.array((0.,0.)), np.array((0.,0.)))
mercury = universe.Planet("Mercury", 3.301e23, np.array((0.,0.387*au)), np.array((-47861.,0.)))
earth = universe.Planet("Earth", 5.9742e24, np.array((-1*au,0.)), np.array((0.,29783.)))
venus=universe.Planet("Venus", 4.869e24, np.array((-0.722*au,0.)),np.array((0.,-34965)))
mars=universe.Planet("Mars",6.4185e23, np.array((0.,-1.52*au)), np.array((23885, 0.)))
ss = universe.Universe()
ss.add_planet(sun)
ss.add_planet(earth)
ss.add_planet(mercury)
ss.add_planet(venus)
ss.add_planet(mars)
ss.evolve(2*year)

fig= plt.figure(figsize=(10,10))
plt.plot(sun.x,sun.y,label=sun.name,color="yellow", linewidth=7.0)
plt.plot(mercury.x,mercury.y,label=mercury.name,color="green")
plt.plot(mercury.x[-1],mercury.y[-1],"o",color="green")
plt.plot(earth.x,earth.y,label=earth.name,color="blue")
plt.plot(earth.x[-1],earth.y[-1],"o",color="blue")
plt.plot(venus.x,venus.y,label=venus.name,color="orange")
plt.plot(venus.x[-1],venus.y[-1],"o",color="orange")
plt.plot(mars.x,mars.y,label=mars.name,color="magenta")
Esempio n. 5
0
from matplotlib import pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation
import universe

au = 1.496e11
day = 60 * 60 * 24
year = 365.242 * day

sun = universe.Planet(
    "Sun",
    "yellow",
    1.989e30,
    0.696 * 1e9,
    np.array([0., 0.]),
    np.array([0., 0.]),
)
mercury = universe.Planet("Mercury", "darkorange", 3.3e24, 2.439 * 1e6,
                          np.array([0., 0.466 * au]), np.array([-47362., 0.]))
venus = universe.Planet("Venus", "red", 4.8685e24, 6.051 * 1e6,
                        np.array([0.723 * au, 0.]), np.array([0., 35020.]))
earth = universe.Planet("Earth", "blue", 5.9742e24, 6.371 * 1e6,
                        np.array([-1. * au, 0.]), np.array([0., -29783.]))
mars = universe.Planet("Mars", "brown", 6.417e23, 3.389 * 1e6,
                       np.array([0., -1.666 * au]), np.array([24007., 0.]))

comet = universe.Planet("comet", "black", 1e14, 0.5 * 1e3,
                        np.array([4. * au, 4 * au]),
                        np.array([-20000., -15000.]))

ss = universe.Universe()
Esempio n. 6
0
import universe
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation



au = 1.496e11
day = 60*60*24
year = 365.242*day

sun = universe.Planet("Sun", 1.989e30, np.array((0.,0.)), np.array((0.,0.)))
mercury = universe.Planet("Mercury",  3.3e24, np.array((0.,0.466*au)), np.array((-47362.0,0.)))

ss = universe.Universe()
ss.add_planet(sun)
ss.add_planet(mercury)
ss.evolve(5.0*year)

plt.style.use('dark_background')
fig = plt.figure()
ax = plt.axes(xlim=(-2e11, 2e11), ylim=(-2e11, 2e11))
ax.set_aspect('equal')
ax.axis('off')
axis.plot(sun.x,sun.y,label=sun.name,color="yellow", linewidth=2.0)
axis.plot(mercury.x,mercury.y,label=mercury.name,color="orange")

# axis.plot(venus.x,venus.y,label=venus.name,color= "red")

# axis.plot(earth.x,earth.y,label=earth.name,color="blue")
Esempio n. 7
0
import universe as uni
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

au = 1.486 * (10**11)
day = 60 * 60 * 24
year = 365.242 * day

Sun = uni.Planet("Sun", "yellow", 1.989 * (10**30), np.array((0, 0)),
                 np.array((0, 0)))
Mercury = uni.Planet("Mercury", "orange", 3.3 * (10**24), np.array(
    (-47362, 0)), np.array((0, 0.466 * au)))
Venus = uni.Planet("Venus", "red", 4.8685 * (10**24), np.array((0, 35020)),
                   np.array((0.723 * au, 0)))
Earth = uni.Planet("Earth", "blue", 5.9742 * (10**24), np.array((0, -29783)),
                   np.array((-1 * au, 0)))
Mars = uni.Planet("Mars", "brown", 6.417 * (10**23), np.array((24007, 0)),
                  np.array((0, -1.667 * au)))

p = uni.Universe()
p.addPlanet(Sun)
p.addPlanet(Mercury)
p.addPlanet(Venus)
p.addPlanet(Earth)
p.addPlanet(Mars)

p.interact(5 * year)

fig = plt.figure("Sunvec sustav")
axis = plt.axes(xlim=(-2 * au, 2 * au), ylim=(-2 * au, 2 * au))
Esempio n. 8
0
import universe 
import numpy as np 
import matplotlib.pyplot as plt

au = 1.496e11
day = 60*60*24
year = 365.242*day

sun = universe.Planet("Sun", "yellow", 1.989e30, np.array([0.,0.]), np.array([0.,0.]))
mercury = universe.Planet("Mercury", "darkorange", 3.3e24, np.array([0.,0.466 * au]), np.array([-47362.,0.]))
venus = universe.Planet("Venus", "red", 4.8685e24, np.array([0.723 * au, 0.]), np.array([0.,35020.]))
earth = universe.Planet("Earth", "blue", 5.9742e24, np.array([-1.*au,0.]), np.array([0.,-29783.]))
mars = universe.Planet("Mars", "brown", 6.417e23, np.array([0., -1.666 * au]), np.array([24007., 0.]))

ss = universe.Universe()
ss.add_planet(sun)
ss.add_planet(mercury)
ss.add_planet(venus)
ss.add_planet(earth)
ss.add_planet(mars)

ss.evolve(5.*year, day / 10)

img = plt.imread("yoda.jpg")
fig = plt.figure(figsize=(10,10))
plt.plot(sun.x_x, sun.y_y, label=sun.name, color=sun.color, linewidth=7.0)

plt.plot(mercury.x_x, mercury.y_y, label=mercury.name, color=mercury.color)
plt.plot(mercury.x_x[-1], mercury.y_y[-1], marker=".", markersize=20, color="orange")

plt.plot(venus.x_x, venus.y_y, label=venus.name, color=venus.color)
Esempio n. 9
0
import universe
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
au = 1.496e11
day = 60 * 60 * 24
year = 365.242 * day

sun = universe.Planet("Sun", 1.989e30, 0.696e9, np.array((0., 0.)),
                      np.array((0., 0.)))
earth = universe.Planet("Earth", 5.9742e24, 0.637e6, np.array((-1 * au, 0.)),
                        np.array((0., 29783.)))
mercury = universe.Planet("Mercury", 3.3e24, 2.439e6, np.array(
    (0, 0.466 * au)), np.array((-47362., 0.)))
venus = universe.Planet("Venus", 4.8685e24, 6.371e6, np.array(
    (0.723 * au, 0.)), np.array((0., 35020.)))
mars = universe.Planet("Mars", 6.417e23, 3.389e6, np.array((0., -1.666 * au)),
                       np.array((24007., 0.)))
comet = universe.Planet("comet", 1e14, 0.5e3, np.array((4. * au, 4 * au)),
                        np.array((-20000., -15000.)))
ss = universe.Universe()
ss.add_planet(sun)
ss.add_planet(earth)
ss.add_planet(mercury)
ss.add_planet(venus)
ss.add_planet(mars)
ss.add_planet(comet)

ss.evolve(5.0 * year)

fig = plt.figure(figsize=(10, 10))