[Tutor] Looking for suggestions - update

->Terry<- tvbare at socket.net
Tue Nov 15 06:52:50 CET 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Today (Nov 14, 2005) at 6:10am, Kent Johnson spoke these wise words:

- ->A couple of notes after a quick look:
- ->
- ->- As you note, def check_valid_jump(sel1, sel2) is really ugly. When I have code like this I look for a way to drive it from a table instead of a bunch of if/elif statements full of magic numbers. In this case it looks like you have one condition for each state. The conditions and results could be put in a list whose index is the state and whose values are the test values for sel1 and sel2. You would have a table that looks like this:
- ->jump_table = [
- ->  (1, 1, 4, 2),    # (state # sel1 and sel2 values to check for state, return value)
- ->  (2, 1, 6, 3),
- ->  # etc for all the tests

<snip>

Thanks for the reply Kent and others. I've made some
changes and the game is quite playable now. I've put
the new version online at the same links if anyone
wants to take a look.

I agree with what someone else posted about earlier.
This list is a great resource and is really appreciated.

Cheers,
- -- 
    Terry


"Be who you are and say what you feel, because those
 who mind don't matter and those who matter don't mind."
                                 -- Dr. Seuss
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)

iD8DBQFDeXe6QvSnsfFzkV0RAlPEAJ4kPDDjXZZZyl0TJqbY5NCoReYlYACeKGW7
su+ZjZQeOyaFBvh67d6i6eU=
=+qXo
-----END PGP SIGNATURE-----



More information about the Tutor mailing list