Jump to content

Recommended Posts

Posted

hello dear autoit community.

has anyone ever played chess or battleship before?

chessboard image or if you like battleship game

without thinking about it the chessboard: how many fields does it have? if your answer is 64, then sorry you are wrong! while there might be 64 fields to move your figures on, but chess, just like the battleship game works by a universal set of rules: a position is determined by the intersection of two (or more) grid markers that create an intersection in the playing field. thus a chess field would have 96 fields and 4 empty corner fields that contain no data.

 

my interest lies exactly in those grid markers and i would like to take those markers to look up the intersections on a playing field. i have tried to demonstrate it using simple screenshots of spreadsheets. even programmes like excel (or in my case it was libreoffice) and other things like navigation systems or even standard maps all used the same system. even longitude and latitude work on the system of pinpointing a unique position by using the intersection of two or more grid markers.

 

i have no idea what i am doing in autoit but this is how far i have got so far:

 

#include <GuiListView.au3>
#include <GuiConstantsEX.au3>
#include <Array.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>


;~ Local $thebigbox[10][10] = [[" ", "1", "2", "3", "4", "5", "6", "7", "8", " "], ["a", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "k"], ["b", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "l"], ["c", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "m"], ["d", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "n"], ["e", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "o"], ["f", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "p"], ["g", "g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "q"], ["h", "h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "r"], [" ", "%", "$", "@", "ß", "ö", "ä", "ü", "#", " "]]
; _ArrayDisplay($thebigbox, "Spreadsheet: The Big Box")

Local $thebigbox[10][10] = [[" ", "1", "2", "3", "4", "5", "6", "7", "8", " "], ["a", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "k"], ["b", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "l"], ["c", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "m"], ["d", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "n"], ["e", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "o"], ["f", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "p"], ["g", "g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "q"], ["h", "h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "r"], [" ", "%", "$", "@", "ß", "ö", "ä", "ü", "#", " "]]

;create GUI and ListView
GUICreate("gui-and-listview", 480,520,-1,-1)
GUISetState(@SW_SHOW)
$hListView = GUICtrlCreateListView("",50,100,310,240, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
$Input1 = GUICtrlCreateInput("e", 48, 32, 121, 21)
$Input2 = GUICtrlCreateInput("4", 238, 32, 121, 21)
$Input3 = GUICtrlCreateInput("", 238, 368, 121, 21)
$Button1 = GUICtrlCreateButton("Start", 56, 368, 75, 25)
$Button3 = GUICtrlCreateButton("Read", 156, 65, 75, 25)
$Button2 = GUICtrlCreateButton("EXIT", 350, 450, 75, 25)

;add colums
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)
_GUICtrlListView_AddColumn($hListView, "", 30, 2)

;add array (the big box)
_GUICtrlListView_AddArray($hListView, $thebigbox)


While 1
    $eMsg = GUIGetMsg()
    Switch $eMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            Exit
        Case $Input1
            $plaintext1 = GUICtrlRead($Input1)
        Case $Input2
            $plaintext2 = GUICtrlRead($Input2)
        Case $Button3
            $plaintext1 = GUICtrlRead($Input1)
            $plaintext2 = GUICtrlRead($Input2)
            MsgBox(0,"Read",$plaintext1 & " and " & $plaintext2)
        Case $Button1
            ; look-up the corresponding data
        Case $Input3
            ; output the corresponding data
    EndSwitch
WEnd

 

basically i have built the spreadsheet in a listview gui and with that said, i now am looking for a way to check for the intersection and then output the data corresponding to the input data. there is always two single points that intersect somewhere and the result of those two points is the intersection resulting in a unique output. ... i would like to take it a step further and use 4 different sets of data to search or count for intersections thus making it very complex.

 

however i do not really know how to begin, or what needs to be done. anybody get the idea of what i aiming for and maybe interested in helping out and pointing me in the direction i need to go?

 

kind regards to all

libre-office-plan.PNG

libre-office-plan2.PNG

libre-office-plan3.PNG

libre-office-plan4.PNG

Posted

further explanations now that you can see the images:

i basically want to build a spreadsheet grid filled with data
and want to use changing data-input to locate the corresponding
field in the grid and output that unique data somewhere else.
it is like a chess board, a spreadsheed from excel or other
alternatives, like a map or anything that describes the exact
whereabouts of something within our world/universe.

if someone asks you where you have your spoons, then you
basically answer with a grid: kitchen, right unit, to drawer,
left side. ... you are giving a map as an answer that helps
to locate the item in question. that is exactly what i would
like to do. create a grid system (or a map) for the corresponding
answer to two known datapoints (input-data)

my plan does not just however want to use a two definition bar
like a chessboard, but rather more check if the there is an
intersection somewhere and locate the data belonging to that
intersection alone.

the basic idea is that the field "e4" could be the result of
different inputs: e+4 ; e+ß ; 4+o ; o+ß ; 8+4 ; k+o ; #+ß
and finally a+e ... the last for result in a non existing
intersection and a positional count. exmaple: input-data
was a and e and there is no intersection anywhere on the
definition bars. both entries are on the definintion bar 1
(primary) and now the positions must be counted. there are
3 positions inbetween a and e (b,c,d) and thus there must
be 3 positions between e and e4 (e1,e2,e3) ... if the
input data in this case would have ben not a+e but rather
more e+a then that would result of course in the field "b4"

i know that somebody will claim that if input-data is c+m
no intersection and no couting would help because there is
not enough datafields for the count. that is a problem and
i do not yet have a solution for that issue. at the moment
i am first and formost trying to find help to make a
gridsearch possible that will work and output unique data
to the input data supplied.

basically i would like to design a complex positioning
grid based on two data-inputs made by the user and the
lookup of the corresponding data within the gridfield.

this way each dataoutput is unique to the input. even though
the output can also be the result of another different input.

like everything in life a set of rules would need to aply:

1) always search first for an intersection starting from the
primary and/or secondary before trying to look for intersections
from additional bar 3 and 4.
2) if absolutely no intersections can be found locate the
positions of the entry-data and count datadifference between
them for output-data

everything in life is based on a grid system. life is a
spreadsheet and the box you are in/on, is always defined
by two or more points describing where you are currently.

 

Posted

i think the difference would be that i do not just want to use two sides but rather all 4 sides to lookup the intersections. so to speak have 4 x bars and 4 y bars to look for data. and not just one x and one y bar. because adding another bar if no intersection can be found would be the whole idea. with only two bars like with chess or battleship only one combination is possible and with my plan a whole number of possible inputs result in the same data output. i guess that is the difference i am going for.

Posted

That's just labeling. Data itself it's still a basic 2D array. Basically you need a function to map different labels to a certain row/column from an array.

Posted

i understand that i can make a fuction to search in a specific row or a specific column but my difficulty is how do i now find the intersection of those two?

if "e" is in row 5 and "4" is in column 5 then find the spot (data) where these two meet (intersect)

that is my struggle at the moment. i do not know how i would have to go about that at all

Posted

This is a naive approach but I still don't get why someone would need such a  strange structure.

#include <Array.au3>

Local $aLabels1[10] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Local $aLabels2[10] = ['k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't']
Local $aLabels3[10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
Local $aLabels4[10] = ['u', 'v', 'w', 'x', 'y', 'z', 'ü', 'ö', 'ä', '#']

$aGrid = CreateGrid(10, 10)
AddSomeRandomData($aGrid)

; Preview random data added
_ArrayDisplay($aGrid['Data'])

AddAxis($aGrid, $aLabels1, 'Left', 0)
AddAxis($aGrid, $aLabels2, 'Right', 0)
AddAxis($aGrid, $aLabels3, 'Top', 1)
AddAxis($aGrid, $aLabels4, 'Bottom', 1)

; Check some lookups
; all should point to the same grid cell
MsgBox(0, '', GetGridValue($aGrid, 'Left', 'd', 'Top', '4'))
MsgBox(0, '', GetGridValue($aGrid, 'Right', 'n', 'Top', '4'))
MsgBox(0, '', GetGridValue($aGrid, 'Left', 'd', 'Bottom', 'y'))
MsgBox(0, '', GetGridValue($aGrid, 'Right', 'n', 'Bottom', 'y'))

Func CreateGrid($iRows, $iCols)
    Local $aArray[$iRows][$iCols]
    Local $aGrid[]
    $aGrid['Data'] = $aArray
    Return $aGrid
EndFunc

Func AddAxis(ByRef $aGrid, $aAxis, $sAxisName, $iType)
    Local $iGridSize
    Switch $iType
        Case 0 ; Vertical axis
            $iGridSize = UBound($aGrid['Data'], 1)
        Case 1 ; Horizontal axis
            $iGridSize = UBound($aGrid['Data'], 2)
    EndSwitch
    If $iGridSize <> UBound($aAxis) Then Return SetError(1, 0, False)
    If $sAxisName = 'Data' Then Return SetError(2, 0, False)
    $aGrid[$sAxisName & '_Labels'] = $aAxis
    $aGrid[$sAxisName & '_Type'] = $iType
    Return SetError(0, 0, True)
EndFunc

Func GetGridValue(ByRef $aGrid, $sVerticalAxisName, $sVerticalAxisValue, $sHorizontalAxisName, $sHorizontalAxisValue)
    Local $Idx1 = -1, $Idx2 = -1
    If Not MapExists($aGrid, $sVerticalAxisName & '_Labels') Then Return SetError(1, 0, Null)
    If Not MapExists($aGrid, $sHorizontalAxisName & '_Labels') Then Return SetError(2, 0, Null)
    If $aGrid[$sVerticalAxisName & '_Type'] <> 0 Then Return SetError(3, 0, Null)
    If $aGrid[$sHorizontalAxisName & '_Type'] <> 1 Then Return SetError(4, 0, Null)
    Local $aVerticalLabels = $aGrid[$sVerticalAxisName & '_Labels']
    Local $aHorizontalLabels = $aGrid[$sHorizontalAxisName & '_Labels']
    For $Index = 0 To UBound($aVerticalLabels) - 1
        If $aVerticalLabels[$Index] = $sVerticalAxisValue Then
            $Idx1 = $Index
            ExitLoop
        EndIf
    Next
    For $Index = 0 To UBound($aHorizontalLabels) - 1
        If $aHorizontalLabels[$Index] = $sHorizontalAxisValue Then
            $Idx2 = $Index
            ExitLoop
        EndIf
    Next
    If $Idx1 = -1 Or $Idx2 = -1 Then Return SetError(5, 0, Null)
    Local $aArray = $aGrid['Data']
    Return $aArray[$Idx1][$Idx2]
EndFunc

Func AddSomeRandomData(ByRef $aGrid)
    $aArray = $aGrid['Data']
    For $i = 0 To UBound($aArray, 1) - 1
        For $j = 0 To UBound($aArray, 2) - 1
            $aArray[$i][$j] = $i & $j
        Next
    Next
    $aGrid['Data'] = $aArray
EndFunc

 

Posted

okay i see that 'something' works, but it is very difficult now to look up and see if it would be right. since the $aLabels1 - 4 are nowhere to be found. besides the fact that the grid is a true 10 x 10 and mine is not a true 10 x 10. i have like the chessboard 4 empty spaces in each of the corners because no data will ever be there and i do not need to look any data up in the corners ever. and going by your labels the "a", "u", "j" and "#" are the corner pieces and thus could never be used in an input because a lookup is not possible.

the thing that bugs me, is that i can not quite follow how and why or where the rest of the data is? i see a grid 10x10 but that has been filled with automated data, but it should be an 8x8 grid filled with automated data and an additional 10x10 outlined grid as the reference point to start the search for intersections, and somehow i can not get my head round what your idea exactly does.

  • Moderators
Posted

cmbspecial,

I have carefully read your posts above and I am completely bemused as to what exactly you are trying to do. I cannot imagine a scenario which would require such a complex system of indexing as the one you appear to propose. Can you give us a real world example of what it is you are trying to do with your multiple indices - we might then be able to offer a cleaner, and hopefully simpler, method to achieve it.

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

hi melba23,

the system of a grid and intersecting points on that grid can be found everywhere. in every spreadsheet (excel / libreoffice / etc.) or in any other aspect in life. anything that has to do with a positioning system requires a grid or grid-like lookup system.

i am attempting to write something like a game but for four players, where each player has a different grid that would make them play against there opposite opponent, whilst the other two do the same and thus hindering each other throughout the game. i guess the closest to what i am thinking of would be a game called halma (i do not know the English title). see the image at the bottom for the game field.

blue wants to get where black is and yellow to where green is and brown to where red is but all at the same time. so six players. i am only thinking of 4 players and thus four index sides and of a square field not like in halma. however, the possibilities of such a complex grid system would be much greater than just a stupid game where you enter your move in a coordination system and the game does the move according to your input. especially if you then have two symbols or alphabetical chars that are both on one and the same grid and counting the distance comes into play to find a specific spot on the "field"

i once read in a book that cryptology is based on an alphabetic grid and just imagine you could have an alphabetic grid and a numerical grid and a grid of special chars all rolled into one single grid and by entering for example a %-sign and a !-sign it could translate to a individual letter of the alphabet or even as in the book i read to a word or a phrase. i even once designed such a system in excel myself that has exactly that 4 grid system that was able to combine any letter, number or special char into a unique letter. as long as you have two starting points (the entered data) you can find a unique intersection to these two starting points. i guess that would be fun to write something like that, too.

so that is just two possible real world examples of what can be done with a complex grid system.

well, i guess that will not help you much though. if you like i can screenshot the excel design that i made that would make clear what i wanted to achieve. it is based on the exact same system as i would like to use now for this game design.

halma-game.PNG

Posted (edited)

The problem is that you look at a grid to solve your problem. The grid is just a visualisation of whatever algorithm is behind The scènes. Excel is internal not a 16 million rows and 16k columns grid.

However you have e4 and 6ß pointing to the same location with data. So basically you only have 1 datastore where you want to have 2 keys returning the same result.

So where you are saying everything is a grid I have some doubt but as a datastore can be seen as a grid maybe you are right and you just need some indexes for your intersections.

Edited by junkew

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...