The Journey of a New Computer Programmer

A longtime computer-literate who wants to learn "real" programming language(s).

Saturday, May 12, 2007

Naval Duels update

The relevant files are available at the Subversion repository:

http://shock.easthighschool.net/projects/aproj/trunk/NavalDuels/ND_CombatEngine.py
http://shock.easthighschool.net/projects/aproj/trunk/NavalDuels/NavalDuels.py

(Just click on the link and select 'save page to disk', or something similar)

The current problem, so far as I have determined, exists in only certain situations -

If a battle-calculation (ship firepower divided by target armor) results in all of the target ships being eliminated (i.e. the relevant target_ship-left variable is 0), the calculation appears to work fine. However, if a battle-calculation results in only some of the target ships being eliminated

(Be warned, ND_CombatEngine.py is a large file- after getting the 'fighter versus fighter' claculation to work, I copy/pasted, and made small changes, to do 6 more -fighter versus the other 6 shiptypes. Then I copy/pasted (and modified) all 7, 7 times over, to make sub versus each shiptype, destroyer versus each shiptype, etc.)

Take a look at this file:
http://shock.easthighschool.net/projects/aproj/trunk/NavalDuels/MainBattleCode_Sample.py

This is one section of that code, the one for Carriers versus each of the 7 shiptypes. A small section may help y'all diagnose my problem, and provide suggestions for shortening the code; that's why I made it a separate file.

0 Comments:

Post a Comment

<< Home