资源简介
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开发-能带计算
- 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
川公网安备 51152502000135号
评论
共有 条评论