Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:14:04+00:00 2026-05-31T21:14:04+00:00

I created a simple Tic Tac Toe game in c#, which can played in

  • 0

I created a simple Tic Tac Toe game in c#, which can played in 1 players mode, and in 2 player mode.

I programmed the computer to react correctly (in the computer vs. player mode), but I think that my code is much bigger than it should be since what I did is that I checked every possible combination manually, and can’t seems to find how to minimize the code.

Here is the makeComputerMove() func: https://gist.github.com/2192374

Explanation of the variables:

char[,] Board: 2D array, contains the ‘X’ and ‘O’

char shape: that’s the shape I’m using to determine the priority move, first I set it to ‘O’ so that the computer will try to win. If it can’t win, it will try to block. If there is nothing to block, it will try to set a ‘O’ near another ‘O’ on the board.

Position P: an object that contains the values Row and Col.

Thanks.

EDIT: Now I see that people are thinking I want you to rewrite my code. I just added it so you could see what I did. I’m only asking for tips (by approaching the problem in a different way).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:14:05+00:00Added an answer on May 31, 2026 at 9:14 pm

    Read about MinMax algorithms here to get the general idea.
    It’s basically backtracking through possible moves, and foreach possible move to all possible moves, and so in, into a certain number of moves (ai depth). This uses recursion.
    Since this is TicTacToe, you can lose the “depth” and have “end” as your stop condition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As part of learning jQuery, I decided to do a simple tic-tac-toe game in
I`ve created simple hello world-like plugin which draws red box. Аfter embedding into xulrunner
I have created simple .aspx page which queries a database for some live data
I created two simple functions which get template parameters and an empty struct defining
I have created simple chat application using smack api.i can able to chat well.but
I have created simple DataGrid with 4 columns, which go outside the bounds of
I have created simple c# example which uses barriers and I have thrown an
I've created simple Engine for my App written in RoR 3.0.x How can I
I created a simple HTML form which takes input as username of the customer.
Could someone help me on this, I have created simple web services using axis2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.