Thread: New to code

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    New to code


    Hello im IOwN i play a game called URBAN TERROR i mod servers and more. I wonder can i get help with mods here? Is it allowed? Answer please!

    IOwN
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0
    i mean help with b3/python to my mods here? can i?
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    You'll probably get good response if you're polite, use the best English grammar you're capable, and have specific programming questions that can be answered without familiarity with your favorite game.

    If you expect your audience to understand "i mod servers and more." then perhaps devshed forums shouldn't be your first choice for help.

    Likewise, if you consider "Answer please!" polite then you should look elsewhere before your transfer to the blacklist occurs.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0
    Excuse me, im not so great on english but i gonna make a mod it is called INFECTION mod, cs have it and i think some other games have it. This is how the mod works. First 2 random person be in red team and the rest in blue team. If a red team player kill one in blue the blue team player that be killed forces into red team. If i am red and die i will wait to the other red die. if the red dont kill it restart the round. Any ideas how i can make this with b3? Sorry for my english

    IOwN
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    You needn't be a native English speaker. Here's a python code that implements my understanding of your description:
    Code:
    # The game of infection
    # I do not know what is "b3"
    
    # example game command line:
    # python -c 'import p;p.main(4)'
    
    import random, pdb
    
    class avatar:
    
        def __init__(self,name,team,offensive_skill,defense_rating):
            if not ((0 < offensive_skill < 1) and (0 < defense_rating < 1)):
                raise ValueError('offensive_skill and defense_rating must be between 0 and 1')
            self.name = name
            self.team = team
            self.offense = offensive_skill
            self.defense = defense_rating
            self.state = 'live'
    
        def __str__(self):
            return ' '.join(self.team,self.name,self.state)
    
        def __gt__(self,other):
            try:
                return random.random() < self.offense*(1-other.defense)
            except:
                raise ValueError('undefined operation with '+self.__class__.__name__)
    
    def create(name,team):
        return avatar(name,
                      team,
                      offensive_skill = 0.2 + random.random()*0.2, # baseball like statistics
                      defense_rating = 0.7 + random.random()*0.2,
                      )
    
    def shoot(red,blue):
        # shooting is not simultaneous.
        #   a dead player can be shot.
        #   a dead player cannot shoot.
        players = red+blue
        random.shuffle(players)
        #pdb.set_trace()
        change = 0
        for shooter in players:
            if 'live' != shooter.state:
                continue
            i = 'red' == shooter.team
            receivers = (red,blue,)[i]
            if not(len(receivers)):
                continue
            j = random.randrange(len(receivers))
            receiver = receivers[j]
            if receiver < shooter:
                change = 1
                if i:
                    red.append(receiver)
                    del blue[j]
                else:
                    red[i].state = 'dead'
        return change
    
    def simulation(players):
        red = [create(str(i),'red') for i in range(max(0,min(2,players)))]
        blue = [create(str(i+2),'blue') for i in range(max(0,players-2))]
        print('%d red, %d blue'%(sum('live' == r.state for r in red),len(blue)))
        while red and blue:
            if shoot(red,blue):
                print('%d red, %d blue'%(sum('live' == r.state for r in red),len(blue)))
                red = [r for r in red if 'live' == r.state]
        if red:
            print('The zombie infection overwhelmed the living')
        if blue:
            print('blue wins---zombie threat eliminated')
    
    infection = main = simulation

    Comments on this post

    • Sepodati agrees : Nice thought, but wasted effort. :)
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0
    Is this the force? Or dose i need to fix something! Im so thankful guys! What have u done here?

    Thank you from IOwN
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0
    It says No Module name infection (in b3 log) whats wrong?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0
    ???
  16. #9
  17. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    I do not know what a b3 is.

    to Sepodati: I enjoyed writing the infection game and learned a little. Far better than my usual wasteful activities.
    [code]Code tags[/code] are essential for python code and Makefiles!
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0
    b3/Big brother bot = http://bigbrotherbot.net

    U can make plugins in it and have this for Urban Terror that game i play and cod games etc.

IMN logo majestic logo threadwatch logo seochat tools logo