Scripts that modify rules crash Golly

Has something gone haywire? Let us know about it!
Post Reply
User avatar
Extrementhusiast
Posts: 1966
Joined: June 16th, 2009, 11:24 pm
Location: USA

Scripts that modify rules crash Golly

Post by Extrementhusiast » July 11th, 2014, 6:45 pm

Running a script that changes a .table file crashes Golly, with the error message notably saying "This application has requested the Runtime to terminate it in an unusual way." (running 64-bit version on Windows 7, script previously worked running 32-bit version on Windows XP)
I Like My Heisenburps! (and others)

User avatar
Andrew
Moderator
Posts: 945
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Scripts that modify rules crash Golly

Post by Andrew » July 11th, 2014, 8:47 pm

Extrementhusiast wrote:Running a script that changes a .table file crashes Golly...
Any chance you could post the offending script? It would help enormously if you could create a version of the script that is as small as possible but still causes the same crash. Is the crash 100% reproducible?
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
Extrementhusiast
Posts: 1966
Joined: June 16th, 2009, 11:24 pm
Location: USA

Re: Scripts that modify rules crash Golly

Post by Extrementhusiast » July 12th, 2014, 1:51 pm

The offending Python script (from Randomized Three-State Rules):

Code: Select all

from random import randint
import golly as g

def f(n):
  line = [0, 0, 0, 0, 0, 0, 0, 0, n]
  i = 0
  while i < 8:
    j = 0
    while j <= i:
      line[j] = 1
      j += 1
    file.write('%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n' % (line[8], line[7], line[6], line[5], line[4], line[3], line[2], line[1], line[0], r()))
    j = 0
    while j <= i:
      line[j] = 2
      file.write('%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n' % (line[8], line[7], line[6], line[5], line[4], line[3], line[2], line[1], line[0], r()))
      j += 1
    i += 1

def r():
  if randint(0, 2) == 2:
    return randint(0, 2)
  else:
    return 0

file = open(g.getdir('rules') + 'test.table', 'w')
file.write('n_states:3\n')
file.write('neighborhood:Moore\n')
file.write('symmetries:permute\n\n')
f(0)
file.write('%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n' % (1, 0, 0, 0, 0, 0, 0, 0, 0, r()))
f(1)
file.write('%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n' % (2, 0, 0, 0, 0, 0, 0, 0, 0, r()))
f(2)
file.close()
g.new('testing rule')
g.setalgo('RuleLoader')
g.setrule('test')
g.select([0, 0, 100, 100])
g.randfill(33)
g.select([])
g.fit()
I'll come up with a test script soon.
I Like My Heisenburps! (and others)

User avatar
Andrew
Moderator
Posts: 945
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Scripts that modify rules crash Golly

Post by Andrew » July 12th, 2014, 9:03 pm

I ran the above script many times on my 64-bit Mac version of Golly without any problems, so it would seem to be a Windows-specific problem. I don't have access to a 64-bit Windows machine so I'll try to get someone else to duplicate your crash.

Just to be clear, are you sure you're using a 64-bit Python? A 64-bit Golly requires that. (If the supplied Python scripts like oscar.py run ok then you're presumably using a compatible Python.)
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

flipper77
Posts: 197
Joined: October 24th, 2010, 3:25 am
Location: Spokane, WA

Re: Scripts that modify rules crash Golly

Post by flipper77 » July 13th, 2014, 1:05 am

I'm also running the 64-bit version on my Windows 7 computer, and the script runs perfectly fine. I don't know what could cause it to do that, but I do know I have a working 64-bit version of Python

User avatar
Extrementhusiast
Posts: 1966
Joined: June 16th, 2009, 11:24 pm
Location: USA

Re: Scripts that modify rules crash Golly

Post by Extrementhusiast » July 17th, 2014, 2:42 pm

Andrew wrote:Just to be clear, are you sure you're using a 64-bit Python? A 64-bit Golly requires that. (If the supplied Python scripts like oscar.py run ok then you're presumably using a compatible Python.)
Yes, as I had previously gone through a debacle where Golly couldn't find Python, even though I provided the correct file address. As it turns out, that's what happens when you have 64-bit Golly look for 32-bit Python. (With the 64-bit python, preset scripts like oscar.py do work.)
I Like My Heisenburps! (and others)

User avatar
Extrementhusiast
Posts: 1966
Joined: June 16th, 2009, 11:24 pm
Location: USA

Re: Scripts that modify rules crash Golly

Post by Extrementhusiast » September 16th, 2014, 9:23 pm

The latest version of the apgsearch script also crashes Golly in the same way. Perhaps it just has to do with changing rules?

EDIT: No, maybe it's writing files, as this script works:

Code: Select all

from glife import validint
import golly as g

num_string=g.getstring("Enter the number of samples:")
if not validint(num_string) :
	g.exit("This is not a valid number.")
else :
	num_samples=int(num_string)

margin=127
soup_width=2*margin+1
pop_t=0
pop_t_minus_one=0

pop=0
maxpop=0
prev_maxpop=0
pop_data=[]

# Clear the current layer
g.new("work")

for i in range(num_samples) :
	# Change to a dummy rule
	g.setrule("B/S")

	# Create random soup
	g.select([0, 0, soup_width, soup_width])
	g.randfill(50)
	g.select([])

	# Change rule to WFLanalyze-1
	g.setrule("WFLanalyze-1")

	# Set central cell
	g.setcell(margin,margin,3)

	# Run pattern until stabilization
	for j in range(1001) :
		if j==1000 :
			g.exit("Overflow on a sample.")
		pop_t_minus_one=int(g.getpop())
		g.run(1)
		pop_t=int(g.getpop())
		if pop_t==pop_t_minus_one :
			break

	# Change rule to WFLanalyze-2
	g.setrule("WFLanalyze-2")

	# Step pattern
	g.run(1)

	# Record population
	pop=int(g.getpop())

	# Increment table
	if pop>maxpop :
		prev_maxpop=maxpop
		maxpop=pop
		for j in range(prev_maxpop,maxpop) :
			pop_data.append(0)

	pop_data[pop-1]+=1

	# Reset
	g.reset()
# END

# Create new layer
g.new("data")

# FOR LOOP:
for i in range(len(pop_data)) :
	if pop_data[i]!=0 :
		for j in range(pop_data[i]) :
			g.setcell(i,-j-1,1)
# END
EDIT 2: Found a one-line problem:

Code: Select all

from random import randint
Notably, this doesn't affect the 32-bit version of Golly, which is very strange.
I Like My Heisenburps! (and others)

User avatar
Andrew
Moderator
Posts: 945
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Scripts that modify rules crash Golly

Post by Andrew » September 21st, 2014, 9:15 pm

I'm getting a bit confused. Are you saying that the latest 64-bit Golly for Windows, using a 64-bit Python, will crash if a script contains "from random import randint"? If so, I've got no idea why that would happen.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
Extrementhusiast
Posts: 1966
Joined: June 16th, 2009, 11:24 pm
Location: USA

Re: Scripts that modify rules crash Golly

Post by Extrementhusiast » September 24th, 2014, 8:35 pm

Just getting word that that same error message is appearing in completely different contexts from what I'm seeing here. So it's highly likely it's not a problem with Golly.
I Like My Heisenburps! (and others)

Post Reply