The concept of “oil to electricity” is crucial for expanding the share of electricity in final energy consumption as well as for encouraging energy efficiency and emission reduction. Initially, a multidimensional strategy analysis is conducted for the government, ports, and ships concerned. From an economics perspective, a mathematical model of electricity substitution benefit analysis based on multiagent cooperative game theory under cap and trade and carbon tax policies is constructed, and the effect of carbon emissions caused by ships on the environment and society is converted into economic value. How several variables, such as transformation costs, ship electricity consumption, subsidy rates, carbon tax prices, and the ratio of shore power usage time to berthing time, affect the functioning of shore power is analyzed. The best electricity price under various circumstances is determined while considering the benefits of the three parties to maximize social welfare. The reduction in carbon dioxide and pollutant emissions is calculated. Meanwhile, the environmental advantages of the “replacement of oil with electricity” procedure are estimated. An example supports the claim that the suggested modeling approach can successfully resolve the economic benefits of each participant for the period that fosters the growth of electricity replacement projects and offers a sound scientific foundation for the formation of pertinent legislation.