Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualAngus Hollands

Posted 11 February 2013 - 04:35 PM

Thanks to everyone. I've considered all of the points. I have read the entire documentation countless times, but certain things were not clear. I'm still not fully sure how best to define replication conditions. I don't know If I will want to evaluate a condition to determine which variables to send every time I want to replicate variables because for any serious number of clients this will become slow. 

 

I have some ideas regarding speeding up the system. All of this is conceptual, but in my old system objects would be iterated through again when they were serialised. Instead, I plan to now use the network attributes as part of the state storage (every tick store the state of the object by copying it's network values) and only converting that to bytes every network tick, but doing so in the same iteration. 

 

One question I have; Would it be a worse design to declare replicating attributes by name, or to use a special declare object that looks more like attribute lookup?

e.g:

class DeclaredProxy:
    def __init__(self, replicator):
        self.tags = set()
        self.replicator = replicator
        
    def __getattr__(self, key):
        network_variables = self.replicator.network_variables
        if key in network_variables:
            self.tags.add(key)
        return getattr(self.replicator, key)
    
class Declared:
    def __init__(self, replicator):
        self.proxy = DeclaredProxy(replicator)

    def __enter__(self):
        return self.proxy
        
    def __exit__(self, *a, **kw):
        pass

class Actor(Replicator):
    a = Variable(1)  
    b = Variable(1)  
    c = Variable(1)  
    d = Variable(1)               
               
    e = Variable(1)  
    f = Variable(1)  
    g = Variable(1)  
    h = Variable(1)   
    
    def replication(self, caller):
        dirty_variables = self.dirty_variables(caller)
        is_initial = self.is_initial(caller)
        
        with self.declarer as declare:
            if is_initial:
                declare.a
                declare.b
                declare.c
                declare.d

 

Here is the yield example. It's likely less overhead, but less pretty in my opinion

class Actor(Replicator):
    a = Variable(1)  
    b = Variable(1)  
    c = Variable(1)  
    d = Variable(1)               
               
    e = Variable(1)  
    f = Variable(1)  
    g = Variable(1)  
    h = Variable(1)   
    
    def replication(self, caller):
        dirty_variables = self.dirty_variables(caller)
        is_initial = self.is_initial(caller)
        
        if is_initial:
            yield "a"
            yield "b"
            yield "c"     

#3Angus Hollands

Posted 11 February 2013 - 04:35 PM

Thanks to everyone. I've considered all of the points. I have read the entire documentation countless times, but certain things were not clear. I'm still not fully sure how best to define replication conditions. I don't know If I will want to evaluate a condition to determine which variables to send every time I want to replicate variables because for any serious number of clients this will become slow. 

 

I have some ideas regarding speeding up the system. All of this is conceptual, but in my old system objects would be iterated through again when they were serialised. Instead, I plan to now use the network attributes as part of the state storage (every tick store the state of the object by copying it's network values) and only converting that to bytes every network tick, but doing so in the same iteration. 

 

One question I have; Would it be a worse design to declare replicating attributes by name, or to use a special declare object that looks more like attribute lookup?

e.g:

class DeclaredProxy:
    def __init__(self, replicator):
        self.tags = set()
        self.replicator = replicator
        
    def __getattr__(self, key):
        network_variables = self.replicator.network_variables
        if key in network_variables:
            self.tags.add(key)
        return getattr(self.replicator, key)
    
class Declared:
    def __init__(self, replicator):
        self.proxy = DeclaredProxy(replicator)

    def __enter__(self):
        return self.proxy
        
    def __exit__(self, *a, **kw):
        pass

class Actor(Replicator):
    a = Variable(1)  
    b = Variable(1)  
    c = Variable(1)  
    d = Variable(1)               
               
    e = Variable(1)  
    f = Variable(1)  
    g = Variable(1)  
    h = Variable(1)   
    
    def replication(self, caller):
        dirty_variables = self.dirty_variables(caller)
        is_initial = self.is_initial(caller)
        
        with self.declarer as declare:
            if is_initial:
                declare.a
                declare.b
                declare.c
                declare.d

 

Here is the yield example. It's likely less overhead, but less pretty in my opinion

class Actor(Replicator):
    a = Variable(1)  
    b = Variable(1)  
    c = Variable(1)  
    d = Variable(1)               
               
    e = Variable(1)  
    f = Variable(1)  
    g = Variable(1)  
    h = Variable(1)   
    
    def replication(self, caller):
        dirty_variables = self.dirty_variables(caller)
        is_initial = self.is_initial(caller)
        
        with self.declarer as declare:
        if is_initial:
            yield "a"
            yield "b"
            yield "c"     

 

 


#2Angus Hollands

Posted 11 February 2013 - 04:30 PM

Thanks to everyone. I've considered all of the points. I have read the entire documentation countless times, but certain things were not clear. I'm still not fully sure how best to define replication conditions. I don't know If I will want to evaluate a condition to determine which variables to send every time I want to replicate variables because for any serious number of clients this will become slow. 

 

I have some ideas regarding speeding up the system. All of this is conceptual, but in my old system objects would be iterated through again when they were serialised. Instead, I plan to now use the network attributes as part of the state storage (every tick store the state of the object by copying it's network values) and only converting that to bytes every network tick, but doing so in the same iteration. 

 

One question I have; Would it be a worse design to declare replicating attributes by name, or to use a special declare object that looks more like attribute lookup?

e.g:

class DeclaredProxy:
    def __init__(self, replicator):
        self.tags = set()
        self.replicator = replicator
        
    def __getattr__(self, key):
        network_variables = self.replicator.network_variables
        if key in network_variables:
            self.tags.add(key)
        return getattr(self.replicator, key)
    
class Declared:
    def __init__(self, replicator):
        self.proxy = DeclaredProxy(replicator)

    def __enter__(self):
        return self.proxy
        
    def __exit__(self, *a, **kw):
        pass

class Actor(Replicator):
    a = Variable(1)  
    b = Variable(1)  
    c = Variable(1)  
    d = Variable(1)               
               
    e = Variable(1)  
    f = Variable(1)  
    g = Variable(1)  
    h = Variable(1)   
    
    def replication(self, caller):
        dirty_variables = self.dirty_variables(caller)
        is_initial = self.is_initial(caller)
        
        with self.declarer as declare:
            if is_initial:
                declare.a
                declare.b
                declare.c
                declare.d

#1Angus Hollands

Posted 11 February 2013 - 03:42 PM

Thanks to everyone. I've considered all of the points. I have read the entire documentation countless times, but certain things were not clear. I'm still not fully sure how best to define replication conditions. I don't know If I will want to evaluate a condition to determine which variables to send every time I want to replicate variables because for any serious number of clients this will become slow. 

 

I have some ideas regarding speeding up the system. All of this is conceptual, but in my old system objects would be iterated through again when they were serialised. Instead, I plan to now use the network attributes as part of the state storage (every tick store the state of the object by copying it's network values) and only converting that to bytes every network tick, but doing so in the same iteration. 


PARTNERS