static Node[] generateMoves(Node node) { List <Node> nodes = new List <Node>(); for (int i = 0; i < 7; i++) { if (JoinFour.isMoveValid(node.player | node.opponent, i) && !JoinFour.hasPlayerWon(node.player) && !JoinFour.hasPlayerWon(node.opponent)) { nodes.Add(new Node { opponentPlaying = !node.opponentPlaying, player = (node.opponentPlaying) ? node.player : JoinFour.applyMove(node.player, node.opponent, i), opponent = (node.opponentPlaying) ? JoinFour.applyMove(node.opponent, node.player, i) : node.opponent, lastMove = i }); } } return(nodes.ToArray()); }
public MainForm() { Console.WriteLine(JoinFour.applyMove(1UL << 63, 0, 0)); // Initialise button properties for (int i = 0; i < 42; i++) { // Initiate the button buttons[i] = new Button(); // Set the bounds of the button in the order shown in the bitboard layout buttons[i].SetBounds(boardOffsetX + (buttonSize * (int)Math.Floor((double)i / 6)), boardOffsetY + (buttonSize * (5 - (i % 6))), buttonSize, buttonSize); // Set colour buttons[i].BackColor = Control.DefaultBackColor; // Add the button listener buttons[i].Tag = i; buttons[i].Click += new EventHandler(MoveSubmitted); Controls.Add(buttons[i]); } InitializeComponent(); Size = new Size(600, 600); Console.WriteLine(Size); }
public bool submitMove(int x) { if (!JoinFour.isMoveValid(players[0] | players[1], x)) { return(false); } if (playerOnePlaying) { players[0] = JoinFour.applyMove(players[0], players[1], x); if (JoinFour.hasPlayerWon(players[0])) { gameFinished = true; } else if (type == GameType.PlayerVsComputer) { players[1] = JoinFour.applyMove( players[1], players[0], AIPlayer.generateNextMove(players[1], players[0])); if (JoinFour.hasPlayerWon(players[1])) { gameFinished = true; } } else { playerOnePlaying = false; } } else { players[1] = JoinFour.applyMove(players[1], players[0], x); if (JoinFour.hasPlayerWon(players[1])) { gameFinished = true; } playerOnePlaying = true; } return(true); }