In the Federation Starfleet, the practice of conducting battle simulations (also known as war games or battle drills) was a common method of honing the tactical and combat skills of starship personnel.
Starfleet Academy routinely used battle simulations to train its cadets, such as the Kobayashi Maru scenario, which detailed a no-win scenario. It has been in existence in one form or another since before the 2250s. (Star Trek II: The Wrath of Khan; VOY: "Learning Curve")
Performance in battle simulations may be a factor in starship crew evaluations, including promotion decisions. Simulations may be scheduled in conjunction with duty shift schedules. (TNG: "Chain of Command, Part I", "Lower Decks")
In 2267, Starfleet conducted an elaborate simulation involving five Template:ShipClass starships: the USS Enterprise, the USS Excalibur, the USS Hood, the USS Lexington, and the USS Potemkin. The Enterprise was equipped with Doctor Richard Daystrom's experimental M-5 computer, and relieved of all but a skeleton crew. The other four starships were to launch a coordinated attack against the Enterprise as a test of the M-5's tactical and strategic capabilities.
However, the M-5 malfunctioned during the simulated attack; rather than firing with minimum-power phasers, the M-5 attacked the Excalibur with full-power phasers and photon torpedoes, destroying the ship and killing everyone on board. Enterprise Captain James T. Kirk managed to force the M-5 to deactivate before the remaining starships, led by Commodore Robert Wesley, could attack and destroy the Enterprise. (TOS: "The Ultimate Computer")
Operation Lovely Angel
In 2365, the crew of the USS Enterprise-D participated in a battle simulation in the Braslota system, overseen by Zakdorn strategist Sirna Kolrami, known as Operation Lovely Angel. Enterprise captain Jean-Luc Picard was originally against participating in the simulation, but with the recent discovery of the threat from the Borg (c.f. TNG: "Q Who"), he recognized the need for his crew to practice their combat skills.
An away team of forty crewmen from the Enterprise, led by Commander William T. Riker, boarded the obsolete and deactivated cruiser USS Hathaway and reactivated its systems in the space of 48 hours. However, the Hathaway was no match for the top-of-the-line Template:ShipClass starship, and so Riker's team prepared a few surprises. Riker's temporary first officer, Lieutenant Worf, hacked into the Enterprise's tactical systems and projected the appearance of a Romulan Warbird, creating a diversion that allowed the Hathaway to score multiple hits against the Enterprise.
However, the simulation was interrupted by the appearance of a Ferengi Marauder, whose DaiMon believed that the two Starfleet ships were engaged in some sort of internal struggle over advanced technology. The Kreechta attacked the Enterprise (which had originally thought that the Marauder's appearance was another trick programmed by Lieutenant Worf) and disabled the larger ship, leaving it powerless to defend the smaller Starfleet vessel. Bractor demanded that the Hathaway be turned over to him.
Fortunately, an act of subterfuge by Wesley Crusher had provided the Hathaway with a small amount of antimatter to power the ship's warp drive. Riker and Picard devised an elaborate illusion in which the Enterprise appeared to destroy the Hathaway with torpedoes, but in actuality the Hathaway escaped in a brief two-second warp jump to the far side of a nearby planet, where it was able to hide. Worf then programmed a sensor shadow into the Ferengi ship's computer, making it appear that Starfleet reinforcements were approaching the system. Apparently outnumbered and with its potential booty seemingly destroyed, the Ferengi ship retreated. (TNG: "Peak Performance")