当前位置:   article > 正文

java四连环游戏编程_如何用C语言实现四连环游戏(重力四子棋)?

重力四子棋csdn

正好我们老师也要做了这个作业!就来蹭个热闹~

大概就是实现了要求的功能,然后能够自定义棋盘大小(目前是6行7列,通过修改Connect4::play()里面的对于rowNum和colNum的赋值来实现自定义棋盘大小),能够选择先手后手,能够选择人机、人人模式;可能还有没有测试出来的的bug;可能代码不是很规范;

采用模式匹配的方式,给程序下棋提供一点参考(其实也就是预先设计了几种优先考虑的情况)

补上控制台输出样例:

Welcome to the game 'Connect 4' in console!

Chose the game mode:

- 1. PvC

- 2. PvP.

1

Game mode: Player v.s. Computer

Who goes first?

- 1. Player

- 2. Computer

1

Game starts!

中间省略若干行……

. . . . . . . . . @: Player

. . . . . . . . . $: Computer

@ . . . . . . . .

$ . @ . . @ . . .

$ @ @ @ $ @ . . .

@ $ $ $ @ $ $ @ $

-----------------

1 2 3 4 5 6 7 8 9

Round: 20

History: 1 2 2 3 3 4 5 6 4 1 3 5 6 7 8 9 6 1 1

Computer's turn: 3

. . . . . . . . . @: Player

. . . . . . . . . $: Computer

@ . . . . . . . .

$ . @ $ . @ . . .

$ @ @ @ $ @ . . .

@ $ $ $ @ $ $ @ $

Round: 21

History: 1 2 2 3 3 4 5 6 4 1 3 5 6 7 8 9 6 1 1 4

Player's turn: 4

. . . . . . . . . @: Player

. . . . . . . . . $: Computer

@ . . @ . . . . .

$ . @ $ . @ . . .

$ @ @ @ $ @ . . .

@ $ $ $ @ $ $ @ $

-----------------

1 2 3 4 5 6 7 8 9

Round: 21

History: 1 2 2 3 3 4 5 6 4 1 3 5 6 7 8 9 6 1 1 4

Player wins!

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号