Test, fix, and refactor#3
Open
KevinRGeurts wants to merge 30 commits intocosmicr:masterfrom
Open
Conversation
… requres (). (2) raw_input() is now input().
…g into a float results in a ValueError exception. So testing the type of Float('foo') does not work. (2) Now up to 32 total unit tests.
…_main__ in previous commit. (3) Add temporary hack in __main__ allowing seed to be set for random number generator. (4) Fix bug in navigation. (5) created input_int() which may not actually be needed because of item 4. Now have a total of 40 unittests.
…trols(). (2) Up to 54 unittests. (3) Added generate_sector() call to certain tests, where it was required because of need to have starbase or klingon located in the game's starting sector. Without this, some test would execute alone but not always reliable in a set.
…mless, since it got overwritten anyway before being accessed, but confusing. (2) In navigation(), fix bugs in integer and mod division. This was a part of why docking with starbase was failing. (3) Fixed off-by-one index error in is_docking_location() that was the rest of why docking with starbase was failing. (4) Added some dock strings to clarify a few functions' parameters. (5) Up to 65 unit tests.
… in initialize_game(). (2) Now at 70 unit tests that pass and 9 that fail. The 9 failing ones are placeholders for 9 functions that currently do not have any direct unit tests, though most are tested as part of other tests.
…) Added support for /d flag to __main__ to trigger a DEBUG mode which consistently seeds the random number generator. This is helpful in testing. (3) Have a total of 78 passing unittests. All functions are tested, although a small number of TODO comments in test_startrek.py denote potential coverage improvements.
…ft, right meaning of course number.
… up, down, left, right meaning of numeric direction.
…rbases present in the galaxy than intended. Updated unittest to assert that this is not happening.
… preparation for either capturing output for GUI or driving by AI.
…, and prep for AI and/or GUI.
…ent. This is prep for AI game play and/or GUI. Also, implemented inability to adjust shield energy if shield control is damaged. The fact that this was missing appears to have been a bug.
…tion. This is preparation for possible game play AI and/or GUI.
…rs.py. (2) Quadrant and Game classes moved out of glob_vars.py and into quadrant.py and game.py. (3) Moved 4 functions that don't access the game state out of startrek.py and into utilities.py. For example, distance(). (4) Added doc strings to utilities.py. (5) Refactored long_range_scan() to separate precheck and actual scan, in prep for AI and/or GUI. (6) Refactored computer_controls() to have precheck, input, and acgtual algorithm components. (7) Refactored display_galactic_record() to use _fetch_galactic_record(). (8) Refactored induce_damage(...) to return a list of strings to be printed. (9) startrek._navigation(...) now returns a boolean indicating if an obstacle was encountered. (10) Created StarTrekCourse class to represent direction in Star Trek navigation, and allowing addition/subtraction to adjust direction. (11) startrek._phaser_controls_fire(...) now returns number of klingon ships destroyed. . And _torpedo_control_launch(...) now returns booleans indicateding if torpedo missed everything and if torpedo was captured by star. (12) Added setup of logging, and /log option to log navigation data for debugging purposes. (13) Added GameOptions class to retain game options set by command line arguments. (14) Added GameOptions.cheat_no_damage, set to True by /no_damage command line argument. (15) Removed the zip of cosmicr's startrek1971 master branch.
…at I know .md, but not .rst.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I downloaded a source .zip of your startrek1971 main branch back in April. I originally played this game on a Commodore 64, back in the early 1980s, went looking on GitHub for a python port of the game, and found your project. At the time I didn't have an account on GitHub, so instead of creating a fork, I just started modifying the code in a local git repo.
I updated the code where needed to make it work with Python 3.x. Then, to learn the code in depth, I started writing unit tests. In the process I found a few bugs, which I fixed. I also did some minor refactoring.
Then I got the idea of using the Star Trek game as a learning project in how to implement artificial intelligence for games. In particular, I wanted to work on a decision making system. Obviously there is no entertainment in a game that completely plays itself. But I am new to game playing AI, and Star Trek was an uncomplicated game to use to learn.
Recently I forked your project on GitHub, created a topic branch, and pushed up some of my changes, so that I could send you this pull request. None of the decision making additions are included in this pull request, but some of the refactors I made and included were motivated by the AI work. I added a Change Log section to README.rst which summarizes the bug fixes and refactors I made.
My development environment is Microsoft Visual Studio Community 2022, so my topic branch includes a StarTek.sln and a StarTek.pyproj file. These aren't required to use the modified code.