2
$\begingroup$

Even though there are other questions related to the same error scattered around the web, I'm either being really myopic (in which case I profusely apologise) or my problem is unique.

I'm attempting to modify Jean-Francois Gallant neural network add-on, for a project. I am taking the 'hands-on' approach to this and I have learnt a lot along the way. I have changed the names of the variables and I am almost certain the error I am getting is as a result of that.

I keep getting a 'AttributeError' message from the console whenever I run my script from the Blender Game Engine:

Traceback (most recent call last): File "main", line 112, in AttributeError: 'module' object has no attribute 'DnpolymeraseNum'

Here is the code I believe is relevant. The code in asterisks is the line with the error:

import bge
import math
import mathutils
import nnetga
from random import random
from time import clock 
#¸¸♫·¯·♪¸¸♩·¯·♬¸¸¸¸♫·¯·♪¸¸♩·¯·♬¸¸¸¸♫·¯·♪¸¸♩·¯·♬¸¸¸¸♫·¯·♪¸¸♩·¯·♬¸¸¸¸♫·¯·♪¸¸♩·¯·♬`

input = []
for i in range(2):
    input.append([])
    **for ii in range(bge.logic.DnpolymeraseNum):**
        if i == 1:
            input[i].append([0,0,0,0,0,0])
        if i == 0:
            input[i].append([0,0,0,0,0,0,0,0])`

From what I understand the module I've imported is simply not attributed in the module nnetga that is imported. Is there anyway to ensure this happens so I can get rid of this error?

Again, I'm pretty scared to post this question up in case I annoy anyone. If I do I'm sorry, but I'm exhausted.

$\endgroup$
  • 2
    $\begingroup$ Fairly sure you can't add properties to bge.logic. You probably need to add a game property to the object and add cont=bge.logic.getCurrentController() then change your loop to for ii in range(cont['DnpolyeraseNum']): $\endgroup$ – sambler Nov 20 '16 at 6:36
  • $\begingroup$ @sambler Thank you very much, this worked. Please make your answer so I can select it correct. $\endgroup$ – Eli Nov 20 '16 at 20:04
2
$\begingroup$

You can't add properties to bge.logic.

To get this to work in the game engine, add a game property to the object and adjust your script to get the controller to access the property.

import bge

cont = bge.logic.getCurrentController()

input = []
for i in range(2):
    input.append([])
    for ii in range(cont['DnpolymeraseNum']):
        if i == 1:
            input[i].append([0,0,0,0,0,0])
        if i == 0:
            input[i].append([0,0,0,0,0,0,0,0])`
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.