资源简介
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开发-能带计算
- matlab开发-FlockingAlgorithm
- matlab开发-MuellerStokesJonesCalculus
- matlab开发-HX711的自定义数据库
- matlab开发-SMOTEBoost
- matlab开发-果蝇优化算法第二版
- matlab开发-多变量决策树
- matlab开发-水轮发电机模型
- matlab开发-交通警告标志识别标签代码
- matlab开发-RUSBoost
- matlab开发-基于遗传算法的机器人运动
- matlab开发-MPU6050加速度陀螺仪
- matlab开发-功率曲线FAsmallscalewindturbi
- matlab开发-NASAJPLDE405开发星历表
- matlab开发-SortinoRatio
- matlab开发-永磁TDC并联电机数学模型
- matlab开发-3相SPWM整流器
- matlab开发-Kilobotswarm控制Matlabarduino
- matlab开发-简单音频播放
- matlab开发-记录文件的绘图仪加速度、
- matlab开发-永磁同步电机PMSM动态数学模
- matlab开发-多目标优化差分进化算法
- matlab开发-随机微分方程解算
- matlab开发-波长调制光谱的二次谐波模
- matlab开发-仿制药生物生理学基础药动
- matlab开发-使用svmrfe选择功能
- matlab开发-KDTreeNearestNeighborandRangeSear
- matlab开发-stlread
- matlab开发-三维图像堆栈查看器
- matlab开发-动态电压恢复器故障dvr
评论
共有 条评论