Reversi Game with AI Implementation in MATLAB: Strategy, Heuristic Algorithm, and Gameplay
VerifiedAdded on  2023/04/25
|4
|826
|462
Assignment
AI Summary
In this assignment we will discuss about othello or revrsi game Implementation in matlab and below are the summaries point:-
MATLAB is a numerical computing environment and programming language used for various applications.
This assignment focuses on implementing a Reversi game with AI using MATLAB and C code.
The game includes options for AI vs AI and Human vs AI, with the AI utilizing efficient heuristic algorithm implementation.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head: Othello or revrsi Game Implementation in matlab 1
Reversi game with AI Implementation in MATLAB
Executive Summary
MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and
proprietary programming language developed by MathWorks. ... The MATLAB application is
built around the MATLAB scripting language. Common usage of the MATLAB application
involves using the Command Window as an interactive mathematical shell or executing text files
containing MATLAB code. MATLAB can call functions and subroutines written in the
programming languages C or Fortran. A wrapper function is created allowing MATLAB data
types to be passed and returned. MEX files are the dynamically loadable object files created by
compiling such functions.[27] Since 2014 increasing two-way interfacing with Python was being
added.
In this assignment we did with C language . In this project we design and develop and Reversi
game with AI using MATLAB. We build C code into MATLAB functions .This game is simple
game and we design this code using AI .We design and develop Reversi game two option AI vs
AI ,Human vs AI . In this game we develop the strategy for computer using efficient Heuristic
algorithm implementation. Othello allows user to play Othello game in MATLAB GUI against a
simple AI. The AI for this game only is designed only to find the most swapping possible at its
turn. It does not try to anticipate the next possible turn or try to capture tiles at the board edge,
which makes it fairly easy to beat.
Reversi game with AI Implementation in MATLAB
Executive Summary
MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and
proprietary programming language developed by MathWorks. ... The MATLAB application is
built around the MATLAB scripting language. Common usage of the MATLAB application
involves using the Command Window as an interactive mathematical shell or executing text files
containing MATLAB code. MATLAB can call functions and subroutines written in the
programming languages C or Fortran. A wrapper function is created allowing MATLAB data
types to be passed and returned. MEX files are the dynamically loadable object files created by
compiling such functions.[27] Since 2014 increasing two-way interfacing with Python was being
added.
In this assignment we did with C language . In this project we design and develop and Reversi
game with AI using MATLAB. We build C code into MATLAB functions .This game is simple
game and we design this code using AI .We design and develop Reversi game two option AI vs
AI ,Human vs AI . In this game we develop the strategy for computer using efficient Heuristic
algorithm implementation. Othello allows user to play Othello game in MATLAB GUI against a
simple AI. The AI for this game only is designed only to find the most swapping possible at its
turn. It does not try to anticipate the next possible turn or try to capture tiles at the board edge,
which makes it fairly easy to beat.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Othello or revrsi Game Implementation in matlab 2
MALAB
Game Description
The boards are represented as matrices where 0 represents an empty spot, -1: a black
token, and 1: a white token. Initially, finding all valid moves was implemented in MATLAB
using image dilation techniques using a 3x3 ones matrix. However, profiling showed that this
was too slow. So finding all valid moves was implemented in C code. This was done using an
array of function pointers representing the eight rays emanating from a candidate move position.
Candidate locations are empty and a neighbor of an enemy token. Candidates that produced a
nonzero number of flips are returned as a vector of actions. Their corresponding resultant boards
are also returned as a 3D matrix of valid next-boards.
The AI itself is implemented using a minimax decision with alpha-beta pruning. The heuristic is
calculated based on a weighted sum of score, number of corners, and mobility. The heuristic is
zero-sum, so Min's benefits are subtracted from Max's benefits etc. The heuristic function is
meant to be calculated quickly as well, so this was another function I implemented in C and built
back into MATLAB using MEX.
A simple one-player othello board-game program. Players control the white piece while the
computer AI controls the black. The AI uses a simple heuristic-based optimization search. For
simplicity, it only searches up to one move ahead.
Reversi, also known as Othello, is a game in which reversible white/black chips are placed on a
grid. The goal is to have the most pieces once the board is full (i.e. there are no more legal
moves). A move, to be legal, must flip at least one opponent's chip by flanking it. "Flanking"
occurs by surrounding a line of opposing chips with two of your own. It can occur on straight
lines and diagonals.
MALAB
Game Description
The boards are represented as matrices where 0 represents an empty spot, -1: a black
token, and 1: a white token. Initially, finding all valid moves was implemented in MATLAB
using image dilation techniques using a 3x3 ones matrix. However, profiling showed that this
was too slow. So finding all valid moves was implemented in C code. This was done using an
array of function pointers representing the eight rays emanating from a candidate move position.
Candidate locations are empty and a neighbor of an enemy token. Candidates that produced a
nonzero number of flips are returned as a vector of actions. Their corresponding resultant boards
are also returned as a 3D matrix of valid next-boards.
The AI itself is implemented using a minimax decision with alpha-beta pruning. The heuristic is
calculated based on a weighted sum of score, number of corners, and mobility. The heuristic is
zero-sum, so Min's benefits are subtracted from Max's benefits etc. The heuristic function is
meant to be calculated quickly as well, so this was another function I implemented in C and built
back into MATLAB using MEX.
A simple one-player othello board-game program. Players control the white piece while the
computer AI controls the black. The AI uses a simple heuristic-based optimization search. For
simplicity, it only searches up to one move ahead.
Reversi, also known as Othello, is a game in which reversible white/black chips are placed on a
grid. The goal is to have the most pieces once the board is full (i.e. there are no more legal
moves). A move, to be legal, must flip at least one opponent's chip by flanking it. "Flanking"
occurs by surrounding a line of opposing chips with two of your own. It can occur on straight
lines and diagonals.
Othello or revrsi Game Implementation in matlab 3
Compile and Run the code
You can do this in the MATLAB command window:
mex getAllValid.c
mex utility_c.c
Then you can run the main program by running:
main.m
There are two option
1. "Human vs AI"
2. "AI vs AI"
First option if we select "Human vs AI", we have the choice between playing as black or
white.
Second option there is no need to choice
Compile and Run the code
You can do this in the MATLAB command window:
mex getAllValid.c
mex utility_c.c
Then you can run the main program by running:
main.m
There are two option
1. "Human vs AI"
2. "AI vs AI"
First option if we select "Human vs AI", we have the choice between playing as black or
white.
Second option there is no need to choice
Othello or revrsi Game Implementation in matlab 4
In this game we design a sidebar gives access to certain game settings and options
therefore we can load game states or save the current game state. The game timeline can be
altered by moving the iteration slider or changing the iteration number text box. The allotted for
the AI to think can also be changed here. By default, the AI is given 1 second to think, but you
can change that at any point in the game. The current score of the game is also displayed on the
sidebar. We can then test the game by changing the move iteration slider or text box.
In this game we design a sidebar gives access to certain game settings and options
therefore we can load game states or save the current game state. The game timeline can be
altered by moving the iteration slider or changing the iteration number text box. The allotted for
the AI to think can also be changed here. By default, the AI is given 1 second to think, but you
can change that at any point in the game. The current score of the game is also displayed on the
sidebar. We can then test the game by changing the move iteration slider or text box.
1 out of 4
Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024  |  Zucol Services PVT LTD  |  All rights reserved.