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 9136515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:57:46+00:00 2026-06-17T08:57:46+00:00

Alright, right now I am trying to create a basic four in a row

  • 0

Alright, right now I am trying to create a basic four in a row game with a 10×10 board.
(Ranging from A to J and 1 to 10.) Now, the goal of the game is to prohibit the player from entering a ‘coordinate’ that has already been used, and the coordinate can’t ‘float’.

For example: When the player chooses A9, but A1 to A8 are still empty, the choice can’t be there. (As if you drop a coin down the collumn)


What I wanted to ask is, how do I validate that the previous value isn’t in use?
I was thinking about arrays, but I don’t know how to make that work.

This is the code I wrote to validat the coordinate:

Function Validate-Move{

do{
    do {        
        $script:coordinateLetter = Read-host "Please enter a letter from A to J" 
        if($script:coordinateLetter.Length -gt 1){}
       } 
    while ($script:coordinateLetter.Length -gt 1)
  }
until($script:coordinateLetter -cmatch "[A-J]")

do{
  $script:coordinateNumber = Read-host "Please enter a number from 1 to 10!"

  }
until($script:coordinateNumber -match "^([1-9]|[1][0])$")


}
$playerMove = $coordinateLetter + $coordinateNumber
Write-host "You have chosen " -NoNewline; Write-host "$fullCoordinate" -for green

After this block of code I would like to perform a check that the value is possible for use. Jerry Lee Ford’s book uses the following method in the Three in a Row game:

if (($move -eq "A1") -and ($A1 -ne " ")) {$result = "Invalid"}
if (($move -eq "A2") -and ($A2 -ne " ")) {$result = "Invalid"}
if (($move -eq "A3") -and ($A3 -ne " ")) {$result = "Invalid"}
if (($move -eq "B1") -and ($B1 -ne " ")) {$result = "Invalid"}

and so forth. But that would mean that I would have to make 100 variables (!) and write a check for all of them ?

Can anyone point me in the right direction?

  • 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-06-17T08:57:47+00:00Added an answer on June 17, 2026 at 8:57 am

    Why not using a multidimensional array to set coordinate and evaluate if has value or not:

    $m = New-Object 'object[,]' 10,10
    $m[0,0] = "x"
    $m[0,9] = "x"
    
    [bool]$m[0,2]
    False
    
    [bool]$m[0,1]
    True
    

    You need to map the range A – J to 0 – 9 ’cause array are 0-based

    after the user input you can check if slot is busy like this:

    if ([bool]$m=[$coordinateLetter,$coordinateNumber]) #if busy
    { do this stuff..}
    else
    { do something other.. }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a single page CRUD. Right now, I faced some
I am trying to debug right now in C and am curious if it
Alright, I'm trying to create textviews dynamically with strings i have in an array.
Alright, I'm attempting to rewrite a URL in .htaccess Right now the URL looks
First, the formula I'm currently using: =countifs('page1'!AF:AF,$L6,'page1'!AA:AA,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AB:AB,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AC:AC,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AD:AD,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AE:AE,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AF:AF,=&RIGHT(M$2,3)) Alright, now, what I'm attempting to match
Alright I have two roles setup in Devise: User and Employer. Right now you
Right now I have: s = @/Users/minisquad1/Pictures/; This works alright in my computer. I
Alright so I am making a simple Tic Tac Toe program. Right now I
Alright I'm pretty new to programming and stuff and I'm now trying to code
Alright, Im trying to count all the rows where Membership_Status = Active. The result

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.