资源简介
matlab开发-ConnectFour。著名的“连接四”游戏。
代码片段和文件信息
function dummy = connect4()
% This file performs the famous game of Connect FOUR
% The rules of the Game are:
% Two players may participate
% The board is shown in the figure window
% Every player has his own tile colour
% Every player drops his tile in his turn by Clicking on the desired Column
% The two players go on trying to connect Four tiles of one Colour
% Horizontally Vertically or in any diagonal
% The player who manages to do so first in his own Colour
% IS THE WINNER
% Programmed by: Mina Ayman (mina_ayman@yahoo.com)
% Using MATLAB R12 on 14/11/2003
% Enjoy Your Play !!!
% Getting the tiles for the play
tile = imread(‘btile.bmp‘);
p1t = imread(‘p1.bmp‘);
p2t = imread(‘p2.bmp‘);
wint = imread(‘win.bmp‘);
% Getting the board for the play
board = [tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile];
% Sound Generator for the winner
[winyz] = wavread(‘winner.wav‘);
winning = [win; win; win; win];
% Sound Generator for the hit sound
[hitbc] = wavread(‘hit3.wav‘);
% Sound Generator for the drop tile sound
[tdropbbcc] = wavread(‘boing.wav‘);
% Initialization of the players
fprintf(‘\n\t\t\t Welcome to The Game Of CONNECT FOUR‘)
st = ‘Your Turn! ‘;
con = ‘Congratulations! ‘;
wins = ‘ Wins‘;
% Player 1
fprintf(‘\n Entering the Name of Player (1)‘)
player1 = input(‘\nYour Name is : ‘‘s‘);
fprintf(‘\n Welcome %s‘player1)
fprintf(‘\n You will get the Red Tile‘)
id1 = [st player1];
con1 = [con player1 wins];
% Player 2
fprintf(‘\n\n\n Entering the Name of Player (2)‘)
player2 = input(‘\nYour Name is : ‘‘s‘);
fprintf(‘\n Welcome %s‘player2)
fprintf(‘\n You will get the Yellow Tile‘)
id2 = [st player2];
con2 = [con player2 wins];
fprintf(‘\n\n\n Now Let‘‘s Begin Our Game‘)
fprintf(‘\n Press (Enter) when READY‘)
pause;
% Plotting the board
u = figure;
set(gcf‘Color‘[0 0.7 0])
imshow(board)
% Introduction
p = title(‘**Welcome to CONNECT FOUR**‘);
set(p‘Color‘[0.8 0 0.8])
set(p‘FontWeight‘‘bold‘)
set(p‘FontSize‘19)
pause(4);
% Displaying Rules of the game
set(p‘Color‘[0.5 0 0.5])
set(p‘String‘‘Drop Your Tile in Your Turn!!!‘)
set(p‘FontSize‘18)
pause(3);
set(p‘String‘‘With a Right Click on the Column‘)
pause(3);
set(p‘String‘‘Where You Want to Drop Your Tile‘)
pause(4);
game = zeros(67);
% The Beginning of the Play
for n = 1 : 22
p1x = 0;
a = title(id1);
set(a‘FontSize‘18)
set(a‘FontWeight‘‘bold‘)
set(a‘Color‘‘r‘)
pause(1.2);
% Get the play of Player 1
while(p1x == 0);
[c1r1pp1] = impixel(board);
p1y = ceil(c1(1)/50);
col1 = game(:p1y);
if (all(col1) == 0)
p1x = max(find(col1 == 0));
game(p1xp1y) = 11;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5964 1992-09-07 00:00 connect4\HIT3.WAV
文件 196708 1994-05-02 12:00 connect4\winner.wav
文件 7656 2003-11-10 19:34 connect4\btile.bmp
文件 7656 2003-11-10 19:37 connect4\p2.bmp
文件 7656 2003-11-10 19:38 connect4\p1.bmp
文件 7656 2003-11-10 19:39 connect4\win.bmp
文件 76996 2003-11-16 12:57 connect4\connect4.m
文件 7812 1994-04-26 14:00 connect4\BOING.WAV
目录 0 2003-11-08 19:56 connect4\
相关资源
- 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电平转换器,带有单
- matlab开发-DynaSimDynaSim
- matlab开发-spy2m
- matlab开发-landmask
- matlab开发-经济调度通用算法解决方案
- matlab开发-图片加密和解密
- matlab开发-分子通讯粘着剂
- matlab开发-IEEE754二进制表示
评论
共有 条评论