2019-12-21 20:46:23 +00:00
|
|
|
import random
|
2019-12-23 09:03:59 +00:00
|
|
|
#from graphics import *
|
|
|
|
#win = GraphWin()
|
2019-12-23 11:19:49 +00:00
|
|
|
# library
|
|
|
|
#import seaborn as sns
|
|
|
|
#import pandas as pd
|
|
|
|
#import numpy as np
|
|
|
|
|
|
|
|
# Create a dataset (fake)
|
|
|
|
#df = pd.DataFrame(np.random.random((5,5)), columns=["a","b","c","d","e"])
|
|
|
|
|
|
|
|
# Default heatmap: just a visualization of this square matrix
|
|
|
|
#p1 = sns.heatmap(df)
|
2019-12-23 09:03:59 +00:00
|
|
|
|
|
|
|
|
2019-12-21 20:46:23 +00:00
|
|
|
|
2019-12-21 21:00:28 +00:00
|
|
|
# (c) R P Clark 2019
|
2019-12-21 20:46:23 +00:00
|
|
|
|
|
|
|
def mandelbrot (re, Im, max_iter):
|
|
|
|
c = complex (Re,Im)
|
|
|
|
z = 0.0j
|
|
|
|
for i in range (max_iter):
|
|
|
|
c = complex(re,Im)
|
|
|
|
z = z * z + c
|
|
|
|
if ( z.real * z.real + z.imag * z.imag) > 4:
|
|
|
|
return i
|
|
|
|
return max_iter
|
|
|
|
|
|
|
|
columns = 10
|
|
|
|
rows = 10
|
|
|
|
|
|
|
|
print "HijFong"
|
|
|
|
for Re in range ( -2000, 1000, 333 ):
|
|
|
|
for Im in range ( -1000, 1000, 200 ):
|
|
|
|
print mandelbrot(Re/1000.0,Im/1000.0,100),
|
|
|
|
print
|
|
|
|
|
|
|
|
mm = 40
|
|
|
|
|
|
|
|
# make sure 0,0 as first answer cannot win
|
2019-12-23 09:03:59 +00:00
|
|
|
# i.e. in the stable or very chaotic area
|
|
|
|
while mm < 90 and mm > 10:
|
2019-12-21 20:46:23 +00:00
|
|
|
r = random.randint(-2000, 1000) / 1000.0
|
|
|
|
i = random.randint(-1000, 1000) / 1000.0
|
|
|
|
mm = mandelbrot(r,i,100)
|
|
|
|
|
|
|
|
ro = 0.0
|
|
|
|
io = 0.0
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
|
|
|
|
real = raw_input("player 1: Real: ")
|
|
|
|
imag = raw_input("player 1: Imag: ")
|
|
|
|
|
|
|
|
r = r + float(real)/100.0;
|
|
|
|
i = i + float(imag)/100.0;
|
2019-12-23 09:03:59 +00:00
|
|
|
ro = ro + float(real)
|
|
|
|
io = io + float(imag)
|
2019-12-21 20:46:23 +00:00
|
|
|
|
|
|
|
mm = mandelbrot(r,i,100)
|
2019-12-23 11:19:49 +00:00
|
|
|
if mm > 98:
|
|
|
|
print "you are in the STABLE zone "
|
|
|
|
if mm < 21:
|
|
|
|
print "you are in the CHAOS zone "
|
2019-12-21 20:46:23 +00:00
|
|
|
print "Stability factor=",mm," x=",ro*100,"y=",io*100
|
|
|
|
if mm > 20 and mm < 80:
|
|
|
|
print "you won"
|
|
|
|
|
|
|
|
real = raw_input("player 2: Real: ")
|
|
|
|
imag = raw_input("player 2: Imag: ")
|
|
|
|
|
|
|
|
r = r + float(real)/100.0;
|
|
|
|
i = i + float(imag)/100.0;
|
2019-12-23 09:03:59 +00:00
|
|
|
ro = ro + float(real)
|
|
|
|
io = io + float(imag)
|
2019-12-21 20:46:23 +00:00
|
|
|
|
|
|
|
mm = mandelbrot(r,i,100)
|
2019-12-23 11:19:49 +00:00
|
|
|
if mm > 98:
|
|
|
|
print "you are in the STABLE zone "
|
|
|
|
if mm < 21:
|
|
|
|
print "you are in the CHAOS zone "
|
2019-12-21 20:46:23 +00:00
|
|
|
print "Stability factor=",mm," x=",ro*100,"y=",io*100
|
|
|
|
if mm > 20 and mm < 80:
|
2019-12-23 11:19:49 +00:00
|
|
|
print "you found the RAGGED EDGE OF CHAOS YOU WON"
|
2019-12-21 20:46:23 +00:00
|
|
|
|