Beispiel #1
0
  def setupGrid( self, matrix ):

    if self.__test:
      self.__rows = 101
      self.__cols = 101

      self.__gridWidget = GridView( self, self.__rows, self.__cols, False )
      self.__layout.addWidget( self.__gridWidget, 0, 0 )

      b_overwriteSpectralValue = True
      maxEnergy = 255 / 3
      automaton = C_spectrum_CAM_RGB( maxQuanta=maxEnergy )
      automaton.component_add( 'R', maxEnergy / 3, b_overwriteSpectralValue )
      automaton.component_add( 'G', maxEnergy / 3, b_overwriteSpectralValue )
      automaton.component_add( 'B', maxEnergy / 3, b_overwriteSpectralValue )
      automaton.updateRule_changeAmount(self.__updateAmount)

      world = C_CAE( np.array( ( self.__rows, self.__cols ) ), automaton )
      world.verbosity_set( 1 )
      arr_world = np.zeros( ( self.__rows, self.__cols ) )
      arr_world[0, 0] = 1
      arr_world[50, 50] = maxEnergy / 3 + 1
      arr_world[100, 100] = maxEnergy / 3 * 2 + 1

    elif matrix:
      maxEnergy = 255

      arr_worldRaw = np.loadtxt( matrix, float, '#', '\t' )
      arr_world = misc.arr_normalize( arr_worldRaw, scale=maxEnergy )

      self.__rows, self.__cols = arr_world.shape

      self.__gridWidget = GridView( self, self.__rows, self.__cols, False )
      self.__layout.addWidget( self.__gridWidget, 0, 0 )

      b_overwriteSpectralValue = True
      automaton = C_spectrum_CAM_RGB( maxQuanta=maxEnergy )
      automaton.component_add( 'R', maxEnergy / 3, b_overwriteSpectralValue )
      automaton.component_add( 'G', maxEnergy / 3, b_overwriteSpectralValue )
      automaton.component_add( 'B', maxEnergy / 3, b_overwriteSpectralValue )
      print "Update amount = %d" % self.__updateAmount
      automaton.updateRule_changeAmount(self.__updateAmount)

      world = C_CAE( np.array( ( self.__rows, self.__cols ) ), automaton )
      world.verbosity_set( 1 )

    else:
      c.error( 'No test mode and no matrix..' )
      sys.exit()

    print arr_world
    world.initialize( arr_world )

    self.__world = world
Beispiel #2
0
#
# 04 January 2012
# o Initial development implementation.
#

import numpy as np

from C_spectrum_CAM import *
from C_CAE import *

import _common.systemMisc as misc

b_overwriteSpectralValue = True
maxEnergy = 249
automaton = C_spectrum_CAM_RGB(maxQuanta=maxEnergy)
automaton.component_add('R', maxEnergy / 3, b_overwriteSpectralValue)
automaton.component_add('G', maxEnergy / 3, b_overwriteSpectralValue)
automaton.component_add('B', maxEnergy / 3, b_overwriteSpectralValue)

world = C_CAE(np.array((101, 101)), automaton)
world.verbosity_set(1)
arr_world = np.zeros((101, 101))
arr_world[0, 0] = 1
arr_world[50, 50] = maxEnergy / 3 + 1
arr_world[100, 100] = maxEnergy / 3 * 2 + 1

world.initialize(arr_world)

for iter in np.arange(0, 100):
    world.state_transition()
Beispiel #3
0
# 04 January 2012
# o Initial development implementation.
#

import  numpy           as np

from    C_spectrum_CAM  import *
from    C_CAE           import *

import  _common.systemMisc      as misc

b_overwriteSpectralValue        = True
maxEnergy                       = 249
automaton                       = C_spectrum_CAM_RGB(maxQuanta = maxEnergy)
automaton.component_add('R', maxEnergy/3, b_overwriteSpectralValue)
automaton.component_add('G', maxEnergy/3, b_overwriteSpectralValue)
automaton.component_add('B', maxEnergy/3, b_overwriteSpectralValue)

world           = C_CAE( np.array( (101,101)), automaton )
world.verbosity_set(1)
arr_world               = np.zeros( (101, 101) )
arr_world[0,0]          = 1
arr_world[50,50]        = maxEnergy/3 + 1
arr_world[100, 100]     = maxEnergy/3*2 + 1

world.initialize(arr_world)

for iter in np.arange(0, 100):
    world.state_transition()