<s> __author__ = '<STR_LIT>' <EOL> import unittest <EOL> from xcs . bitstrings import BitString <EOL> from xcs . scenarios import MUXProblem <EOL> class TestMUXProblem ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . scenario = MUXProblem ( <NUM_LIT:10> ) <EOL> def test_get_possible_actions ( self ) : <EOL> actions = self . scenario . get_possible_actions ( ) <EOL> self . assertTrue ( len ( actions ) == <NUM_LIT:2> ) <EOL> self . assertTrue ( True in actions ) <EOL> self . assertTrue ( False in actions ) <EOL> def test_sense ( self ) : <EOL> situation_size = ( self . scenario . address_size + <EOL> ( <NUM_LIT:1> << self . scenario . address_size ) ) <EOL> previous = self . scenario . sense ( ) <EOL> self . assertIsInstance ( previous , BitString ) <EOL> self . assertTrue ( len ( previous ) == situation_size ) <EOL> while self . scenario . more ( ) : <EOL> current = self . scenario . sense ( ) <EOL> self . assertIsInstance ( current , BitString ) <EOL> self . assertTrue ( len ( current ) == situation_size ) <EOL> if current != previous : <EOL> break <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_execute ( self ) : <EOL> situation = self . scenario . sense ( ) <EOL> index = int ( situation [ : self . scenario . address_size ] ) <EOL> value = situation [ self . scenario . address_size + index ] <EOL> self . assertEqual ( <NUM_LIT:1> , self . scenario . execute ( value ) ) <EOL> self . assertEqual ( <NUM_LIT:0> , self . scenario . execute ( not value ) ) <EOL> def test_more ( self ) : <EOL> self . scenario . reset ( ) <EOL> for _ in range ( self . scenario . initial_training_cycles ) : <EOL> self . scenario . sense ( ) <EOL> self . assertTrue ( self . scenario . more ( ) ) <EOL> self . scenario . execute ( False ) <EOL> self . assertFalse ( self . scenario . more ( ) ) <EOL> def main ( ) : <EOL> unittest . main ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
