Difference between revisions of "Pseudo-Code"
From BEEP BOOP
Karmeleaux (Talk | contribs) (Created page with "*board1 is a 20x11 array *character is a value assigned to each character with a special block //ex. Karm=0, Dai=1, Koray=2, Hina=3 ==Generating the board== <nowiki> for (x=0...") |
Karmeleaux (Talk | contribs) (→Checking Matched Sets) |
||
| Line 56: | Line 56: | ||
//ugh, no doubt the most complicated part of common code, this would be called in every successful move | //ugh, no doubt the most complicated part of common code, this would be called in every successful move | ||
//match threes are simple because you simply get to check at most x or y -/+2, whereas with this system we've got to write code | //match threes are simple because you simply get to check at most x or y -/+2, whereas with this system we've got to write code | ||
| − | checking the shape and configuration of every tetromino, as well as a bit extra to insure it never tried to check off the board (ex. checking for an horizontally-configured I shape when one swapped two pieces on the leftmost side horizontally) | + | checking the shape and configuration of every tetromino, as well as a bit extra to insure it never tried to check off the board (ex. |
| + | checking for an horizontally-configured I shape when one swapped two pieces on the leftmost side horizontally) | ||
//It's doable, but it's not easy to render in pseudo-code so I'm not gonna bother right now | //It's doable, but it's not easy to render in pseudo-code so I'm not gonna bother right now | ||
//One thing to note is that you saw at generating the board how I had 1 and 7 turn to 1? Well the idea currently is 1 is 'inactive' | //One thing to note is that you saw at generating the board how I had 1 and 7 turn to 1? Well the idea currently is 1 is 'inactive' | ||
| Line 62: | Line 63: | ||
This is important to note for later code that interacts with active sets. | This is important to note for later code that interacts with active sets. | ||
//Also, you know what? Fuck it, it's an array with 210 entries, I think we could scan it between even move/turn for tetrominoes with | //Also, you know what? Fuck it, it's an array with 210 entries, I think we could scan it between even move/turn for tetrominoes with | ||
| − | no real problems, rather than solely checking around switched blocks. This would be far simpler to code and because it's purely math it should be milliseconds of time, probably genuinely no more than tripling the completely negligible time anyway. There. (this also simplifies problems when active sets become inactive due to spells) | + | no real problems, rather than solely checking around switched blocks. This would be far simpler to code and because it's purely math |
| + | it should be milliseconds of time, probably genuinely no more than tripling the completely negligible time anyway. There. (this also | ||
| + | simplifies problems when active sets become inactive due to spells) | ||
| − | //Anyway, at the beginning of the turn, if any number of has a value between 7 and 12, it means it's an active set and should be cleared. This calls the deletion code, but would have a flag not to give an extra turn for any matches. | + | //Anyway, at the beginning of the turn, if any number of has a value between 7 and 12, it means it's an active set and should be |
| + | cleared. This calls the deletion code, but would have a flag not to give an extra turn for any matches. | ||
</nowiki> | </nowiki> | ||
Latest revision as of 00:17, 10 March 2014
- board1 is a 20x11 array
- character is a value assigned to each character with a special block //ex. Karm=0, Dai=1, Koray=2, Hina=3
Contents
Generating the board[edit]
for (x=0; x<20; x++) {
for (y=0; y<11; y++) {
board1[x][y]=random(13); //this is INCREDIBLY simplified, in reality we'd want to make sure there were no matches on the
starting board, but pseudo-code!
if (board1[x][y]=1||7)
board1[x][y]=1; //value for physical attack block
. . .
if (board1[x][y]=13)
board[x][y]=13+character; //adding the character value to 13 ensures you get their special block
}
}
Swapping Tiles[edit]
cursor1x is the x position of the first click, cursor1y is the y
cursor2x is the x position of the second click, cursor2y is the y
//probably some sort of 'highlight' board1[cursor1x][cursor1y]
//un-highlight if cursor2x=cursor1x&&cursor2y=cursor2y, as they decided not to select that
if (cursor1x+1||-1=cursor2x) {
temp is an integer that's simply used to storage the value during the swap
temp=board1[cursor1x][cursor1y];
board1[cursor1x][cursor1y]=board1[cursor2x][cursor2y];
board1[cursor2x][cursor2y]=temp;
}
else-if (cursor1y+1||-1=cursor2y) {
(exact same code as above, just for a vertical switch) }
else {
cursor1x=cursor2x;
cursor1y=cursor2y;
//this assumes that because the player has clicked a non-adjacent block, they instead want to move that block, there would
also need to be a 'un-highlight' clean-up in here but eh right now
}
Deleting Tiles[edit]
reusing cursor1x and cursor1y here
//briefly set board1[cursor1x][cursor1y] to a blank space, I imagine this would be value 99 or something, only used for when blocks
are removed
for(x=cursor1x;x<20;x++) {
board1[x][cursor1y]=board1[x+1][cursor1y]
//simplified, there may be a bit more code for cases at the top of the board, but the gist of it
//additionally, the refunding of a move if an active set is form from the process, but I haven't included moves in any pseudo-code
just yet so it's just a mental note right now
}
Checking Matched Sets[edit]
//ugh, no doubt the most complicated part of common code, this would be called in every successful move //match threes are simple because you simply get to check at most x or y -/+2, whereas with this system we've got to write code checking the shape and configuration of every tetromino, as well as a bit extra to insure it never tried to check off the board (ex. checking for an horizontally-configured I shape when one swapped two pieces on the leftmost side horizontally) //It's doable, but it's not easy to render in pseudo-code so I'm not gonna bother right now //One thing to note is that you saw at generating the board how I had 1 and 7 turn to 1? Well the idea currently is 1 is 'inactive' physical attack, and if one of the tetromino checkers found a matching group of 1's, it would turn them all to 7's (and so forth). This is important to note for later code that interacts with active sets. //Also, you know what? Fuck it, it's an array with 210 entries, I think we could scan it between even move/turn for tetrominoes with no real problems, rather than solely checking around switched blocks. This would be far simpler to code and because it's purely math it should be milliseconds of time, probably genuinely no more than tripling the completely negligible time anyway. There. (this also simplifies problems when active sets become inactive due to spells) //Anyway, at the beginning of the turn, if any number of has a value between 7 and 12, it means it's an active set and should be cleared. This calls the deletion code, but would have a flag not to give an extra turn for any matches.
Adding to Reserves[edit]
//Adding to reserves would be simple and probably only called at the beginning of turns when scanning for matched sets above, though there may be additional ways to build it up (some artifacts may provide a negligible amount each turn???). Regardless, it's pretty much 'add the value for the matched set' and 'if current value of reserve exceeds max then current equals max' bam
Using Spells[edit]
//another one that's a bit too complicated for my tastes right now, though this is something I could definitely render in pseudo-code given the effort. Pretty much the general feel of it the game checks to see if you meet the requirements of casting any spell any time you gain reserves (or whatever gate the spell has). If you do, it becomes clickable, then subtracts the require values from the necessary shit. Babambalam. //spells at destroy blocks an opponent's board would probably call more or less the deleting one's own tiles code, like above in matched sets it should have a check so one doesn't get extra turns from being attacked. //Additionally, if the value is somewhere between 7 through 12, it becomes the value minus 6 rather than being deleted, which is just a pseudo-pseudo-code of saying it becomes inactive
There's obviously more systems/subroutines that need to be created and called, but I think all of that is a decent starting point for saying 'this is pretty manageable.'