Thursday, September 30, 2021

Double

 Playing the same code on pycharm and vscode. User is X!






More Good News

 Covid pill works against all variants including Delta, manufacturer says (msn.com)

Recurs

Downloaded ttt code lastnight

 https://github.com/juanesmendez/CS50-AI-Project0-tictactoe/blob/master/tictactoe.py


Plays OK:




          
*     *     *
Starting to see what 'recursion' is; a function that calls itself within

its execution is said to be recursive ie it recurs...

From W3 Schools:





...









Tuesday, September 28, 2021

More tic

My grasp of Python is just not up to the task; and I need

help to see what the coding paradigm I am trying for might look

like. So tomorrow, back to YouTube:



                                              *     *     *

I did look at a number of tutorials on pygame.



There is a pattern in what needs to be done:
-import pygame
-initiate pygame (so that all operating systems can be accessed)
-design a window with a call call display.set_mode
=one draws with display.flip(' screen') or display.update('items')

A Remedy

 https://www.pfizer.com/news/press-release/press-release-detail/pfizer-starts-global-phase-23-epic-pep-study-novel-covid-19

Monday, September 27, 2021

TicTT


Starting on the tictactoe assignment tomorrow:





German Elections

source: Libération, published on September 25, 2021 

author: Lucie Claudon

translation: GoogleTranslate/ doxa-louise

EPLANATION

German elections 2021: one polling day, but two votes

German federal elections 2021 

The citizens of Germany are called to the polls this Sunday to designate the members of the Bundestag who will choose the one who will succeed Angela Merkel.

This Sunday, 60.4 million Germans are called to the polls and, of these, 2.8 million will be able to vote for the first time. As in France, the right to vote is granted to all citizens over 18 years of age; they are thus automatically registered on the electoral listls.

How are  elections conducted?

Since 1949, the year of the creation of the Federal Republic of Germany, the election has been conducted according to a mixed system of majority vote and personalized proportional representation. Unlike France,  Germans citizens have two votes. On the one hand, citizens vote for the candidate for their constituency, who will sit as a member of the Bundestag (the equivalent of the National Assembly). In all, 299 parliamentarians are elected at the end of a uninominal vote by simple majority, said by "the first vote": the candidate obtaining the most votes, even without an absolute majority, is elected.

On the other hand, voters vote for parties, represented by national lists. This second vote is the most important because it defines the proportional distribution of the total number of seats in the Bundestag. Votes can be taken either by post or at a polling station.

The parties having access to Parliament are only those who obtained at least 5% of all the second votes. In theory, the Parliament consists of 598 members, but it happens that certain parties obtain more members by the direct way than by the proportional one. The number of seats is then increased. Since 2017, 709 MPs have been sitting. They are the ones who elect the chancellor, whose mandate lasts 4 years.

Who is in the running?

A total of 47 parties present 6,211 candidates, either on party lists or individually in constituencies across Germany. The six main parties which hope to share the seats in the Bundestag are the CDU (Christian Democrats), the SPD (Social Democrats) - the two great historic parties -, the environmentalists of Die Grünen (The Greens), the populist movement of extreme right (AfD), the liberals (FDP) and the radical left party Die Linke.

When will we know the future chancellor?

The parties are led to form coalitions at the end of the results, except if they obtain an absolute majority. This last happened in 1961. The Christian Democrats then won 50.2% of the vote and 270 seats. The time for negotiations can be long. After the 2017 elections, Angela Merkel's last term in office, it took her 117 days to arrive at a so-called black-red-yellow coalition (re party colors), which brings together the Social Democrats (SPD) and the liberals (FDP). Which makes local prognosticators say that Angela Merkel could stay in the chancellery ... until Christmas .


                                                                 *     *     *

Who won the German election? Final results show defeat for Merkel’s CDU as centre-left party wins | The Independent

Sunday, September 26, 2021

Debug

 With Python code from the below site, running a debug session

in VSCode.







Using the down arrow from the debug commands...



https://www.sqlshack.com/how-to-debug-python-scripts-in-visual-studio-code/

Saturday, September 25, 2021

Solve

 The proposed code works like a charm, for both the small

and the large data set:



The code, and very much modelled on that in the maze problem.

It is BFS:

                                       



*     *     *











DEBUG

 I have - up to this point - tested my code by writing

in print commands at varios points. This is more complicated, and

I now need to learn how to use a debugger to see what is going on.

so be it:




                                          *     *     *

VSCode debugger running on the Maze project...



Friday, September 24, 2021

Assignment degrees

 A little moment in coder confusion here. I need to remind

myself to think like a programmer, and not a coder. So far:




https://www.geeksforgeeks.org/python-return-statement/


                                                                          *     *     *



*     *     *
I am shameless, and plan to work with the below video tomorrow

morning.



Thursday, September 23, 2021

Assignment(s)

 I cold just tip-toe through this course the way I

did with the last: etting an overview. Bit thisone is

closerto what I already know about , like propositional

calculus in Logic. So, yep, I am going to be trying my hand

at the assignments. And get some real experience with python


The first lecture assignment has two elements:

degrees, which consists of writing code to find the degree of

separation between actores from their film roles.

Tic-tac-toe ( you guessed it), writing the play code for the computer.


Have downloaded the code packages; starting tomorrow morning.


https://cs50.harvard.edu/ai/2020/projects/0/

Wednesday, September 22, 2021

Minimax

 

Moving on with adversarial games, my AI lecture presented an Interesting explication 

of the Minimax, here thebasis for the pseudocode describing how a computer might play 

( and win at) tic tac toe. The idea is to play another game in which X is trying to maximize 

the score, and 0 is trying to minimize it. A terminal win for X is +1, one for O is -1,

and a draw is 0.




I can use alpha beta pruning to diminish the number of iterations: some paths 

are discourging from the get-go.


There are 255, 168 possible tic tac toe games. No computer is going to calculate

all that. An algorithm that shows more probabilities of winning might be 

good enough!! (Depth-limited minimax).

                                            *     *     *

(Don't want to misrepresent things here. Tic tac toe is always a draw if 

both sides play optimally 👧. And because the board can be turned and/or flipped

 - think see-through board - there are only three games, depending on

where the first move is) .

                                            *     *     *


GOT IT!!



Fall is here...

Tuesday, September 21, 2021

Morning After

 Congratulations to all who partcipated in yesterday's election: 

that was true grit, in difficult times.


From Wikipedia, the results in 2019 qnd 2021.(There was 1 Independent in 2019)




I am surprised that no one has mentionned that there is no provision in the constitution

about who might be competent to do things like carbon emissions trading. Going into the

future, this is no minor issue. And for those not following Quebec news, Mrs Anglade 

of the provincial Liberals announced yesterday that her party would endorse disinvesing

in gas and oil production within Quebec in 2022 (the next provincial election).


Oh, and  Canada's debt to GDP ratio might not be quite so fine. We are actually

number 3 behing Italy and Spain...




                                  *     *     *

The two search algorithms used so far had in common that they had

no connection with the peculiarities of the problem. Thus, one couldn't choose

for oeover the other a priori; they were uninformed. An informed algorithm uses 

information about the problem. 


Greedy Best-first search introduces a heuristic function to the problem In th case

of maze problems, one would choose the node known to be closest to the arrival

point. One can tell this won't always work, but it mght make life easier when it does.

The heurisric in the example below goes by the charming name of Manhattan distance,

which is the distance mesured by the coordinate system.






So voilà, using greedy best-first search does find a solution; but we will need to be

more clever to find an optimal solution.


A*search will do that. It will use both the Manhattan distance and  the cost of reaching the

node in the first place.











Monday, September 20, 2021

New Maze

 Having a spot of fun by making my own mazes.

Below, maze4.txt in stack and queue:





Sunday, September 19, 2021

Vote

 So Conrad Black thinks the only rational thing to do in this

election is vote for  Erin O'Toole. I wouldn't know: this election was 

so cutesy we didn't get to hear about some of the really important 

stuff, like International Affairs. Yet there it is, front and foremost in the

news. If Australia gets those nuclear-powered missiles - with bomb capability -

then China sees no alternative then to put them on the list of those

who should be bombed in the eventuality of war.


What?? Did I miss a turn here? Big to-do about no one paying their NATO

dues under Donald Trump, but that is NATO. North Atlantic Treaty Organiaztion, 

yesterday's war. The rumble is on somewhere else, in the Pacific. I looked

up if Canada had any submarines: we have four, and they are very well taken care of.

They do exercises...in the Mediterranean. But a smaller country than us, with a 

population of 25 million, is buying a lot of them, and getting grief from China about it.

It's a different game.


I am not trying to paint China as the enemy. But having them produce a lot of our 

material things and clothes has circulated quite a bit of money their way, which 

lets them buy things like Vancouver properties, tuition at Oxford, Chanel bags. We 

are tangled with them in various legal issues as well, such as the two Michaels. And 

don't get me going on the pandemic.


Distressing to me is that the major party leaders are all Quebecers: Truseau, Blanchet, 

O'Toole. And with his law degree, J.Singh might as well be one.  All trying to balance

culture and demography. Is there no institutional reponse to this that might allow us to move 

forward!?


Oh, and I think that Yves-Francois Blanchet - with a degree in Anthropology and History 

fromthe U. de M - should have been Minister of External Affairs during the whole 

Afghanistan crisis. Stop repeating himself..., earn his salary...


Thus from me: vote for the mp of your choice, and hang tight!


https://www.independent.co.uk/news/uk/home-news/aukus-pact-australia-britain-us-b1921897.html



Saturday, September 18, 2021

Search Algorithms

 There are two basic search algorithms examined in our lecture. One can

move between them by merely changing the code at line 128 from between

stack and queue.



Definitions

DFS (stack):



BFS (queue)



Maze1


On this first maze, both reach the correct solution in 11 - 1 moves.

Maze2





Again, both arrive at the optimal solution, but with very different search histories.

DFS is normally used for shortest route problems.

Maze3



Here, DFS stops at a long path. DFS is trusted for maze problems with a uniquesolution.


                                                              *     *     *