tic-tac-toe

Simple tic-tac-toe AI [closed]

淺唱寂寞╮ 提交于 2019-11-27 02:51:22
问题 I know this has been asked a lot and I've searched other code but most of what I've seen doesn't seem flawless (never loses) and simple, elegant and efficient. And I'm unable to decide which type of solution would fit that description. The solutions I've seen are: (1) Using minimax with alpha-beta pruning. This seems complicated to me and possibly unnecessary for such a simple game? Is it probably too complicated? If not, would I need to do a lot of hard coding or am I misunderstanding the

Code Golf: Tic Tac Toe

回眸只為那壹抹淺笑 提交于 2019-11-26 17:58:50
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Post your shortest code, by character count, to check if a player has won, and if so, which. Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where: 0 = nothing set 1 = player 1 (X) 2 = player 2 (O) So, given the array b = [ 1, 2, 1, 0, 1, 2, 1, 0,

What algorithm for a tic-tac-toe game can I use to determine the “best move” for the AI?

99封情书 提交于 2019-11-26 15:44:56
In a tic-tac-toe implementation I guess that the challenging part is to determine the best move to be played by the machine. What are the algorithms that can pursued? I'm looking into implementations from simple to complex. How would I go about tackling this part of the problem? bkane The strategy from Wikipedia for playing a perfect game (win or tie every time) seems like straightforward pseudo-code: Quote from Wikipedia (Tic Tac Toe#Strategy) A player can play a perfect game of Tic-tac-toe (to win or, at least, draw) if they choose the first available move from the following list, each turn,

What algorithm for a tic-tac-toe game can I use to determine the “best move” for the AI?

为君一笑 提交于 2019-11-26 04:36:49
问题 In a tic-tac-toe implementation I guess that the challenging part is to determine the best move to be played by the machine. What are the algorithms that can pursued? I\'m looking into implementations from simple to complex. How would I go about tackling this part of the problem? 回答1: The strategy from Wikipedia for playing a perfect game (win or tie every time) seems like straightforward pseudo-code: Quote from Wikipedia (Tic Tac Toe#Strategy) A player can play a perfect game of Tic-tac-toe

Algorithm for Determining Tic Tac Toe Game Over

喜你入骨 提交于 2019-11-26 01:05:16
问题 I\'ve written a game of tic-tac-toe in Java, and my current method of determining the end of the game accounts for the following possible scenarios for the game being over: The board is full, and no winner has yet been declared: Game is a draw. Cross has won. Circle has won. Unfortunately, to do so, it reads through a predefined set of these scenarios from a table. This isn\'t necessarily bad considering that there are only 9 spaces on a board, and thus the table is somewhat small, but is

Algorithm for Determining Tic Tac Toe Game Over

时光怂恿深爱的人放手 提交于 2019-11-25 23:56:24
I've written a game of tic-tac-toe in Java, and my current method of determining the end of the game accounts for the following possible scenarios for the game being over: The board is full, and no winner has yet been declared: Game is a draw. Cross has won. Circle has won. Unfortunately, to do so, it reads through a predefined set of these scenarios from a table. This isn't necessarily bad considering that there are only 9 spaces on a board, and thus the table is somewhat small, but is there a better algorithmic way of determining if the game is over? The determination of whether someone has