• Advertisement
  • entries
  • comments
  • views

New speed calculation system

Sign in to follow this  


As you can see on the picture, the most visible change is a way to make the log lines colored. You can choose from gray, white, red, yellow, and green right now. All you need to do is print "1}line" to get it red, but I am going to change it to "r}line" to make it easier to remember.
The title says I did a new speed calculation system, so I better go into that also. The old system used to be:

  • All monsters get updated
  • The player return True, meaning it did something
  • The game loops trough all the monsters
  • The world object divides the monsters speed by the players speed to determine how many moves it gets

    • The world calls AIturn that many times
    • AIturn adds event to the monsters event quire depending on AI calculations (For the player object, this list is filled with keyboard input)

    • The next round, when the monster updates, the base class (Player) will run threw the input and do stuff

      The problem with that approach is that time is only counted for the amount of times its AI gets updated, but the player is being penalized for the amount of actions it takes. This mean monsters can take multiple actions per frame but the player can not. The AI should be based on a system where this doesn't happen, but never trust AI's. The AI coding was also more difficult because a lot of values where being checked that weren't important, like Event.Key when only Event.unicode was defined. You always had to check for everything
      The new system works like this:

      • All monsters get updated
      • The player adds to its actions if it has a event
      • The world object loops thew all objects
      • if it has a action ready:
      • add object.speed to object.action points
      • if it has more then 0 action points:
      • subtract the value of all the pending actions from its action points
      • call process_actions()

      • else, if it doesn't, call AI turn, that adds a action. If the monster is a player, that dous nothing
        Its actually a but more complicated, but it works. It is leggy though, since it takes a few frames for player input to get all the way threw the system. Here is the fuller code:[code=auto:62]while True: if self.objindex>=len(self.objects): self.objindex=0 obj=self.objects[self.objindex] if isinstance(obj, player_input.PlayerObject): if len(obj.actions)>0: obj.action_points+=obj.speed while obj.action_points>0: obj.action_points-=obj.gameTurn() redraw=True self.objindex+=1 else: obj.AIturn() break else: self.objindex+=1
        Some other changes I made are: (I am using a lot of bullets today)

        • Count armor in weight calculation (before, it would be lighter to wear some stuff)
        • Make food more nutritious, so its actually possible to survive without starving
        • A few improvements to AI
        • reduce experience from eating food
        • better text wrapping system, making printing using commas possible
        • a few updated graphics (I didn't do this)

          The next time I do something might be a few more month, so don't be surprised if you see nothing for some time. Be surprised if you see this in 2035 and it is still the last post.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement