3D Console Game interface

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

85 Replies - 2581 Views - Last Post: 02 June 2017 - 02:18 PM

#1 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

3D Console Game interface

Posted 02 May 2017 - 01:56 PM

The idea is to have a 3 player game of chess in a 7x7x7 cube. The way I want to format my output would be like the following if it were a 3x3x3 cube.


ABC......
DEFJKL...
GHIM0NRST
...OPQUVW
......XYZ


I have been thinking of ncurses, but would prefer to keep things as simple as possible, as well as compatible. Would prefer to avoid non-standard libraries. I am open to suggestions.

Is This A Good Question/Topic? 0
  • +

Replies To: 3D Console Game interface

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13567
  • View blog
  • Posts: 54,133
  • Joined: 12-June 08

Re: 3D Console Game interface

Posted 02 May 2017 - 01:59 PM

I am not certain if I follow. You want this in the terminal/console window, but 3d? You know that window is just text, right?
Was This Post Helpful? 0
  • +
  • -

#3 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 02 May 2017 - 02:31 PM

Yes, it is just text, and that is fine for now. Theoretically, the code can be written so that the symbols for the pieces could be changed to something other than characters. I used letters in the above sample to show order. With the 0 stuck in the middle, it kind of throws it off. Another way of writing that in base 3 would be:


000001002
010011012100101102
020021022110111112200201202
.........120121122210211212
..................220221222


And, for a 2x2x2 cube, the order is entirely sequential:

000001
010011100101
......110111


For a 7x7x7 cube, I have been using the letters a-g for the "z" axis, h-n for the "y" axis, and o-u for the x axis. Here are some samples of how those addresses could be ordered. In a usable interface, symbols expressing the contents of the space would be displayed rather than the address of the space.

Oops. I said here they are, and I forgot to include the link.
https://drive.google...iew?usp=sharing
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5928
  • View blog
  • Posts: 20,272
  • Joined: 05-May 12

Re: 3D Console Game interface

Posted 02 May 2017 - 11:39 PM

Why have separate letters for each axis? Why not simply use the position within the 3 digit number?

For example, given the number 375, interpret that as:
3 is the x coordinate
7 is the y coordinate
5 is the z coordinate

At least for me, it is less cognitive load.

Anyway given the way you are displaying the board, you don't really need ncurses. Plain old console output should be able to output what you need given that you were able to create the display in your posts above simply by using characters and placeholders. You could do the same by using characters and spaces.
Was This Post Helpful? 0
  • +
  • -

#5 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 03 May 2017 - 06:47 AM

Actually, that is exactly how I did it in the first version, and something about it made me want to switch to unique identifiers for each of the 21 different planes. Likewise, by using caps, I am able to uniquely identify each piece, and use different letters for each player's pawns (A-G,Z; H-N,Y; O-U,X). I have the different planes going horizontal across the screen, rather than stepping down in that version.

Anyhow, in looking at that, it seems that the best way would be to decrement the y, while incrementing the z in another nested for loop.
Was This Post Helpful? 0
  • +
  • -

#6 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 03 May 2017 - 07:55 AM

Forgetting about the inner for loop of x, and just looking at the z and y, for a 7x7x7 cube, I wind up with:

00
01 10
02 11 20
03 12 21 30
04 13 22 31 40
05 14 23 32 41 50
06 15 24 33 42 51 60
16 25 34 43 52 61
26 35 44 53 62
36 45 54 63
46 55 64
56 65
66


It seems I should be able to come up with something for that.
Was This Post Helpful? 0
  • +
  • -

#7 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 03 May 2017 - 09:20 AM

Okay, I got it working now. Here is the output for a 5x5x5 cube.
[[email protected] 777chess]$ ./a.out
000 001 002 003 004 
010 011 012 013 014 100 101 102 103 104 
020 021 022 023 024 110 111 112 113 114 200 201 202 203 204 
030 031 032 033 034 120 121 122 123 124 210 211 212 213 214 300 301 302 303 304 
040 041 042 043 044 130 131 132 133 134 220 221 222 223 224 310 311 312 313 314 400 401 402 403 404 
                    140 141 142 143 144 230 231 232 233 234 320 321 322 323 324 410 411 412 413 414 
                                        240 241 242 243 244 330 331 332 333 334 420 421 422 423 424 
                                                            340 341 342 343 344 430 431 432 433 434 
                                                                                440 441 442 443 444 



And the code:
#include <iostream>
#include <vector>
using namespace std;


int main() {
        int x;
        int y;
        int z;
        for ( int line=0;line<9;line++) {
                for (y=line,z=0; (z>=0 && z < 5 && y>=0);)/> {
                while (y > 4) {
                        cout << "                    ";
                        y--;
                        z = line - y;
                }

                for (x=0;x<5;x++) {
                cout << z;
                cout << y;
                cout << x;
                cout << " ";
                }
                y--;
                z++;
                }
cout << endl;


        }
}


Was This Post Helpful? 0
  • +
  • -

#8 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 03 May 2017 - 10:52 AM

Or, for a little more adjustable format, with a display that would be like what is used in the game, we have:
                                        cout << DKGREYBG; } else { cout << LTGREYBG; };
//                                      cout << z << y << x;
                                        cout << " " << RESET;
                                }
                                cout << " ";
                                y--;
                                z++;
                        }
                        cout << endl;


        }
}


Was This Post Helpful? 0
  • +
  • -

#9 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 03 May 2017 - 06:16 PM

For anyone interested, this is the basic idea I am working on. It is pretty horribly written code, but it basically works. I haven't implemented checking for checks, yet, but it shows you where all the pieces go, and allows you to move them to those spaces.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#10 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 07 May 2017 - 06:26 AM

I have been thinking about this game for the better part of a year, or so.

Last night, I got to thinking about the different ways the cube could be displayed. There are 48 possible ways to count out the coordinates in the cube, that I can think of, using this basic format (zyx).
font="Courier New"]
000 001
010 011 100 101 <---- sample 2x2x2 cube
110 111
[/font]

It seems natural to me to pair them. For each possible layout, there is a polar opposite ... a negative. For the above example, its polar opposite would be:

111 110
101 100 011 010
001 000


Laying printed side by side, you have the output for the left eye and the right eye. Not really sure what to do with the whitespace.

000 001 111 110
010 011 100 101 101 100 011 010
110 111 001 000


For anyone interested in what I have so far, I do have a functional version that you can compile and test out. The code is very hastily thrown together, and it is basically my first program in C++ (I took a class in a community college about 20 years ago).
777.cpp
Was This Post Helpful? 0
  • +
  • -

#11 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 07 May 2017 - 07:32 AM

@skydiver , I haven't implemented any of the changes you suggested, yet. I haven't made any changes for a while. I am thinking about what you said, though. Especially about the map idea. One of my biggest character flaws is that I procrastinate. Maybe I'll think of a reason why, later.
Was This Post Helpful? 0
  • +
  • -

#12 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 07 May 2017 - 10:17 AM

Perhaps this would be a viable way to arrange the output:
     000 001                   111 110
 010 011 100 101           101 100 011 010
     110 111                   001 000


Was This Post Helpful? 0
  • +
  • -

#13 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 07 May 2017 - 10:31 AM

Then, for 7x7x7 using the letters, we have this for the left "eye", and its reverse for the right "eye":
                                                                                     aho ahp ahq ahr ahs aht ahu 
                                                                       aio aip aiq air ais ait aiu bho bhp bhq bhr bhs bht bhu 
                                                         ajo ajp ajq ajr ajs ajt aju bio bip biq bir bis bit biu cho chp chq chr chs cht chu 
                                           ako akp akq akr aks akt aku bjo bjp bjq bjr bjs bjt bju cio cip ciq cir cis cit ciu dho dhp dhq dhr dhs dht dhu 
                             alo alp alq alr als alt alu bko bkp bkq bkr bks bkt bku cjo cjp cjq cjr cjs cjt cju dio dip diq dir dis dit diu eho ehp ehq ehr ehs eht ehu 
               amo amp amq amr ams amt amu blo blp blq blr bls blt blu cko ckp ckq ckr cks ckt cku djo djp djq djr djs djt dju eio eip eiq eir eis eit eiu fho fhp fhq fhr fhs fht fhu 
 ano anp anq anr ans ant anu bmo bmp bmq bmr bms bmt bmu clo clp clq clr cls clt clu dko dkp dkq dkr dks dkt dku ejo ejp ejq ejr ejs ejt eju fio fip fiq fir fis fit fiu gho ghp ghq ghr ghs ght ghu 
               bno bnp bnq bnr bns bnt bnu cmo cmp cmq cmr cms cmt cmu dlo dlp dlq dlr dls dlt dlu eko ekp ekq ekr eks ekt eku fjo fjp fjq fjr fjs fjt fju gio gip giq gir gis git giu  
                             cno cnp cnq cnr cns cnt cnu dmo dmp dmq dmr dms dmt dmu elo elp elq elr els elt elu fko fkp fkq fkr fks fkt fku gjo gjp gjq gjr gjs gjt gju 
                                           dno dnp dnq dnr dns dnt dnu emo emp emq emr ems emt emu flo flp flq flr fls flt flu gko gkp gkq gkr gks gkt gku
                                                         eno enp enq enr ens ent enu fmo fmp fmq fmr fms fmt fmu glo glp glq glr gls glt glu 
                                                                       fno fnp fnq fnr fns fnt fnu gmo gmp gmq gmr gms gmt gmu
                                                                                     gno gnp gnq gnr gns gnt gnu

Was This Post Helpful? 0
  • +
  • -

#14 s23bog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 79
  • Joined: 02-May 17

Re: 3D Console Game interface

Posted 07 May 2017 - 11:28 AM

I think the real benefit of using the letters instead of numbers is that one is easily able to see each plane, file, rank, or diagonal if you search for one or two letters at a time (a, b, c ... h, i , j ... o, p, q ...) (a.o for the intersection of the a and o planes, or fi for the intersection of the f and i planes.)

Then, if you look for [akr], for example, you see all three axes of the coordinate system.
Was This Post Helpful? 0
  • +
  • -

#15 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 5928
  • View blog
  • Posts: 20,272
  • Joined: 05-May 12

Re: 3D Console Game interface

Posted 07 May 2017 - 12:17 PM

If the distinction between the planes is so important, why not X be lowercase letters, the Y be numbers, and Z be uppercase letters.

My main concern is that it is relatively hard to tell the relative distances just looking at purely letters. Is the difference between a and e the same as the difference between h and n?
Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »