They are pokemon types. Pokemon can have up to two types. For you the
numbers are pure abstractions.
On Tuesday, April 2, 2024, Thomas E Enebo via ruby-talk <
ruby-talk(a)ml.ruby-lang.org> wrote:
Mark, what does the left and right side of the first
array's subelements
represent?
tep=[[0,3],[1,5],[2],[3,14],[4,0],[5,0],[6,15],[7,9],[8,7],[9,11],[10,16],[11,6],[12],[13,9],[14],[15,14],[16]]
As Ryan noted it appears to be an index of 17 things
where the right side
may be nothing? I also note that the right hand values also
fit into 0-16
as a range. I find myself intrigued in the same way I can be with word
puzzles. So far I think:
1. single pairs [2] correspond to no other entry in
the list
2. [0, 3] would be 0 entry relates to entry 3
In plain english what does this array mean? Once I see
`str=tep[0]+tep[1]+tep[2]`
this throws me off the rails since not all teps
are [n, n] but some are [n].
> -Tom
> -Tom
> -Tom
> On Mon, Apr 1, 2024 at 8:29 AM Mark Smith
via ruby-talk <
ruby-talk(a)ml.ruby-lang.org> wrote:
>
>>
https://codeshare.io/P84e1Q
>> I don't know if it will be more clear but Pokemon have types and so do
their moves. A move doesn't have to be the same type as the pokemon. A
pokemon of a type can resist a move of a type or be weak to it or immune or
just normally effective.
> As far code goes, it is still not working right-
type and typesgen are
not combining correctly
> On Mon, Apr 1, 2024 at 5:14 AM Ryan Davis via
ruby-talk <
ruby-talk(a)ml.ruby-lang.org> wrote:
>>
>>
>>> > On Mar 30, 2024, at 16:14,
Mark Smith via ruby-talk <
ruby-talk(a)ml.ruby-lang.org> wrote:
>>>
>>>
>>> > That seems to be the main
error but the full error message is
>>> > [1mTraceback [m (most recent call last):
>>> > 4: from playground.rb:42:in `<main>'
>>> > 3: from playground.rb:42:in `p'
>>> > 2: from playground.rb:42:in `inspect'
>>> > 1: from playground.rb:42:in `inspect'
>>> > playground.rb:42:in `inspect': [1mcannot set encoding on
non-encoding
capable object ( [1;4mArgumentError [m [1m) [m
>>>
>>> >
Thanks for your help in advance.
>>> > Maybe it is because I need to combine the previous values of the
types arrays with the additional values and not the previous values are
set. What does the error mean and how to fix it?
>>
>>>
There's a lot going on with this code that I'm not gonna touch on...
I'm not going to help with the error because I'm unwilling to run such
obfuscated code right now. But I will say that code readability matters and
helps to convey what the code does:
>>
>>> * name
things so they convey what they're doing
>>> * name your magic numbers
>>> * indent the code correctly
>>> * add blank lines to separate different ideas into their own paragraphs
>>> * say what you mean (eg .empty? vs .length==0)
>>
>>> ...all
of these things help you and anyone who winds up reading the
code.
>>
>>>
`ptl=[[0,3],[1,5],[2],[3,14],[4,0],[5,0],[6,15],[7,9],[8,7],[9,11],[10,16],[11,6],[12],[13,9],[14],[15,14],[16]]
>>
>>> Some of
these aren't pairs. Are you sure that you can mix nil and
integers? I don't see checks to that effect.
>>
>>> Also,
the first item is literally just the slot count. Not terribly
valuable and could be had with `with_index`
>>
>>> >
ptl.shuffle()
>>
>>>
ptl.shuffle returns a new array. So this doesn't do what you want.
>>
>>> >
str=ptl[0]+ptl[1]+ptl[2]
>>
>>> this
never differs as a result (probably a good thing until you get
this debugged)
>>
>>> could be
`str = ptl.first 3`
>>
>>> >
cr=3
>>> > i=0
>>> > w=Array.new(2) { [] }
>>> > until i==3
>>> > p ptl[cr]
>>> > w[i]=ptl[cr]
>>> > if ((w[i]&str).length()==0)
>>> > i+=1
>>> > end
>>> > cr+=1
>>>
>>> >
end
>>> > types=Array.new(19) { [[],[],[]] }
>>>
>>> >
pwt=w[0]+w[1]+w[2]
>>>
>>> >
types[17]=[[pwt],[str]]
>>> > for i in 0..(pwt.length()-1)
>>> > types[pwt[i]]=[[],[19]]
>>> > end
>>
>>> what is
the point of this code if you're literally overwriting it all
in the next block?
>>
>>> > for
i in 0..(str.length()-1)
>>
>>>
`str.length.times do |i|`
>>
>>> >
types[str[i]]=[[19],[]]
>>> > end
>>> > typeslist=Array.new(17) {|i| i }
>>> > sampstr=Array.new(6) { [] }
>>> > sampwk=Array.new(6) { [] }
>>> > for i in 0..types.length()-1
>>> > typeslist.shuffle()
>>
>>> ditto
>>
>>> > for
j in 0..5
>>> > sampstr.push typeslist[j]
>>> > end
>>
>>>
sampstr.append typeslist.take 6
>>> or
>>> sampwk.append typeslist[0..5]
>>
>>> > for
j in 6..12
>>> > sampwk. push typeslist[j]
>>> > end
>>
>>>
sampwk.append typeslist.drop(6).take(6)
>>> or
>>> sampwk.append typeslist[6..12]
>>
>>> >
types[0][i]=sampstr.push types[0][i]
>>> > types[1][i]=sampwk.push types[1][i]
>>> > types[2][i]=typeslist[13]
>>> > end
>>> > p types`
>>> ______________________________________________
>>> ruby-talk mailing list -- ruby-talk(a)ml.ruby-lang.org
>>> To unsubscribe send an email to ruby-talk-leave(a)ml.ruby-lang.org
>>> ruby-talk info --
https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-talk.ml.ruby-lang.or…
>
>>
______________________________________________
>> ruby-talk mailing list -- ruby-talk(a)ml.ruby-lang.org
>> To unsubscribe send an email to ruby-talk-leave(a)ml.ruby-lang.org
>> ruby-talk info --
https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-talk.ml.ruby-lang.or…
> --
> blog:
http://blog.enebo.com twitter: tom_enebo
> mail: tom.enebo(a)gmail.com