Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Abstract:

Linear algebra is a fundamental course in university mathematics that is easy to be understood.


Linear algebra is a branch of mathematics that deals with vectors and matrices, as well as finite
dimensional vector spaces, linear transformations, and matrix combinations in general. The goal
of our study is to implement our connect-four game using the concepts of linear algebra as
vectors and matrices and AI.

Introduction:

This paper discusses the importance of linear algebra and its applications in real life. A

real time connect-4 game was successfully designed and first published by Milton Bradley in

1974 and solved by Victor Allis is 1988. Connect-4 is a competitive game between two players,

the first who completes the target wins. Connect-4 game is played on a board of 7x6 squares, the

target is to get four discs in a row diagonally, horizontally, or vertically. Connect-4 is one of the

games which the player needs to make a strategy to choose his moves which require skills on the

part of the players. The game can be solved in a variety of ways such as using AI. AI has several

levels which are random which is the easiest to beat, defensive which makes blocking a win

priority and aggressive which makes winning a priority. Minimax is used in AI for decision

making to make the best move for the player in two-player games. There are some rules that

strategically can guarantee a victory for one player or a tie for both, such as Claimeven,

Baseinverse, Vertical, Aftereven, Lowinverse, Highinverse, Baseclaim, Before and

Specialbefore. Matrices are widely used in computer graphics. As Yip (2001) stated that “In

video gaming industry, matrices are major mathematic tools to construct and manipulate a

realistic animation of a polygonal figure. Examples of matrix operations include translations,

rotations, and scaling”. Playing Connect 4 resulted in both positive and negative insight and
search experiences, according to the studies. As a consequences, Connect-4 has the potential to

be used as a reliable elicitation instrument for both positive and negative problem-solving

experiences in future problem-solving investigations.

Lujain’s paragraph

The game Connect 4, with each move symbolizing a solving episode, was found as
having the potential to provide these experiences (where best to place the counter). Eighty people
played six games of Connect 4 against a computer, reporting each move as positive search,
positive insight, negative search, or negative insight. Then, to validate the experiences generated,
phenomenological assessments were gathered. The findings revealed that playing Connect 4
resulted in both good and negative insight and search experiences, with the majority of players
employing all four methods of problem resolution. These reported sensations were equivalent to
those produced by established laboratory approaches focusing on positive insight, according to
phenomenological assessments. As a result, connect 4 has the potential to be employed in future
problem-solving studies as a valid elicitation instrument of insight and search experiences for
both positive and negative problem-solving. According to Barrett’s (2014) The split of mental
processes into cognitive and emotional processes, according to Conceptual Act Theory, is a false
dichotomy, since both are consequences of integrated created experience rather than one being a
result of the other. It places valanced core affect at the center of mental events, which are
subsequently labelled cognitive, emotional, or perceptual. Moreover, connect 4 may be perceived
as providing more realistic problem-solving experiences than other paradigms in which a
sequence of challenges are addressed in order to achieve a single, overarching objective rather
than presenting separate, unrelated difficulties. In order to properly leverage this paradigm for
creative problem-solving research in experimental psychology and neuroscience, future study
will need to look at developing versions of Connect 4 with more control.
A sudden new knowledge, idea, or solution followed by an emotional Aha feeling is
known as an insight moment (Jung-Beeman et al., 2008; Klein and Jarosz, 2011). Eighty
individuals were recruited through university and neighborhood advertisements. The participants
were all above the age of 18 (Mage = 30.63, SDage = 12.64, range 18–66 years), with a mix of
native English speakers and those who spoke English as a second language (n = 10). Some of the
individuals had previously participated in longitudinal research comparing solution skills across
tasks. Additional physiological (heart rate and interoceptive heartbeat counting task) and
psychological assessments were collected in addition to the information presented here. A
repeated measures Bayesian ANOVA (IVs: Solving type and valence) was used for pleasantness
evaluations. Strong evidence of a major impact of valence (BF10 = 5.77e + 38) and moderate
evidence of no main influence of solution style (BF01 = 6.88) were found in the data (DV:
pleasantness). For both forms of solutions, positive moves were considered as more enjoyable
than negative actions. When looking at the graph (Figure (Figure2)2) that presents these data, it
appears that solution type and valence had an interaction impact, with insight moves being
scored as more positive and negative than search. When the main effects were included to a null
model and compared to one with interaction effects, it was found that there was poor support for
either model (BF = 2.35). There was strong evidence (BF10 = 266.70) for a main effect of
solving (IV) on surprise ratings (DV), with insight solutions being rated as more surprising than
search for both positive and negative moves. There was moderate evidence of no main effect of
valence (IV: BF01 = 3.36) or interaction effects (BF = 3.71 toward a null model including main
effects compared to interaction effects) on surprise ratings.

References
Hill1 G., Shelly M. (2018) Connect 4: A Novel Paradigm to Elicit Positive and Negative
Insight and Search Problem Solving.Kemp2
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6209650/

Real-Time Connect 4 Game Using Artificial Intelligence:


Sarhan et al. (2009) stated that:
The purpose of the Connect 4 game is to acquire four chips in a row, diagonally,
horizontally, or vertically, before your opponent. There are many different ways to solve
the Connect 4 game. There are several degrees of AI difficulty to choose from. They're
the random, defensive, and aggressive AI. Random, as the name implies, chooses a play
at random and is the most difficult to defeat. Defensive AI focuses on averting a victory,
whereas aggressive AI focuses on achieving victory. The simplest is random AI.
Algorithms for AI solutions come in many different forms and sizes, and they can be
rather complex. We looked at minimax, minimax with alpha-beta pruning, A*, and
influence maps. Minimax is the hardest to defeat because it is a recursive tree that uses
backtracking to find the optimum move, but it takes a long time to process. The
opponents are known as MIN and MAX. MAX is attempting to improve his score, while
MIN is attempting to lower MAX's score. This rule is then used by the software, which
searches for the best move several moves ahead. The Connect 4 game's AI was combined
into a real-time version using the waterfall software development model. The game can
now be played by one or two players. If two players were chosen, a timer may be used. If
only one player is selected, the AI may be easy, medium, or difficult. In one-player mode,
the hard level is the only one with a timer. (p.283)
References*

Sarhan, A., Shaout, A. & Shock, M. (2009). Real-Time Connect 4 Game Using Artificial

Intelligence: A Survey. Journal of Computer Science, 5(4), 283-289. Retrieved from:

https://www.thescipub.com/pdf/jcssp.2009.283.289.pdf

Matrices and its usage in computer games

A time ago graphics used in cartoon and cars and architecture were done by hand drawing but

now these things are done very easily by computer graphics especially the video gaming industry

is relying on computer graphics which is now done by the usage of matrices (Yip, 2001).

Matrices are used a lot in video gaming industry and as stated by Yip (2001), Matrices are

important mathematic tools in the video gaming industry for creating and manipulating a realistic

animation of a graphical figure. Translations, rotations, and scaling are examples of matrix

operations. Field of view, modeling, color transformation, and projection are examples of other

matrix transformation ideas. The ability to design 3D video games requires a basic knowledge of

matrices. As stated by Yip (2001), (x, y, z) can be represented as Points in R^3 and identified as

a homogeneous vector on the plane of R^4. If we convert a 3D point to a 4D vector, we can

represent a transformation to this point with a 4 x 4 matrix. So we can use matrices to make 4D

or 3D dimension this is called homogeneous coordinate transformation and this transformation

can be represented by this equation (Transformed Point = Transformation Matrix ´ Original


Point) and in other case a spanned plane by two vectors can be represented using this equation

(Transformed Plane = Transformation Matrix Original Plane) which is expressed by

transformation matrix multiplied by a 3*2 matrix consists of (a, b, c, d, e, f). Basically the

translation means “adding a vector to a point, making a point transform to a new point. This

operation can be simplified as a translation in homogeneous coordinate” (Yip, 2001) so by using

points and translate it make a reflection and makes shapes as graphics. Another way to explain

the usage of matrices in games is that two players let name them R and C, player R is believed to

have m possible moves, while player C has n possible moves. The movements of Rare being

used to name the rows from top to bottom of a m X n matrix, and the moves of C are being used

to label the columns from left to right (Azuaba, 2021).

References

Azuaba, E. (2021, January). Application of Matrices to the Theory of Games. Retrieved from:

https://www.researchgate.net/publication/348234443_Application_of_Matrices_to_the_Theory_

of_Games

Yip, T. (2001, March 12). Matrices in Computer Graphics. Retrieved from:

https://sites.math.washington.edu/~king/coursedir/m308a01/Projects/m308a01-pdf/yip.pdf
Research on Different Heuristics for Minimax Algorithm Insight from Connect-4 Game:

Connect-4 game is a chess game played on a board with seven vertical columns, each with six
squares. Two players alternate moves until four dots are linked horizontally, vertically, or
diagonally. Once a dot is placed in one of the columns, it will descend to the column's lowest
vacant square. Minimax is used in artificial intelligence for decision making. It is most
commonly used in turn-based two-player games like Tic-Tac-Toe, chess, and other similar
games. Minimax seeks to determine the best move for a player in our Connect-4 chess game,
provided that the opponent also plays optimally as stated by Kang et al. (2019). Max and Min are
the two players in Minimax. Beginning with Max's initial move, the Minimax algorithm will test
all possible combinations of Max's and Min's moves. When one of the players wins or the game
ends in a tie, the board's evaluation value is supplied to represent the board's current state. If any
aspects on the board work in Max's favor, they will be given a positive value. If not, a negative
value will be assigned. The total of all feature values is the final evaluation value. Max will
select the highest possible evaluation value, whereas Min will select the lowest possible value.
Max will eventually come to a decision. Minimax uses a heuristic function to analyze the current
state of the game. Minimax's ultimate choice is heavily influenced by the heuristic function's
performance. as mentioned by Kang et al (2019). Even though heuristics has been successfully
applied to minimax in Connect-4, there is significant room for future improvement such as
tuning method.
A Knowledge-based Approach of Connect-Four:

Although many people know the rules of Connect-four most of them know little about the way
the game should be played. It's possible that some strategic rules can be discovered that
guarantee a win for one player or a tie for both, such as Claimeven, Baseinverse, Vertical,
Aftereven, Lowinverse, Highinverse, Baseclaim, Before and Specialbefore. If the accuracy of
these rules can be established, evaluating a large number of positions to determine the game's
outcome is unnecessary if both players play appropriately. “Zugzwang is a very important
concept in playing Connect-Four” stated Allis (1988). Zugzwang is when a player is forced to
make a move he would rather not make. The force is just the fact that each turn requires only one
move. “Concluding, we have found a method where we can sometimes find a set of rules which
ensures the controller of the Zugzwang that he will not lose, since he can refute all the
opponents’ threats. If the method does not work, we can say nothing about the given position.”
(Allis, 1988). As a result, it is beneficial to establish as many rules as possible that may be used
in forecast the outcome of a game in as many scenarios as possible. VICTOR is a program that
implements specific principles, meeting one of the project's goals: a Connect-Four Shannon C-
type strategy program. Using the nine strategic rules mentioned earlier, a software has been
created to determine the value of a position. “One goal of the project was to show that a program
can be written using the Shannon C-type strategy” (Allis, 1988). This goal is not only achieved,
but it also demonstrates that the VICTOR program can always win while playing White. This
project has demonstrated that developing a Shannon C-type program is challenging due to the
extensive knowledge required stated Vector Allis (1988). Nevertheless, if enough information is
obtained, the software will be able to outperform all other programs and human beings.

References Used:

Kang, X.Y., Wang, Y.Q. and Hu, Y.R. (2019) Research on Different Heuristics for Minimax
Algorithm Insight from Connect-4 Game. Journal of Intelligent Learning Systems and
Applications, 11, 15-31. https://doi.org/10.4236/jilsa.2019.112002

Allis, V., A Knowledge-based Approach of Connect-Four. (1988)


Methodology:

We used a python code to implement our connect four game using the concepts of linear algebra

such as matrices and vectors. With the usage of NumPy Library which stands for numerical

python it works with arrays and has functions for the usage of linear algebra and matrices.

Our code:

We first took the dimensions of the matrix as input then we displayed the matrix ,and as long

as our game is not over we will continue with the following functions, first by creating the blue

and red pieces as a vector which we will use for the game and then we check for the valid rows

and columns and drop the pieces, after looping and inserting pieces in alternative order with 2

players we check whether player is winning or not by going through four conditions expressed as

left slopped, right slopped ,vertical and horizontal functions . Since the winning consists of 4

connected pieces, we check the vertical function by going through each column and loop through

4 rows, the function is true if a 4 variable vertical line is created then if this function fails we

check the second function which is the horizontal function we loop in the range of 4 columns and

loop through the number of rows then the function is true if we found a 4 variable horizontal line

is created if it fails then we go to the third function which is right slopped which we loop through

rows and columns in the range of 4 then we check if there is a 4 variable right slopped

line is created. If it fails, then we go to the fourth function which is left slopped which we loop

through rows and columns in the range of 4 then we check if there is a 4-variable left slopped

line is created

if one of those functions is true it prints that player won and if none of them is true the we go to

dropping the pieced again until the rows and columns are full, and the game is over
To express the code in the form of linear algebra concepts such as dropping a piece, it is like

adding a zero matrix to a matrix which includes a variable in the place of the piece insertion as in

the given two pictures

And we can express the columns of the board game as a vector and if 4 consecutive places of this

vector are full of the same color then the vertical function is true, and the player wins the same as

vertical function, but we can express it as a vector in a transpose matrix .and the left and right

slopped can be expressed as 4 places in the shape of a diagonal in a matrix.


Conclusion

In conclusion the relevance of linear algebra and its applications in real life are discussed in this

paper. This study demonstrates the effectiveness of Connect 4 as a paradigm for eliciting

problem-solving experiences of various valences (positive to negative) and types of problems

(insight to search). This should allow for more experimental research into issue solving that

includes the previously stated negative insight, as well as positive insight and search-based

problem solutions. Connect-4 is one of the activities in which the player must devise a plan to

pick his movements, which necessitates the players' talents. The game may be solved in a variety

of ways, including employing artificial intelligence. The AI has three levels: random, which is

the simplest to beat, defensive, which prioritizes blocking, and aggressive, which prioritizes

winning. According to the studies, playing Connect 4 resulted in both positive and bad insight

and search experiences. As a result, Connect-4 has the potential to be employed as a reliable

elicitation tool in future problem-solving research for both positive and negative problem-solving

experiences.
Discussion

As a player makes moves putting counters into a grid, working toward the overall winning goal

of obtaining four counters in a row, this study reveals that Connect 4 is a naturalistic activity that

produces insight and search problem solving experiences. Importantly, it has established for the

first time the elicitation of negative insight in a laboratory context, implying that experimental

validation of negative insight may be conducted to supplement existing qualitative research (Hill

and Kemp, 2016, unpublished a). Constructive search and insight were shown to be more

pleasurable than negative search and insight. Furthermore, insight shifts (both negative and

good) were perceived as more unexpected and abrupt. The alternative or null hypothesis

examining certainty ratings across solution and valence was not supported by adequate evidence.

Connect 4 demonstrates that it is a useful potential method for exploring aspects of positive and
negative insight and search solving in an experimental setting, as it performs similarly to a

variety of other insight elicitation methods that are limited to eliciting positive solving

experiences. It's reasonable to assume that positive insight is more pleasurable than positive

search. Because there has been little previous study on negative insight, it is more difficult to

draw predictions in this area. To sum up, the paper demonstrates the effectiveness of Connect 4

as a paradigm for eliciting problem-solving experiences of various valences (positive to

negative) and types of problems. This should allow for more experimental research into issue

solving that includes stated negative insight, as well as positive insight and search-based problem

solutions.

Result

The participants won 3.1 (SD = 1.46) out of the six Connect 4 games they played on average. A

distribution of number of games won that resembles that of a normal distribution.


74 percent of all moves were active problem-solving experiences. Insight accounted for 22% of

these adjustments (11 percent positive, 11 percent negative), whereas search accounted for 78%.

(62 percent positive and 16 percent). highlights the many sorts of problems that participants had

when playing Connect 4. Over 90% of participants experienced at least three of the four forms of

problem resolution (positive insight, positive search, negative insight, and negative search).

Breakdown of participants reported solving as positive insight (+i), positive search (+s), negative

insight (−i), and negative search (−s).


One subject of particular relevance is whether all negative insights were reported in reaction to a

game loss or impending loss. When comparing negative insight reporting across all games

played, it was discovered that games that were later won or drawn (41 percent) reported about

the same amount of negative insight as games that were lost (59 percent). Furthermore, just 14%

of the total negative insight movements were for the last move in a losing game. We classified

the tactics that users to use while playing the game. These tactics range from simple button-

pushing to more complex approaches based on estimating solutions and selecting vectors based

on their direction. We also discovered that users concentrate on the numerical and geometric

components of the game interface, which gives us more information about their strategy. These

findings influenced game improvements as well as our team's ideas for incorporating the game.

You might also like