Search This Blog

Sunday, January 27, 2019

Book Review: Time Travel, a history

Time Travel, by James Gleick is subtitled " A history".  In it, Gleick traces the origins of the idea of "time travel", which did appear in a way as part of some stories from time to time (such as a Connecticut Yankee in King Arthur's Court), but that Wells' Time Machine made it explicit.  Paired with this is that physics, in the early 20th Century now also started investigating the nature of time as "the fourth dimension" of spacetime and that physicists were working on the mathematics to try to see if time travel a la Wells was allowed by Nature.  Gleick takes his cues from literature (mostly science fiction) and physics, launching into detailed discussions of the philosophical ramifications of the ideas.
Clearly from the fact that the chapters usually end in questions, time is something that humanity experiences constantly but it has a slipperiness that evades a good definition.  If somehow one could get outside of time to examine it from a different perspective one could make some sense of what it is.  But even this thought, if someone tries to clarify it, is found to be either so vague as to be meaningless or full of unresolvable paradoxes.  Every consideration regarding backward travel in time ends up into a discussion of determinism vs. free will.  Forward time travel at an increased rate is perfectly acceptable and there is a technical solution: park a space ship close to a black hole for a couple of days and when you head back to civilization, you will find centuries have passed.  So far, it seems that it is a one-way ticket though.
I have a hesitation in recommending this book.  If one has not thought deeply about the subject of time and time travel, there are many naïve thoughts that Gleick destroys, but one gets frustrated because I did not get the sense that something was suggested as backfill.  Further, since I am listening to it as an eAudiobook borrowed from the library, the convolutions created in some of the argumentation that I covered become unclear.  Some of the subtleties are not brought out in the contrast as well as I would have liked.  Nonetheless, there are many rewarding aspects and the book has been deeply researched.  The variety of references and sources, from Wells to Spock, philosophers to physicists, is astounding and surprising in some cases.  If you have thought philosophically about time and time travel and enjoy science fiction, then you will relish this book.  For the average person, it is ahead of its time.

Executive Order 13825: Manual for Courts-Martial

What the Executive Order says

Executive Order (EO) 13825 is entitled "2018 Amendments to the Manual for Courts-Martial, United States" and has 12sections.  It was originally issued in March 2018.

Section 1

This section indicates that the changed versions of Parts II, III and IV of the Manual for Courts-Martial are included as Annex 1 to the EO.

Section 2

This section indicates that for when the change was effective, that you can't be charged with a crime nor have the charges dropped due to a change regarding the deed in the changes made today.

Section 3

This section discusses the Military Justice Act of 2016, which is PL 114-328.  Section 5542 directs the President to prescribe implementing regulations for all of the changes listed in Division E of the Law.

Section 4

So while Annex 1 shows a bunch of changes made, there are further changes in Annex 2.

Section 5

This section indicates that the changes in Annex 2, unlike the changes in Annex 1, take effect in the future.  The language here again indicates that people can't be made guilty or innocent for deeds committed on the opposite side of the effective date.

Sections 6 through 12

These sections makes further clarifications regarding the applicability and interpretation of certain sections of PL 114-328.  It is not clear to me why they had put things into different sections of the EO, especially since the date of effect is January 1, 2019 for almost all of the items listed in these sections.

My Commentary

The preamble, which sets out the authorities on which this EO is issued, indicates that by 10 USC 801, Congress has deemed that the President has the authority to direct and define the justice processes and military law applicable within the military.  Insofar as adjudication of incidents involving both military and civilian participants, it is not clear whether military or civilian law has precedence.  So prior to this, I had been under the false belief that Congress also defines military law, but apparently it does not.  A scan of new articles on the topic, especially since a lot of the changes are going into effect this past month, leaves me with the impression that it is regarding crimes of a sexual nature that are affected the greatest.



Saturday, January 26, 2019

Executive Order 13824: Sports, Fitness, and Nutrition

What the Executive Order Says

Executive Order (EO) 13824 is entitled "President's Council on Sports, Fitness, and Nutrition" (note the Oxford comma) and has 2 sections.  It was issued in February of 2018.

Section 1

This section revokes EO 13545 which the previous President used to establish his "President's Council on Sports, Fitness, and Nutrition."

Section 2

With EO 13545 having been revoked, EO 13265 comes back into force, but this section makes a number of changes to the text of it.  However, technically, the changes listed interfere with each other.  Section 5 is changed by (c), then renumbered by (d) and then further changed by (a) (b) (c) which are under (d).

My commentary

So I characterized this as word soup.  It is so hard to read documents that are created this way.  You have to be able to access the original plus the list of changes and then work through the integration of the changes into the original.  Having pieced together what the final version is, it creates a council and, depending on whether the administration and the council take the charge seriously, it could do some good things or not.
One point made in the purpose section is that team sports participation by children has declined.  I have to ask what is so special about team sports.  I have found these kinds of organized leagues and teams to be expensive and a proportion of the people involved petty and vindictive.  There is the cliché of the one kid who is on the team but never gets to play.  It's a cliché because it does happen even though it really should not.  Physical exercise need not be an organized sport, whether team or individual.  The real justification here should have been statistics about children's and young adult's health.  But talking about that would get into the third rail of "HealthCare" and Republicans simply do not have a defendable alternative to the current system to offer.  But the statistics show there is room for improvement.
Further, this is one of the things that it seems that Presidents use to play one-upmanship games with.  We've seen a couple of these kinds of EO's issued in our review.  Here, EO 13824 revokes EO 13545 which itself largely modified EO 13265 which itself revokes EO 12345.  The President's council can be reviewed here.

Wednesday, January 23, 2019

Executive Order 13823: Terrorists

What the Executive Order says

Executive Order (EO) 13823 is entitled "Protecting America Through Lawful Detention of Terrorists." and has 4 sections.  It was issued in January 2018.

Section 1

This section starts awkwardly citing "long-standing law of war principles" which I guess is trying to reference the Geneva Convention. This section is subtitled "Findings" and tries to present a justification as to why the US can detain persons considered enemies of the US at the Guantanamo Bay Naval Station.

Section 2

This section revokes Section 3 of EO 13492.  That EO and that specific section called for the closure of the detention facilities at Guantanamo by January of 2010.  Clearly, that never happened.  Section 2(c) allows for transport of additional detainees to Guantanamo.  Section 2(d) has several layers of irony in asking for a report from the intelligence agency to recommend policies on prisoners of war and the use of the Guantanamo Bay Detention facility.  First, because the EO's seem to always look for a report to be written, second because there are news stories and books published detailing how the current President does not listen to the Intelligence Services anyway.  The last subsection references EO 13567 from March of 2011.  That EO set up a review process for period reviews of detainee files to expedite a final disposition so that detainees could be all removed from Guantanamo.  Subsection 2(e) of EO 13823 stipulates that any new detainees would be subject to the same periodic reviews.

Section 3

This section adds some language that restricts the applicability to those persons captured during an armed conflict, and in the case they are American citizens, that this does not deprive the detainees of their rights as citizens.

Section 4

This section includes language to limit the applicability such that is does not conflict with applicable laws or create any legal liabilities against the US Government.

My commentary

The most significant item in this EO is 2(a) wherein section 3 of EO 13492 is revoked.  That section had mandated that the authorities work to remove all the prisoners held at Guantanamo Bay Naval Base and close the detention facility.  As such, the detention facility is to be used in an ongoing fashion to detain existing and new detainees as necessary.  The EO is fairly symbolic as it stakes out the administrations attitude towards prisoners of war and other individuals considered "enemies of the US" (except, of course, journalists).
The funny thing about life to me is that when you go looking for something, more often than not, you seem to find it.  Thus the way to find good things in life is to go looking for those good things.  If the US spends a lot of resources looking for enemies, she shall certainly find them.  And here is the stark contrast between the erstwhile and present administrations: one looked for friends, the other for enemies.  Hence the 180 degree shift in policy from emptying the detention facility at Guantanamo to using it for more found enemies.

Sunday, January 20, 2019

Executive Order 13822:Supporting Veterans

What the Executive Order Says

Executive Order (EO) 13822 is entitled "Supporting our veterans during their transition from uniformed service to civilian life" and it has 3 sections.  This EO was issued in January 2018.

Section 1

This section defines the policy which is that veterans need better access to mental healthcare services including suicide prevention resources.

Section 2

This section has 3 subsections.  (a) directs the Secretary of Defense, Secretary of Veterans Affairs and the Secretary of Homeland security to do something.  Doesn't really say what they should do.  (b) mandates that the group mentioned need to submit within 60 days a Joint Action Plan.  (c) mandates that a follow-up report on the progress of implementation of the Joint Action Plan be issued within 180 days.

Section 3

This section includes general provisions that limit the authority of the EO to ensure that it does not overstep legislative and constitutional limits.

My Commentary

I have looked on the internet for the Joint Action Plan and follow-up report since due to the age of this EO, it clearly should be available.  On the Veterans Affairs website, I found this updated action plan.  This plan defines 16 actions to be implemented that will support the reduction in suicides and mental health incidents for veterans.  I found this status update report dated July 9, 2018 although it is watermarked "DRAFT".  I would like to think that this had made a difference in at least some veteran's lives.  But it is not clear that there has been much success and since there does not seem to be any mandated report to follow up the implementations (while most of the 16 actions were "On track", none were expected to be completed until mid-2019), we may never know.

Saturday, January 19, 2019

Executive Order 13821: Rural Broadband Internet

What the Executive Order Says

Executive Order (EO) 13821 is entitled "Streamlining and Expediting Requests to Locate Broadband Facilities in Rural America".  It has 4 sections and was originally issued in January of 2018.

Section 1

This section defines the policy.  It first states that internet access is rural areas is a problem that can be an obstruction to growth, development, and jobs.  The actions being taken are indicated as aiming for regulatory reform and reduction.  The last paragraph indicates that continued implementation of section 6409 of PL 112-96 shall be pursued.

Section 2

This section has 5 different subsections.  The Administrator of General Services is directed to make a review of the common form application and based on the review, due in July of 2018, make changes to the form.  (c) directs various bureaucrats to review and approve requests to mount antennas on Federal Property. (d) and (e) mandate that quarterly reporting is generated on the application process.

Section 3

This section includes definitions for the terms "Federal property managing agencies" and "Federal real property".

Section 4

This section contains general provisions that limit the authority of the Executive Order so as not to appear to override existing laws or create any liabilities for the US Federal Government.

My commentary

So overall, this policy amplifies a policy that was created by a previous congress and simply creates some reporting requirements around it.  Now the GSA has to report the number of applications that were received to mount microwave band antennas on the roofs of federal buildings.  I have not been able to find these reports anywhere.  How exactly this helps get broadband to everyday rural citizens is a bit mysterious to me.  I don't think this EO was terribly effective to change anything.
There are some political ironies in the issue of this EO.  First, the current administration is highlighting and endorsing a policy that was created under the previous administration.  The current administration has been strongly pushing for elimination and relaxation of regulations and why this seems only to be a step sideways instead of in the direction of elimination is unclear to me.
I can see that cell towers and similar communications array facilities are subject to the NIMBY effect where everyone wants these to be built, but just not on, beside or near their particular home or business.  The 112th congress seemed to have it right in mandating that it be allowed to have such communication arrays put on federal land when necessary due to local resistance to siting.  One of the sub-texts here is that siting requests that are being held up on environmental impact or other such concerns are the culprit.  Of course there is only a limited amount of space on federal land and the federal government needs to hold some in reserve for future internal needs.  As such, I suspect that the agencies where there have been proposals have jealously guarded the capacity.
In terms of implementation, I have found little to support that any real action happened after the issue of the EO.  However, this FCC report seems to echo a number of the concerns listed in the EO about the slowness of the process for siting approvals.  This topic has been discussed often and for quite some time.  One opinion piece that I found attributed the slowness of rural broadband expansion to the FCC dragging their feet on any number of regulatory or permitting issues.  This EO was just preceded by a memo to the Secretary of the Interior.  I think that the issue and vacuous nature of the memo and EO point to policy arguments within the administration.  Expanding broadband internet may not be appealing to the free market (well, really it is an oligopoly) and I feel that some government intervention in the market is warranted.

Thursday, January 17, 2019

Executive Order 13820: Termination of Election Integrity Commission

What the Executive Order says

Executive Order (EO) 13820 is entitled "Termination of Presidential Advisory Commission on Election Integrity" and has 2 sections.  It was originally issued in January of 2018.

Section 1

This section revokes EO 13799 from May of 2017.

Section 2

This section includes the standard fine print asserting the constitutionality of the EO.

My Commentary

Well, after a lot of controversy, the commission on Election Integrity, which was intended to try and prove that 3 -5 million fraudulent votes had been cast in favor of the Democratic nominee such that the President had won the popular vote, was shut down.
With respect to the politics of the situation, it was really quite a serious embarrassment for the Republican party, but it was necessary since the commission had been repudiated and it had become clear that it was established on a lie.  See my commentary here.

Book Review: What is real?

What is real? by Adam Becker is on the topic of quantum physics.  Becker is trying to answer the title question which has been debated very much in quantum physics due to the prevalence of the Copenhagen interpretation which was championed by Bohr.  In that interpretation, it was considered taboo to think that the solutions to the quantum wave equation represented actual particles, photons and objects since the world was divided between objects that obey the quantum laws and measuring devices which do not.  Becker is clearly infuriated by the Copenhagen interpretation, attacking it on numerous fronts including thinly veiled ad hominem arguments on the proponents of the theory.
In its place, he provides the outlines of several different theories including the many worlds interpretation, the pilot wave theory and the spontaneous collapse theory.  He admits that there are still problems to be resolved but stresses that not all is solved by the Copenhagen interpretation either.
Becker's answer is that there must be real objects that are described by the mathematics.  This is Scientific Realism.  I also agree that there must be something there even though we can only observe it in effects rather than directly.  Boltzmann created statistical mechanics to describe the motions of atoms as the basis for deriving thermodynamic properties of substances, but no one doubts that the atoms that are being described don't exist.  There is still some science to be done, but eventually, we will have a similar understanding even if the Schrodinger wave equation is only considered a similar statistic tool to predict behavior macroscopic properties or results rather than being able to actually be applied to individual objects like Newton's laws of motion.
The approach is heavily biographical.  A lot of details about people's lives are included.  Becker also makes the point that the way things turned out at times was heavily dependent on the people and circumstances and that in fact the orthodoxy of Bohr's position could have crumbled much earlier if things had happened just a little differently.  There is a quite a bit of discussion regarding logical positivism as well as Popper's theory of falsifiability.  This is very much a book that considers the topic from a philosophical point of view highlighting the metaphysical and epistemological questions that are raised from the counterintuitive results of the mathematics and experiments that have verified the predictions of the theory.  It is very clear, unless humans still don't understand quantum physics well enough, it is non-local at least some of the time which has huge consequences with regard to normal people's understanding of causality.  But, similar to when Einstein shows that two observers can differ on whether two events are simultaneous, non-locality must be limited such that it doesn't play a large role for macroscopic objects at non-relativistic speeds of the everyday world.
I borrowed the downloadable audit book from the local library and halfway through came to the realization that I had in fact read it some time ago as a physical book.  Not too disappointed, I enjoyed it again.

Sunday, January 13, 2019

Executive Order 13819: Adjustment of Certain Rates of Pay

What the Executive Order Says

Executive Order (EO) 13819 is entitled "Adjustment of Certain Rates of Pay" and has 8 sections.  This EO defines the rates of pay for political appointees.  This is an annual item.

Section 1

This section references schedules 1, 2, and 3 as the rates of pay for General, foreign service and regarding the Veterans Health Administration and the Department of Veterans affairs.

Section 2

This section references schedule 4 for the rates of pay for Senior Executives.

Section 3

This section references schedules 5, 6 and 7 for the rates of pay for the Executive, the Vice President and Congress, and for justices and judges.

Section 4

This section references schedule 8 for uniformed service pay rates.

Section 5

This section references schedule 9 for locality based comparability payments.  The requirements of publishing notice regarding locality based comparability payments was done in this OMB notice in March, 2018.

Section 6

This section references schedule 10 for the rates of pay for administrative law judges.

Section 7

This section defines when the rates of pay come into force which is either Jan 1, 2018 or the first day of the first applicable pay period after Jan 1, 2018.

Section 8

This section indicates that Executive Order 13756 was superseded by this EO.

Schedules

There are 10 schedules attached to the Executive order

My Commentary

This Executive Order is part of the normal running of the government.  Each year the pay rates are set as required.  This EO was superseded in December 2018 as the rates were again changed.

Saturday, January 12, 2019

Executive Order 13818: Sanctions against persons

What The Executive Order Says

Executive Order (EO) 13818 is entitled "Blocking the Property of Persons Involved in Serious Human Rights Abuse or Corruption" and was issued December 20th, 2017 and it was continued a year later in December 2018.  It has 13 sections, a preamble and an annex.  The annex lists 13 specific persons to whom the sanctions listed in the EO apply.  The preamble declares a national emergency due to the threat imposed by human rights abuses and corruption around the world that threaten the national security, foreign policy and economy of the US.

Section 1

This section decrees that a freeze be implemented on the financial assets of persons named in the Annex.  Also anyone in the US who conducts business with the names persons will end up with their assets frozen.  Despite the freeze, there may be exemptions due to statutes and regulations and current contracts can be fulfilled.

Section 2

This section suspends the ability of the names persons to enter into the United States, whether for immigration or non-immigration purposes.  Then it refers to an old Proclamation (no. 8693) as to how to apply the rules.  In review, it is noted that use of that Proclamation seems formulaic or else it is really well written.

Section 3

This Section prohibits donations in lieu of commercial transactions.

Section 4

This section expands on the prohibitions in section 1.  These specific items are intended to emphasize that doing business with the named persons is illegal.

Section 5

This section prohibits transactions or conspired transactions which would circumvent the prohibitions defined in this EO.

Section 6

This section defines the terms "person", "entity" and "United States person"

Section 7

This section provides justification for not including a notice period.

Section 8

This section delegates to the Secretary of the Treasury to take whatever steps are allowed by the Statute and are necessary to implement the Executive Order.  The Secretary can then request other federal agencies to take actions to implement the Executive Order.

Section 9

This section delegates to the Secretary of State the necessary authority to carry out the actions specified in section 2 of this EO.

Section 10

This section delegates the authority to end the blocking of property to the Secretary of the Treasury.

Section 11

This section delegates the submittal of reports required by 50 USC 1641(c) and 50 USC 1703(c) to the Secretary of the Treasury.

Section 12

This section defines the date and time at which the Executive Order comes into force.

Section 13

This section includes the legal fine print necessary to ensure compliance with the constitutional limits on the executive branch.

Annex

In the Annex are listed 13 persons from all over the world.

My commentary

I honestly cannot remember what, if any, international events might have lead up to the issue of the particular Executive Order.  It is of the type wherein the forces of normalcy had snuck in and wrested a victory from the jaws of chaos that have normally consumed the administration.  However, I really have some angst with the fact that human rights abuses and corruption in general are being used as a justification to invoke a national emergency.  It would make more sense if there was a particular instance that needed to be made an example of.  The pre-amble is weak in the justifications provided.  That's not to say I disagree with taking action against the people listed in the Annex.  There was something political in framing it through a) scare tactics and b) through a Presidential Executive Order rather than simply pursuing justice through the Justice Department and Intelligence agency black ops.
The text itself should have been almost boilerplate, if you run a search on Proclamation 8693, you can see that this kind of thing has been issued on a regular, maybe infrequent, but certainly regular basis and yet Section 4 of the EO looks like it was jammed in there at the last minute before signing.

Friday, January 11, 2019

Book Review: Code Warriors

Code Warriors by Stephen Budiansky is about the history of the NSA and covers aspects of code usage and code breaking.  I listened to the audiobook version over about 2 weeks.  The book focuses on, firstly, a lot of details about codes and ciphers and covers the WW II era in quite a lot of detail including recounting the famous deciphering of messages encrypted by the German Enigma code machines.  It discusses how through some mathematics, you can create systems that are practically unbreakable through brute force methods on conventional computers or even computers that might have 10 or 1000-fold improvements over current technology.  There is a lot of discussion in the later part of the book regarding bugs and other methods that have been employed and documented in the 50's, 60's and 70's to be able to get information without having to resort to breaking the code (clear text intercepts, either prior to encryption by the sender or after decryption at the destination).
The book was fascinating because of the shear amount of detail as well as the reconstruction of some well known events in history, for example the Cuban missile crisis, with a commentary of how the state of the art encryption and code breaking played a part to inform the decision makers of salient details that were not known publicly.  However, I found that in some places the progress in the narrative became excruciatingly slow simply because of the long descriptions of the fine details of the innards of various coding and decoding machines.
The author uses the technique of trying to make history interesting through narrating events through the eyes of whomever seems to have had the most interesting character that was involved in the incident.  And I think it gets overused since it started to feel like the book was a biography at a few points rather than about encryption and code breaking.
The opening describes Edward Snowden's flight with lots of information to Russia from the NSA.  At the very end, there is a little bit of a loop back to this incident.  The author tries to describe why the NSA was doing some of the things it was doing and also does elaborate how these activities are anathema to democracy.  However, we don't really get to a clear picture of the philosophical conflict between privacy and security that the revelations of the sweeping NSA surveillance programs that were brought to light by Snowden.  At best, it is framed as privacy vs. bureaucracy with a caveat that the political leaders should have the personal moral integrity not to use the spy agencies for personal or political advantage wherein Nixon and his enemies list is provided as a case study.
As such, it is difficult for me to strongly recommend the book unless you happen to have a great interest in both 20th century history and the theories that underpin codes and ciphers.  If only one of the two topics interest you, it'd tell you to read it, but be prepared to skim over some parts that might be out of scope for you.

Friday, January 4, 2019

Python version of Game of Life Cellular Automata

Hi again everyone!  I've been busy and have made a nice Game of Life/Cellular Automata program in Python.  It took a couple of hours but here it is.  I used the TK interface for the windows and not a whole lot else, it is, after all a pretty simple program. 

Here are a few screen shots:


I think the red with black borders is pretty.



Here's the program:

from Tkinter import *
from random import randint
from time import sleep
class App:
    """This class is derived, I think, from a TK class and is designed to
    work with the TK environment.
    Requires imports from Tkinter, math, random and time"""
    def __init__(self, master):
        """This class is the whole of the application """
        # Necessary Frames
        frame = Frame(master)
        control_frame = Frame(frame)
        control_frame.grid(row = 0, column = 0, sticky = N)
        canvas_frame = Frame(frame)
        canvas_frame.grid(row =0, column = 1)
        #Application variables
        self.is_running = 0
        self.grid_data = []
        for i in range(160):
            self.grid_data.append([])
            for j in range(160):
                self.grid_data[i].append(0)
        self.color_code = 1
        # 0 = not used, 1 = blue, 2 = black, 3 = red, 4 = green
        self.colors = ['pink','blue','black','red','green']
        self.speed = 5
        self.speeds = [5,2,1,0.2,0.02]
        self.speed_str = ['Really slow','Slower','Slow','Fast','Faster',
                           'Max Speed']
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
       
        #Control FrameWidgets
        self.lab = Label(control_frame, text=self.tmpstr)
        self.lab.pack(side = TOP)
        self.b1 = Button(control_frame, text='Randomize')
        self.b1.config(command=self.randomize)
        self.b1.pack()
        self.b2 = Button(control_frame, text='Start')
        self.b2.config(command=self.go_live)
        self.b2.pack()
       
       
        # The Canvas
        self.canvas = Canvas(canvas_frame, width = 800, height = 800)
        self.canvas.config(bg='white')
        self.canvas.pack()
        frame.pack()
        #Menu's
        menubar = Menu(root)
        menu_1 = Menu(menubar, tearoff=0)
        menu_1.add_command(label='Quit',command=root.destroy)
        menubar.add_cascade(label='File', menu=menu_1)
        menu_2 = Menu(menubar, tearoff=0)
        menu_2.add_command(label='Really slow', command=self.menu_2)
        menu_2.add_command(label='Slower', command=self.menu_3)
        menu_2.add_command(label='Slow', command=self.menu_4)
        menu_2.add_command(label='Fast', command=self.menu_5)
        menu_2.add_command(label='Faster', command=self.menu_6)
        menu_2.add_command(label='Max Speed', command=self.menu_7)
        menubar.add_cascade(label='Speed', menu=menu_2)
        master.config(menu=menubar)
        menu_4 = Menu(menubar, tearoff = 0)
        menu_4.add_command(label='Blue', command=self.color_blue)
        menu_4.add_command(label='Black', command=self.color_black)
        menu_4.add_command(label='Red', command=self.color_red)
        menu_4.add_command(label='Green', command=self.color_grn)
        menubar.add_cascade(label='Color', menu=menu_4)
    def randomize(self):
        """ This function deletes the current data and seeds with a new
        set of randomly placed dots"""
        if self.is_running == 0:
            for i in range(160):
                for j in range(160):
                    self.grid_data[i][j] = 0
            for i in range(2400):
                x = randint(0,159)
                y = randint(0,159)
                self.grid_data[x][y] = 1
            self.canvas.delete(ALL)
            self.update_once()
    def go_live(self):
        """This function stops and starts the simulation."""
        if self.is_running == 0:
            self.b2.config(text='Stop')
            self.is_running = 1
            self.run_sim()
        else:
            self.b2.config(text='Start')
            self.is_running = 0
    def update_once(self):
        """This function draws the screen"""
        for x in range(160):
            for y in range(160):
                if self.grid_data[x][y] == 1:
                    self.canvas.create_rectangle(x*5,y*5,x*5+4,y*5+4,
                            fill=self.colors[self.color_code])
        self.canvas.update()
    def run_sim(self):
        """This is the main loop for the simulation.  Calc new grid,
        copy it, then calls update_once to redraw the screen."""
        new_grid = [] # local variable to store intermediate result
        for i in range(160):
            new_grid.append([])
            for j in range(160):
                new_grid[i].append(0)
        while self.is_running == 1:
            for i in range(160):
                for j in range(160):
                    neigh = self.grid_data[i-1][j-1]
                    neigh += self.grid_data[i][j-1]
                    neigh += self.grid_data[(i+1) % 160][j-1]
                    neigh += self.grid_data[(i+1) % 160][j]
                    neigh += self.grid_data[(i+1) % 160][(j+1) % 160]
                    neigh += self.grid_data[i][(j+1) % 160]
                    neigh += self.grid_data[i-1][(j+1) % 160]
                    neigh += self.grid_data[i-1][j]
                    if neigh < 2 or neigh > 3: # cell dies
                        new_grid[i][j] = 0
                    elif neigh == 3: # cell lives or is born
                        new_grid[i][j] = 1
                    else: # cell is the same as previous tick
                        new_grid[i][j] = self.grid_data[i][j]
            for i in range(160):
                for j in range(160):
                    self.grid_data[i][j] = new_grid[i][j]
            self.canvas.delete(ALL)
            self.update_once()
            if self.speed < 5:
                sleep(self.speeds[self.speed])
    def color_grn(self):
        """This function sets the color of th elines to green and then
        refreshes the screen."""
        self.color_code=4
    def color_red(self):
        """This function sets the color of the lines to red and then
        refreshes the screen."""
        self.color_code=3
       
    def color_black(self):
        """This function sets the color of the lines to black and then
        refreshes the screen."""
        self.color_code=2
    def color_blue(self):
        """This function sets the color of the lines to blue and then
        refreshes the screen."""
        self.color_code = 1
    def menu_2(self):
        """ Sets speed to really slow"""
        self.speed = 0
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
        self.lab.config(text=self.tmpstr)
        self.lab.update()
    def menu_3(self):
        """ Sets speed to slower"""
        self.speed = 1
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
        self.lab.config(text=self.tmpstr)
        self.lab.update()
    def menu_4(self):
        """ Sets speed to Slow"""
        self.speed = 2
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
        self.lab.config(text=self.tmpstr)
        self.lab.update()
    def menu_5(self):
        """ Sets speed to Fast"""
        self.speed = 3
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
        self.lab.config(text=self.tmpstr)
        self.lab.update()
    def menu_6(self):
        """Sets speed to Faster"""
        self.speed = 4
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
        self.lab.config(text=self.tmpstr)
        self.lab.update()
    def menu_7(self):
        """ Sets speed to max speed"""
        self.speed = 5
        self.tmpstr = 'Speed:\n'+self.speed_str[self.speed]
        self.lab.config(text=self.tmpstr)
        self.lab.update()
if __name__ == '__main__':
    root = Tk()
    root.wm_title('Cellular Automata')
    app = App(root)
    root.mainloop()