Skip to content

Commit

Permalink
Use the turn rate at the start of the turn.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Oct 11, 2023
1 parent 5134308 commit 8da759b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 43 deletions.
55 changes: 29 additions & 26 deletions airpower/aircraft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,33 @@ def __init__(self, name, aircraftdata, hexcode, azimuth, altitude, speed, config
# configuration, aircraft initially have level flight, normal power, and
# no carries.

self._name = name
self._x = x
self._y = y
self._facing = facing
self._altitude = altitude
self._altitudeband = apaltitude.altitudeband(self._altitude)
self._altitudecarry = 0
self._speed = speed
self._configuration = configuration
self._flighttype = "LVL"
self._powersetting = "N"
self._bank = None
self._maneuvertype = None
self._maneuversense = None
self._maneuverfp = 0
self._fpcarry = 0
self._apcarry = 0
self._gloccheck = 0
self._aircraftdata = apaircraftdata.aircraftdata(aircraftdata)
self._destroyed = False
self._leftmap = False
self._turnsstalled = 0
self._turnsdeparted = 0
self._finishedmove = True
self._flightpathx = []
self._flightpathy = []
self._name = name
self._x = x
self._y = y
self._facing = facing
self._altitude = altitude
self._altitudeband = apaltitude.altitudeband(self._altitude)
self._altitudecarry = 0
self._speed = speed
self._configuration = configuration
self._flighttype = "LVL"
self._powersetting = "N"
self._bank = None
self._maneuvertype = None
self._maneuversense = None
self._maneuverfp = 0
self._maneuveraltitudeband = None
self._fpcarry = 0
self._apcarry = 0
self._gloccheck = 0
self._aircraftdata = apaircraftdata.aircraftdata(aircraftdata)
self._destroyed = False
self._leftmap = False
self._turnsstalled = 0
self._turnsdeparted = 0
self._finishedmove = True
self._flightpathx = []
self._flightpathy = []

self._saved = []
self._save(0)
Expand Down Expand Up @@ -202,6 +203,7 @@ def _restore(self, i):
self._maneuvertype, \
self._maneuversense, \
self._maneuverfp, \
self._maneuveraltitudeband, \
self._fpcarry, \
self._apcarry, \
self._gloccheck, \
Expand Down Expand Up @@ -234,6 +236,7 @@ def _save(self, i):
self._maneuvertype, \
self._maneuversense, \
self._maneuverfp, \
self._maneuveraltitudeband, \
self._fpcarry, \
self._apcarry, \
self._gloccheck, \
Expand Down
41 changes: 24 additions & 17 deletions airpower/aircraft/_normalflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,11 @@ def dodeclareturn(sense, turnrate):
if turnrateap == None:
raise RuntimeError("attempt to declare a turn rate tighter than allowed by the aircraft.")

self._bank = sense
self._maneuvertype = turnrate
self._maneuversense = sense
self._maneuverfp = 0
self._bank = sense
self._maneuvertype = turnrate
self._maneuversense = sense
self._maneuverfp = 0
self._maneuveraltitudeband = self._altitudeband

########################################

Expand All @@ -382,10 +383,11 @@ def dodeclareslide(sense):
elif self._slides == 2:
raise RuntimeError("at most two slides allowed per turn.")

self._maneuvertype = "SL"
self._maneuversense = sense
self._maneuverfp = 0
self._bank = None
self._bank = None
self._maneuvertype = "SL"
self._maneuversense = sense
self._maneuverfp = 0
self._maneuveraltitudeband = self._altitudeband

########################################

Expand All @@ -409,7 +411,7 @@ def doturn(sense, facingchange):
self._maneuverfp -= 1
self._bank = sense

minturnrate = apturnrate.determineturnrate(self._altitudeband, self._speed, self._maneuverfp, facingchange)
minturnrate = apturnrate.determineturnrate(self._maneuveraltitudeband, self._speed, self._maneuverfp, facingchange)
if minturnrate == None:
raise RuntimeError("attempt to turn faster than the maximum turn rate.")

Expand All @@ -418,7 +420,7 @@ def doturn(sense, facingchange):

else:

minturnrate = apturnrate.determineturnrate(self._altitudeband, self._speed, self._maneuverfp, facingchange)
minturnrate = apturnrate.determineturnrate(self._maneuveraltitudeband, self._speed, self._maneuverfp, facingchange)
if minturnrate == None:
raise RuntimeError("attempt to turn faster than the maximum turn rate.")

Expand Down Expand Up @@ -459,7 +461,9 @@ def doturn(sense, facingchange):
else:
self._facing = (self._facing - facingchange) % 360

self._maneuverfp = 0
# Implicitly continue the turn.
self._maneuverfp = 0
self._maneuveraltitudeband = self._altitudeband

########################################

Expand Down Expand Up @@ -490,9 +494,10 @@ def doslide(sense):
self._slidefp = self._fp

# Do not implicitly continue the maneuver.
self._maneuvertype = None
self._maneuversense = None
self._maneuverfp = 0
self._maneuvertype = None
self._maneuversense = None
self._maneuverfp = 0
self._maneuveraltitudeband = None

# Implicitly finish with wings level. This can be changed immediately by a bank.
self._bank = None
Expand Down Expand Up @@ -559,9 +564,11 @@ def doverticalroll(sense, facingchange, shift):
else:
self._facing = (self._facing - facingchange) % 360

self._maneuvertype = "VR"
self._maneuversense = None
self._maneuverfp = 0
self._bank = None
self._maneuvertype = "VR"
self._maneuversense = None
self._maneuverfp = 0
self._maneuveraltitudeband = self._altitudeband

########################################

Expand Down

0 comments on commit 8da759b

Please sign in to comment.