Ordering Number Lists


#21

@CJW You know that’s half right… I didn’t think I’d have any issues with adding to the numbers… I saw it in my minds eye and there was no reason why it shouldn’t work… but for some reason it was doing all sorts of odd stuff when I typed it out…

Spose for noobs like me, its easier to do it on a small scale and when that works just multiply it up - less code to sort through when it doesn’t!

(edit - ah well its good to know I’m not a complete dolt!)


#22

Keep at it! :wink:


#23


@CJW Just thought you might like to know where I got to... The ADD choices give you a chance to see "YOU" go up and down the list... the toggle was a cheeky thought I had AND I got it working!

*comment assign our numbers to our fake "array"
*temp toggle 22

*temp nA 0
*temp nB 0
*temp nC 0
*temp nD 0
*temp nE 0
*temp nF 0
*temp nG 0
*temp nH 0
*temp nI 0
*temp nJ 0
*temp nK 0
*temp nL 0
*temp nM 0
*temp nn 0
*temp nO 0
*temp nP 0
*temp nQ 0
*temp nR 0
*temp nS 0
*temp nT 0
*temp nU 0
*temp nV 0
*temp nW 0
*temp nX 0
*temp nY 0
*temp nZ 0
*temp nYOU 0

*label start

*temp number_1 nA
*temp number_2 nB
*temp number_3 nC
*temp number_4 nD
*temp number_5 nE
*temp number_6 nF
*temp number_7 nG
*temp number_8 nH
*temp number_9 nI
*temp number_10 nJ
*temp number_11 nK
*temp number_12 nL
*temp number_13 nM
*temp number_14 nN
*temp number_15 nO
*temp number_16 nP
*temp number_17 nQ
*temp number_18 nR
*temp number_19 nS
*temp number_20 nT
*temp number_21 nU
*temp number_22 nV
*temp number_23 nW
*temp number_24 nX
*temp number_25 nW
*temp number_26 nZ
*temp number_27 nYOU

*temp name_1 "A"
*temp name_2 "B"
*temp name_3 "C"
*temp name_4 "D"
*temp name_5 "E"
*temp name_6 "F"
*temp name_7 "G"
*temp name_8 "H"
*temp name_9 "I"
*temp name_10 "J"
*temp name_11 "K"
*temp name_12 "L"
*temp name_13 "M"
*temp name_14 "N"
*temp name_15 "O"
*temp name_16 "P"
*temp name_17 "Q"
*temp name_18 "R"
*temp name_19 "S"
*temp name_20 "T"
*temp name_21 "U"
*temp name_22 "V"
*temp name_23 "W"
*temp name_24 "X"
*temp name_25 "Y"
*temp name_26 "Z"
*temp name_27 "YOU"


*comment define extra variables
*temp have_swapped false
*temp pointer 0
*temp list_size 27

*label loop
*if ((pointer = (list_size -1)) and (have_swapped != true))
 *comment if no swaps are made we can (hopefully) assume that everything is in the right order and finish.
 *goto scoring
*if (have_swapped)
 *comment if a swap has been made at the end of a list iteration, reset the pointer and run again.
 *set pointer 0
 *set have_swapped false
 *goto loop
*set pointer + 1
*if ({("number_"&pointer)} <= {("number_"&(pointer + 1))})
 *comment combined *if statements and swapped comparison direction in order to have sort list from big numbers downwards
 *goto loop
*else
 *comment if the left hand side is bigger, swap them and flag as having swapped.
 *temp store {("number_"&pointer)}
 *setref ("number_"&pointer) {("number_"&(pointer + 1))}
 *setref ("number_"&(pointer + 1)) store
 *temp store2 {("name_"&pointer)}
 *setref ("name_"&pointer) {("name_"&(pointer + 1))}
 *setref ("name_"&(pointer + 1)) store2
 *set have_swapped true
 *goto loop

*label scoring
[b]SCORING[/b]
*line_break
*temp n list_size
*temp str ""
*temp nom ""
*temp num 0
*label print_loop
*set str {"number_"&n}
*set nom {"name_"&n}
*set num (28-n)
*if {"name_"&n} = "YOU"
 [b]${num} : ${nom} ${str}[/b]
*if {"name_"&n} != "YOU"
 ${num} : ${nom} ${str}
*line_break
*set n - 1
*if n > toggle
 *goto print_loop

*label check_player_position
*temp n 0
*label name_check_loop
*set n + 1
*if (({"name_"&n} = "YOU") and (toggle =22))
 *if (n >= 23)
  *goto next
 *temp your_score {"number_"&n}
 *temp ntt (28-n)
 *temp nomtt {"name_"&n}
 *line_break
 [b]${ntt} : ${nomtt} ${your_score}[/b]
*if (({"name_"&n} = "YOU") and (toggle =7))
 *if (n >= 8)
  *goto next
 *temp your_score {"number_"&n}
 *temp ntt (28-n)
 *temp nomtt {"name_"&n}
 *line_break
 [b]${ntt} : ${nomtt} ${your_score}[/b]
*if (n = list_size)
 *goto next
*goto name_check_loop

*label next
*fake_choice
 #add to YOU
  *set nYOU +1
  *goto start
 #add to ALL
  *gosub ddiez
  *set nA +(d10)
  *gosub ddiez
  *set nB +(d10)
  *gosub ddiez
  *set nC +(d10)
  *gosub ddiez
  *set nD +(d10)
  *gosub ddiez
  *set nE +(d10)
  *gosub ddiez
  *set nF +(d10)
  *gosub ddiez
  *set nG +(d10)
  *gosub ddiez
  *set nH +(d10)
  *gosub ddiez
  *set nI +(d10)
  *gosub ddiez
  *set nJ +(d10)
  *gosub ddiez
  *set nK +(d10)
  *gosub ddiez
  *set nL +(d10)
  *gosub ddiez
  *set nM +(d10)
  *gosub ddiez
  *set nN +(d10)
  *gosub ddiez
  *set nO +(d10)
  *gosub ddiez
  *set nP +(d10)
  *gosub ddiez
  *set nQ +(d10)
  *gosub ddiez
  *set nR +(d10)
  *gosub ddiez
  *set nS +(d10)
  *gosub ddiez
  *set nT +(d10)
  *gosub ddiez
  *set nU +(d10)
  *gosub ddiez
  *set nV +(d10)
  *gosub ddiez
  *set nW +(d10)
  *gosub ddiez
  *set nX +(d10)
  *gosub ddiez
  *set nY +(d10)
  *gosub ddiez
  *set nZ +(d10)
  *gosub dseis
  *set nYOU +(d6)
  *goto start
 *if (toggle = 7) #Toggle top 5
  *set toggle 22
  *goto start
 *if (toggle = 22) #Toggle top 20
  *set toggle 7
  *goto start

*label ddiez
*temp d10
*rand d10 1 10
*return

*label dseis
*temp d6
*rand d6 1 6
*return


@CJW - oh ps - you can probably close the thread now! thanks


#24

Good job, I think I’d rather leave it open though. If people have further questions down the line, it beats making a new identical one. Just let it get buried?


#25

@CJW sure no problem…

(oops)

p.s: maybe you can edit the title with your nifty admin skills - change it to something like…

Ordering/Sorting/Ranking lists subroutine

(makes it easier to search for maybe? and a bit more obvious than craft coding conundrum!)