Professional Documents
Culture Documents
Assignment # 2
Joudet Ahsan
17-CS-24
Sir Awais Awan
28-November-2020
17-CS-24@students.uettaxila.edu.pk
The forthcoming Artificial Intelligence (AI) revolution: Its impact on society and
firms
This paper is about Artificial Intelligence (AI) Revolution and its impact on all aspects of our
society, firms and life in general by evaluating predictions made in 1995 for the year 2015.
The paper is divided into 4 sections and the highlights of the sections are;
1. The first section overviews the predictions made in the 1995 paper for the year 2015,
identifying successes and failures (hits and misses)
2. Second section investigates existing and forthcoming technological advances in the
field of AI and the ability of computers/machines to acquire real intelligence.
3. Third one of the sections, sums up the impact of the AI revolution and describes the
four major scenarios being advocated, as well as what could be done to avoid the
possible negative consequences of AI technologies.
4. In the fourth part, discussions about how firms will be affected by these technologies
that will transform the competitive landscape, how start-up firms are founded, and
the way success can be achieved is discussed.
5. In the conclusion, speculations about the future of AI and its impact on our society,
life, firms and employment are briefed.
Conclusions
There are concerns, about AI might overtake us. This conclusive quote,
Thinking about the risks associated with emerging AI technology is hard work, engineering
potential solutions and safeguards is harder work, and collaborating globally on
implementation and monitoring of initiatives is the hardest work of all. But considering all
that is at stake, I would place all my bets on the table and argue that the effort is worth the
risk many times over”
Code
from copy import deepcopy
import numpy as np
import time
# takes the input of current states and evaluvates the best path to goal state
def bestsolution(state):
bestsol = np.array([], int).reshape(-1, 9) #take the input
#1
#2
#3
#4
#6
#5
#turns it into an array, reshaping it like (-1 0 1 2 3...)
while count != -1:
bestsol = np.insert(bestsol, 0, state[count]['puzzle'], 0)#level of the tree is here, best path (up, down,left..
#which ever is better is returen
# this function checks for the uniqueness of the iteration(it) state, weather it has been previously traversed or
not.
def all(checkarray):
set = []
for it in set: #set unique
for checkarray in it:
return 1 #if unique
else:
return 0
# calculate Manhattan distance cost between each digit of puzzle(start state) and the goal state
def manhattan(puzzle, goal):
a = abs(puzzle // 3 - goal // 3) #floor division
b = abs(puzzle % 3 - goal % 3) #modulus
mhcost = a + b
return sum(mhcost[1:])
#thiss is hn because gn moves one step...
# will calcuates the number of misplaced tiles in the current state as compared to the goal state
def misplaced_tiles(puzzle, goal):
mscost = np.sum(puzzle != goal) - 1 #cost to go from current to goal state
return mscost if mscost > 0 else 0 #if cost is zero i.e already in goal state return 0 cost
# initializing the parent, gn and hn, where hn is manhattan distance function call
costg = coordinates(goal) #position of tile is taken and added to costg
parent = -1
g_cost = 0
h_cost = manhattan(coordinates(puzzle), costg) #manhatten is calculated
state = np.array([(puzzle, parent, g_cost, h_cost)], dtstate)
# state array keeps the current state, its parent, gn(usually 1) and hn heuristic value
#position is location i.e 0 1 2(on top of the puzze
# We make use of priority queues with position as keys and fn as value.
dtpriority = [('position', int), ('fn', int)] #full node.
priority = np.array([(0, h_cost)], dtpriority) # heuristic value and priority is kept in an array
if (n == 1):
state, visited = evaluvate(puzzle, goal)
bestpath = bestsolution(state)
print(str(bestpath).replace('[', ' ').replace(']', '')) # as best solution is returned with square brackets
# so remove the square bracket with blank space
totalmoves = len(bestpath) - 1 # moves are one less than the total path
print('Steps to reach goal:', totalmoves)
visit = len(state) - visited
print('Total nodes visited: ', visit, "\n")
print('Total generated:', len(state))
if (n == 2):
state, visited = evaluvate_misplaced(puzzle, goal)
bestpath = bestsolution(state)
print(str(bestpath).replace('[', ' ').replace(']', '')) # as best solution is returned with square brackets
# so remove the square bracket with blank space
totalmoves = len(bestpath) - 1 # moves are one less than the total path
print('Steps to reach goal:', totalmoves)
visit = len(state) - visited
print('Total nodes visited: ', visit, "\n")
print('Total generated:', len(state))
Input
Output
To move from one state to the other. So, if we move from one level to another, only a cost of 1 is inflicted,
because only one step is taken (up, down, left or right). So, this relates to the depth of the tree, depth = 0, cost
would be zero. i.e. at first the cost is also zero, since no tile has been moved. To go to the level 1 or depth =1,
the cost is 1 and so on.
Bibliography
(n.d.). Retrieved from
https://github.com/harshkv/8_Puzzle_Problem/blob/master/8PuzzleProblem.py