[Gcblue-commits] gcb_wx/scripts AI.py, 1.31, 1.32 Menu.py, 1.30, 1.31 UnitCommands.py, 1.32, 1.33
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-15 03:38:51
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv32056/scripts Modified Files: AI.py Menu.py UnitCommands.py Log Message: Index: AI.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/AI.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** AI.py 20 Nov 2006 00:18:47 -0000 1.31 --- AI.py 15 Dec 2006 03:38:49 -0000 1.32 *************** *** 321,324 **** --- 321,405 ---- + + # shoot hostiles and unknowns within range, but do not intercept. + # Turn if necessary to position launchers + def EngageAllAir(TI): + UI = TI.GetPlatformInterface() + BB = TI.GetBlackboardInterface() + + iteration = TI.GetMemoryValue(1) # will return 0 first time + if (iteration == 0): # do initialization + TI.SetMemoryText('Description', 'Engage hostiles and unknowns within range, but do not intercept') + + iteration = iteration + 1 + TI.SetMemoryValue(1, iteration) + + # engage_mode values: + # 0 - searching, 1 - turning to place target within launch sector, 2 - keeping target within semiactive sector + engage_mode = TI.GetMemoryValue(2) + + # memory values + # 10: target id + # 11: launcher index + # 12: launch/follow sector center + # 13: launch/follow sector width + + if (engage_mode == 0): # searching + best_target, best_launcher = GetImmediateAirTarget(UI) + if (best_target != -1): + #UI.DisplayMessage('%s: targ: %d, lau: %d' % (UI.GetName(), best_target, best_launcher)) + launcher_info = UI.GetLauncherInfo(best_launcher) + if (launcher_info.IsValid()): + TI.SetMemoryValue(10, best_target) + TI.SetMemoryValue(11, best_launcher) + TI.SetMemoryValue(12, launcher_info.SectorCenter) + TI.SetMemoryValue(13, launcher_info.SectorWidth) + TI.SetMemoryValue(2, 1) + engage_mode = 1 + TI.SetUpdateInterval(10.0) + else: + TI.SetMemoryValue(2, 0) + else: + # check for nearby missiles + closest_id, closest_range = ClosestOfType(UI, 0x0040, 60) + if (closest_id == -1): + TI.SetUpdateInterval(30) + else: + if (closest_range < 20): + TI.SetUpdateInterval(1) + else: + TI.SetUpdateInterval(5) + UI.SetAllSensorState(1) + + if (engage_mode == 1): # turn to target + target_id = long(TI.GetMemoryValue(10)) + if (target_id == -1): + TI.SetMemoryValue(2, 0) + return + UI.SetTarget(target_id) + launcher = long(TI.GetMemoryValue(11)) + launcher_angle = TI.GetMemoryValue(12) + sector_width = TI.GetMemoryValue(13) + target_bearing = GetTargetBearing(UI) + #if (GetConnControl(BB)): + # UI.SetHeading(target_bearing-launcher_angle) + + engagement_angle = target_bearing - launcher_angle + if (engagement_angle > 180.0): + engagement_angle = engagement_angle - 360.0 + elif (engagement_angle < -180.0): + engagement_angle = engagement_angle + 360.0 + if (engagement_angle <= 0.5 * sector_width): + EngageTargetWithLauncher(UI, launcher) + TI.SetMemoryValue(2, 0) + TI.SetUpdateInterval(1.0) # wait 1 seconds + # ReleaseConnControl(BB) + # set for "fire and forget" this way + # add check here for semiactive guidance that requires keeping FC radar on target + # for duration of engagement + + + + # Adjust heading toward target, maintain altitude and speed to release point, # release ALL bombs at release point, and then reverse course *************** *** 518,524 **** is_air_target = track_info.IsAir() or track_info.IsMissile() if (is_air_target or track_info.IsSub()): ! max_engaged_count = 2 else: ! max_engaged_count = 6 #UI.DisplayMessage('Track %d, %.0f/%d/%d' % (track_id, staleness, bearing_only, engaged_count)) --- 599,605 ---- is_air_target = track_info.IsAir() or track_info.IsMissile() if (is_air_target or track_info.IsSub()): ! max_engaged_count = 1 else: ! max_engaged_count = 5 #UI.DisplayMessage('Track %d, %.0f/%d/%d' % (track_id, staleness, bearing_only, engaged_count)) *************** *** 557,560 **** --- 638,714 ---- + # returns id of closest target that is in-range, engageable, not already + # overwhelmingly engaged, and not a stale track + # returns -1 if none + # modified to avoid wasting all missiles on first target of stream raid + # + # version that only gets air and missile targets + def GetImmediateAirTarget(UI): + + # anAffiliation: UNKNOWN = 0, FRIENDLY = 1, NEUTRAL = 2, HOSTILE = 3 + # + # anClassMask: + # PTYPE_SURFACE 0x0010 + # PTYPE_AIR 0x0020 + # PTYPE_MISSILE 0x0040 + # PTYPE_SUBSURFACE 0x0080 + # PTYPE_FIXED 0x0100 + # int anClassMask, float afMaxRange_km, UINT8 anAffiliation + track_list = UI.GetTrackList(0x0060, 150, 3) + + current_time = UI.GetTime() + nTracks = track_list.Size() + best_range = 1e6 + best_target = -1 + best_launcher = -1 + best_engaged_count = 99 + + for n in range(0, nTracks): + track_info = track_list.GetTrack(n) + track_id = track_info.ID + staleness = current_time - track_info.Time + is_destroyed = track_info.IsDestroyed() + bearing_only = track_info.IsBearingOnly() + engaged_count = track_info.GetEngagedCount() + is_air_target = track_info.IsAir() or track_info.IsMissile() + if (is_air_target or track_info.IsSub()): + max_engaged_count = 1 + else: + max_engaged_count = 5 + #UI.DisplayMessage('Track %d, %.0f/%d/%d' % (track_id, staleness, bearing_only, engaged_count)) + + if ((engaged_count < max_engaged_count) and (staleness < 15.0) and (not bearing_only) and (not is_destroyed)): + UI.SetTarget(track_id) + launcher_info = UI.GetBestLauncher() + launcher_idx = launcher_info.Launcher + #UI.DisplayMessage('Best launcher %d' % launcher_idx) + if (launcher_idx != -1): + target_range = UI.GetRangeToTarget() + launch_range = launcher_info.Range_km # reference max range, use for launch decision + + is_better = (target_range <= launch_range) and (engaged_count < best_engaged_count) + is_better = is_better or ((engaged_count == best_engaged_count) and (target_range < best_range)) + + if (is_better): + best_range = target_range + best_target = track_id + best_launcher = launcher_idx + best_engaged_count = engaged_count + + # Clear best if there is another unengaged air target close to the launch zone + near_launch_range = (target_range > launch_range) and (target_range < 1.75*launch_range) + if (near_launch_range and is_air_target and (launcher_idx == best_launcher) and \ + (best_engaged_count > 0) and (engaged_count == 0)): + best_range = 1e6 + best_target = -1 + best_launcher = -1 + best_engaged_count = 99 + + UI.SetTarget(best_target) + + return (best_target, best_launcher) + + + *************** *** 839,843 **** def InterceptTarget(TI): UI = TI.GetPlatformInterface() ! iteration = TI.GetMemoryValue(1) # will return 0 first time --- 993,997 ---- def InterceptTarget(TI): UI = TI.GetPlatformInterface() ! BB = TI.GetBlackboardInterface() iteration = TI.GetMemoryValue(1) # will return 0 first time *************** *** 846,850 **** TI.SetMemoryValue(2, 0) # 0 if target not engaged, 1 otherwise TI.SetMemoryValue(4, 0) # launcher is fire and forget (flee after attack) ! iteration = iteration + 1 TI.SetMemoryValue(1, iteration) --- 1000,1004 ---- TI.SetMemoryValue(2, 0) # 0 if target not engaged, 1 otherwise TI.SetMemoryValue(4, 0) # launcher is fire and forget (flee after attack) ! TI.SetUpdateInterval(15.0) iteration = iteration + 1 TI.SetMemoryValue(1, iteration) *************** *** 901,904 **** --- 1055,1062 ---- UI.SetSpeedToMax() UI.SetActionText('Int %d (%3.0f s)' % (targetid, TTI)) + if (targetrange - launch_range > 2.0): + TI.SetUpdateInterval(15.0) + else: + TI.SetUpdateInterval(8.0) elif (adjust_depth): UI.SetAlt(-launcher_info.MaxDepth_m + 1) Index: UnitCommands.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/UnitCommands.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** UnitCommands.py 20 Nov 2006 00:18:47 -0000 1.32 --- UnitCommands.py 15 Dec 2006 03:38:49 -0000 1.33 *************** *** 35,42 **** def ToggleEngageAll(UI): ! if (UI.TaskExists('EngageAll')): UI.DeleteTask('EngageAll') else: ! UI.AddTask('EngageAll', 2.0, 0) def AddBombTargetTask(UI): --- 35,45 ---- def ToggleEngageAll(UI): ! if (UI.TaskExists('EngageAllAir')): ! UI.DeleteTask('EngageAllAir') ! UI.AddTask('EngageAll', 2.0, 0) ! elif (UI.TaskExists('EngageAll')): UI.DeleteTask('EngageAll') else: ! UI.AddTask('EngageAllAir', 2.0, 0) def AddBombTargetTask(UI): *************** *** 484,486 **** --- 487,495 ---- + def AddAttackMission(UI, targetId): + if (not UI.HasFlightPort()): + return + FP = UI.GetFlightPortInfo() + FP.AddAttackMission(targetId) + Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Menu.py 6 Dec 2006 01:20:42 -0000 1.30 --- Menu.py 15 Dec 2006 03:38:49 -0000 1.31 *************** *** 159,162 **** --- 159,163 ---- UnitMenu.BeginSubMenu() UnitMenu.AddItemUI('CAP', 'AddCAPMission', 'Datum') + UnitMenu.AddItemUI('Strike', 'AddAttackMission', 'Target') UnitMenu.EndSubMenu() |