2016년 12월 11일 일요일

a random generator (issues with code)


Firstly: i know very little about programming and what i have done is based on some of the example programs and videos i have found.

Secondly: this program is just a way to generate a random set of information about MTG cards that i can deign around.

Issues:

(1) i have IF statements to take care of outliers in regards to things that definitly don't exist or can't exist in the MTG card universe. the main issue i'm having is that no matter if i nest the IF statements regarding Land, or separate the IF statements I still have an issue where when the Supertype: "land" is picked randomly it produces a set of colors, which can't happen.

(2) the same issue with land happens with the Supertypes: "Creature", "Land Creature", "Artifact Creature"

you will notice that i have not completed the global lists for each section, as such i want the generator to function as needed before changing the list with the correct information.

i have no clue what is going on and would greatly appreciate some assistance as to why this is the case and maybe a solution to the issue if possible.

--
What is a set of MTG cards?
And, could you post a readable screenshot?

--
to answer the questions:

*MTG is a shorthand or an abbreviation of the card game Magic: The Gathering.
*the screenshot that i posted is huge. if you click on it you also have the ability to zoom into 90% of the code and see the possible issues.
*i've also attached to the original post the whole program in .aia format for people who would like to mess around with the code themselves without relying on screenshots.

-- 
 I still have an issue where when the Supertype: "land" is picked randomly it produces a set of colors, which can't happen

Look in the logic blocks for green AND blocks, to combine restrictions.
  
See the Books and tutorials section of this FAQ for a well indexed textbook,
to learn about logic.


--
Also consider setting up your combinations in a table or tables.
Read up on lists and lists of lists, especially the lookup-in-pairs block.

See the Lists section of that FAQ for examples.

-- 
I asked my husband, who used to play MTG endlessly with my sons. He said that he did not understand what you are trying to do.
Maybe you could spell out the rules more clearly and make a table or a tree structure showing what the possible combinations are.
Then, you can determine a strategy to implement this.
Cheers, Ghica.

-- 
so the goal is to create a fake card (for art reasons) keep my mind going, etc...

the generator creates a fake card based on the border (old, modern, unglued, etc...). what the color might be for the card (white, blue, black, red, green), what type of card (land, creature, sorcery, instant, etc...), and any any creature types if creature is the typed picked by the generator.

the issues i'm having result when card that can't have a color assigned to them (anything with the Land or Conspiracy type in the name) end up with a random color that gets picked by the generator. which i don't want.

the picture shows that i have created if/then/else statements to help the generator, but they don't seem to be doing what i expect.

with other programming languages (OBJ/Java) this type of implementation is easy. i'm just not a fan. and this web-based program was supposed to make the whole thing quick-and-dirty as i don't need to be polished i'm just looking for a way to keep my creative juices working when i'm bored. 

-- 
never mind et. al. i fixed my own issue.

i used nested IF/THEN/ELSE statements to fix the logic problem with the program. 

ugly and dirty way to fix and issue i know but it works and thats all that matters.

-- 
What you want to do with your project is relatively straight forward in AI2 too.   I expect you have read http://www.appinventor.org/bookChapters/chapter18.pdf  It shows how if..then..else statements work and how to use them with conditionals. Since you are familiar with Java you just need to get familiar with using the blocks.   Rereading you will find that the if statements work just like they do in scripting languages.  Moving from low level languages to AI2 is a bit discerning, especially for programmers who have experience with other programming languages.

With the code you posted, it is not apparent how you tried to handle  "cards that can't have a color assigned to them (anything with the Land or Conspiracy type in the name) "  .  Take a look at the section Programming Conditions within Conditions perhaps and you might not have an 'ugly and dirty" way to fix the issue.

Glad you got your test set to work the way you wanted it to.  

-- 

댓글 없음:

댓글 쓰기