资源简介
matlab开发-othellom。一个简单的单人奥赛罗棋盘游戏程序。
代码片段和文件信息
function othello()
% othello.m
% A simple othello program
% Author: Subroto Gunawan
% Date: August 8 2000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% VARIABLE DECLARATIONS %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% drawing parameters
DrawResolution = 1/100;
N=2*pi;
Theta = 0:DrawResolution:N;
% define the board
BoardSize = 8;
FigSize = 400;
ButtonWidth = 100;
Board = zeros(BoardSizeBoardSize);
InitXLoc = [ BoardSize/2 BoardSize/2+1 BoardSize/2 BoardSize/2+1];
InitYLoc = [ BoardSize/2 BoardSize/2 BoardSize/2+1 BoardSize/2+1];
% default values
DefaultFirstTurn = 1; % 1 is white 2 is black
finish=0;
whitePlayer = ‘human‘;
blackPlayer = ‘com‘;
XPos = [-1];
YPos = [-1];
XLegalPos = [];
YLegalPos = [];
BetweenCount = [];
NoMoveTurnCount = 0;
XDir = [-1 -1 0 +1 +1 +1 0 -1]; % counter clockwise directions starting from West
YDir = [0 +1 +1 +1 0 -1 -1 -1];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% INITIALIZATION %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set up the main frame
fig1 = figure(1);
clf;
set(fig1 ‘Position‘ [120 120 FigSize+ButtonWidth FigSize]...
‘Name‘‘Othello‘...
‘Numbertitle‘‘off‘...
‘MenuBar‘‘none‘);
% user control panel
left = 400;
bottom = 300;
width = 75;
height = 30;
ymod = 30;
statusText = uicontrol(‘style‘‘Text‘...
‘Position‘[(FigSize+ButtonWidth-300)/2 FigSize-30 300 25]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘FontWeight‘‘bold‘...
‘String‘‘‘);
infoText = uicontrol(‘style‘‘Text‘...
‘Position‘[(FigSize+ButtonWidth-300)/2 5 300 25]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘String‘‘Right Click to Quit‘);
whitePlayerText = uicontrol(‘style‘‘Text‘...
‘Position‘[left bottom width height]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘HorizontalAlignment‘‘left‘...
‘String‘[‘ White : ‘ whitePlayer]);
blackPlayerText = uicontrol(‘style‘‘Text‘...
‘Position‘[left bottom-ymod width height]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘HorizontalAlignment‘‘left‘...
‘String‘[‘ Black : ‘ blackPlayer]);
turnText = uicontrol(‘style‘‘Text‘...
‘Position‘[left bottom-4*ymod width height]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘String‘‘ White Turn ‘);
whiteText = uicontrol(‘style‘‘Text‘...
‘Position‘[left bottom-7*ymod width height]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘String‘‘White = 2‘);
blackText = uicontrol(‘style‘‘Text‘...
‘Position‘[left bottom-8*ymod width height]...
‘BackgroundColor‘[0.8 0.8 0.8]...
‘String‘‘Black = 2‘);
% creating the board grids
XLine = linspace(0FigSizeBoardSize+1);
YLine = linspace(0FigSizeBoardSize+1);
for i=1:(BoardSize+1)
line([XLine(i) XLine(i)] [YLine(1) YLine(BoardSize+1)]‘Color‘[0 0 0]);
line([XLine(1) XLine(BoardSize+1)] [YLine(i) YLine(i)]‘Color‘[0 0 0]);
end
axis([0FigSize+ButtonWidth0FigSize]);
hold on;
axis off;
% determine the radius of the piece
gap = (XLine(2)-XLine(1))/2;
radius = gap - (gap*0.25); % leave a 25% side
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12088 2018-07-11 20:16 othello.m
相关资源
- matlab开发-ShamirsSecretSharing
- matlab开发-EMGONOFF
- matlab开发-级联H桥多电平转换三相
- matlab开发-带图形用户界面的步进电机
- matlab开发-MFTireGUI
- matlab开发-自适应霍夫曼编码技术字符
- matlab开发-ConnectFour
- matlab开发-floodfillscanline
- matlab开发-Paretosurfacenavigator
- matlab开发-分步序达尔文粒子群优化
- matlab开发-改进的解决方案经济调度方
- matlab开发-为Resnet50网络设计工具箱模
- matlab开发-sigmoid
- matlab开发-同步发电机的详细模型,包
- matlab开发-多层反向传播神经网络
- matlab开发-Parrotminirones的模拟支持包
- matlab开发-nnsysid
- matlab开发-使用gnewton-raphson方法查找任
- matlab开发-UR5控制Matlab
-
matlab开发-mssamultiob
jectivesalpswarmalg - matlab开发-Vasicek
- matlab开发-直流到全桥逆变器
- matlab开发-使用xFoiland ParseCGeometric参数
- matlab开发-如何模拟6到10个输入状态空
- matlab开发-mtype340
- matlab开发-rafaelaeroXFOILinterface
-
matlab开发-单相三电平去阻尼Pwmba
s - matlab开发-scatter3sph
- matlab开发-TraCI4Matlab
- matlab开发-三个27电平转换器,带有单
评论
共有 条评论