comparison clojure/com/aurellem/run/bootstrap_0.clj @ 333:61a096a53330

fixed problem with rival's name.
author Robert McIntyre <rlm@mit.edu>
date Fri, 06 Apr 2012 14:41:28 -0500
parents 5c2041d1cdda
children 57f4c57d2897
comparison
equal deleted inserted replaced
332:5c2041d1cdda 333:61a096a53330
26 (play-moves 26 (play-moves
27 [[] 27 [[]
28 [] [] [:r] [] [:d] [:a] ;; L 28 [] [] [:r] [] [:d] [:a] ;; L
29 [:r] [] [:r] [] [:r] [] [:r] [] 29 [:r] [] [:r] [] [:r] [] [:r] []
30 [:r] [] [:d] [] [:d] [:a] ;; [PK] 30 [:r] [] [:d] [] [:d] [:a] ;; [PK]
31 [:u] [] [:l] [] [:l] [] [:l] [] 31 [:u] [] [:l] [] [:l] []
32 [:l] [] [:l] [] [:a] ;; U 32 [:l] [] [:l] [] [:l] [:a] ;; U
33 [:r] [] [:r] [] [:r] [] [:r] [] 33 [:r] [] [:r] [] [:r] []
34 [:r] [] [] [:d] [:a] ;; [PK] 34 [:r] [] [:r] [] [:d] [:a] ;; [PK]
35 [] [:a] ;; [PK] 35 [] [:a] ;; [PK]
36 [] [:a] ;; [PK] 36 [] [:a] ;; [PK]
37 [:r] [] [:d] [:a] ;; END 37 [:r] [] [:d] [:a] ;; END
38 ])))) 38 ]))))
39
40 ;; (defn-memo name-rival-bootstrap
41 ;; ([] (name-rival-bootstrap (to-rival-name)))
42 ;; ([script]
43 ;; (->> script
44 ;; (first-difference [] [:a] AF)
45 ;; (first-difference [] [:r] DE)
46 ;; (play-moves
47 ;; [[]
48 ;; [] [] [:r] []
49 ;; [:r] [] [:r] [] [:r] [] [:r] []
50 ;; [:r] [] [:d] [] [:d] [] [:d] [:a];; PK
51 ;; [] [:a] ;; PK
52 ;; [:u] [] [:l] [] [:l] [] [:l] []
53 ;; [:l] [] [:l] [:a] ;; U
54 ;; [:d] [] [:r] [] [:r] [] [:r] []
55 ;; [:r] [] [:r] [:a] ;; PK
56 ;; [:u] [] [:l] [] [:l] [] [:l] []
57 ;; [:l] [] [:l] [] [:u] [:a] ;; L
58 ;; [:d] [] [:r] [] [:r] [] [:r] []
59 ;; [:r] [] [:r] [] [:d] [:a] ;; PK
60 ;; [:r] [] [:d] [:a] ;; END
61 ;; ]))))
62 39
63 (defn-memo leave-house 40 (defn-memo leave-house
64 ([] (leave-house (name-rival-bootstrap))) 41 ([] (leave-house (name-rival-bootstrap)))
65 ([script] 42 ([script]
66 (->> script 43 (->> script
291 [↓ ↓ ← ↓ 268 [↓ ↓ ← ↓
292 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 269 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
293 → → → ↓]) 270 → → → ↓])
294 271
295 (walk-thru-grass 272 (walk-thru-grass
296 [↓ ↓ ↓ ↓]) 273 [↓ ↓ ↓])
297 274
298 (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓]) 275 (walk [↓ ← ← ↓ ↓ ↓ ↓ ↓ ↓])
299 276
300 (walk-thru-grass 277 (walk-thru-grass
301 [↓ ↓ ↓ ↓ ↓ ↓]) 278 [↓ ↓ ↓ ↓ ↓ ↓])
302 279
303 (walk [↓ ↓ ↓ ← ↓ ↓ ↓ 280 (walk [↓ ↓ ↓ ← ↓ ↓ ↓
372 ([^SaveState state] 349 ([^SaveState state]
373 (let [mem (memory state)] 350 (let [mem (memory state)]
374 (+ (aget mem list-screen-offset-address) 351 (+ (aget mem list-screen-offset-address)
375 (aget mem list-cursor-offset-address)))) 352 (aget mem list-cursor-offset-address))))
376 ([] (list-offset @current-state))) 353 ([] (list-offset @current-state)))
354
355
377 356
378 (defn exp-item-selection [] 357 (defn exp-item-selection []
379 (clojure.pprint/pprint 358 (clojure.pprint/pprint
380 (apply memory-compare 359 (apply memory-compare
381 (map read-state 360 (map read-state
486 (def menu do-nothing ) 465 (def menu do-nothing )
487 466
488 (defn close-menu [script] 467 (defn close-menu [script]
489 (first-difference [] [:b] AF script)) 468 (first-difference [] [:b] AF script))
490 469
491
492
493 ;; (defn select-menu-entry* [script]
494 ;; (let [wait-time
495 ;; (- (dec (count (first (set-cursor-relative 1 script))))
496 ;; (count (first script)))]
497 ;; (println "wait-time" wait-time)
498 ;; (play-moves (concat (repeat wait-time []) [[:a] []]) script)))
499
500
501 (defn purchase-item 470 (defn purchase-item
502 "Assumes that the cursor is over the desired item, and purchases 471 "Assumes that the cursor is over the desired item, and purchases
503 quantity of that item." 472 quantity of that item."
504 [n script] 473 [n script]
505 (->> script 474 (->> script
512 481
513 (defn-memo corrupt-item-list 482 (defn-memo corrupt-item-list
514 "Corrupt the num-of-items variable by switching a corrupted pokemon 483 "Corrupt the num-of-items variable by switching a corrupted pokemon
515 into out-of-bounds memory." 484 into out-of-bounds memory."
516 ([] (corrupt-item-list 485 ([] (corrupt-item-list
517 ;;(corrupted-checkpoint) 486 (corrupted-checkpoint)
518 (do-save-corruption) 487 ;;(do-save-corruption)
519 )) 488 ))
520 ([script] 489 ([script]
521 (->> script 490 (->> script
522 activate-start-menu 491 activate-start-menu
523 (set-cursor 1) ; select "POKEMON" from 492 (set-cursor 1) ; select "POKEMON" from
528 select-menu-entry 497 select-menu-entry
529 (repeat-until-different [] list-offset) 498 (repeat-until-different [] list-offset)
530 (set-cursor 9) 499 (set-cursor 9)
531 select-menu-entry ; switch 6th with 10th 500 select-menu-entry ; switch 6th with 10th
532 close-menu 501 close-menu
533 close-menu ))) 502 close-menu)))
534 503
535 (defn-memo get-lots-of-money 504 (defn-memo get-lots-of-money
536 "Sell 0xFE cancel buttons to make a tremendous amount of money." 505 "Sell 0xFE cancel buttons to make a tremendous amount of money."
537 ([] (get-lots-of-money (corrupt-item-list))) 506 ([] (get-lots-of-money (corrupt-item-list)))
538 ([script] 507 ([script]
544 (repeat-until-different [] list-offset) 513 (repeat-until-different [] list-offset)
545 select-menu-entry 514 select-menu-entry
546 (set-quantity 0xFF 0xF7) 515 (set-quantity 0xFF 0xF7)
547 (first-difference [] [:a] AF) 516 (first-difference [] [:a] AF)
548 select-menu-entry 517 select-menu-entry
549 close-menu 518 close-menu)))
550 )))
551
552 519
553 (defn note [str script] 520 (defn note [str script]
554 (println str) script) 521 (println str) script)
555 522
556 (defn-memo buy-bootstrapping-items 523 (defn-memo buy-bootstrapping-items
602 (repeat-until-different [] list-offset) 569 (repeat-until-different [] list-offset)
603 (set-cursor 9) ; goto 10th pokemon 570 (set-cursor 9) ; goto 10th pokemon
604 select-menu-entry ; do switch 571 select-menu-entry ; do switch
605 close-menu 572 close-menu
606 close-menu))) 573 close-menu)))
607 574
608 (defn-memo viridian-store->viridian-poke-center 575 (defn leave-viridian-store
609 ([] (viridian-store->viridian-poke-center 576 ([] (leave-viridian-store (corrupt-item-list-again)))
610 (corrupt-item-list-again)))
611 ([script] 577 ([script]
612 (->> script 578 (->> script
613 ;; leave store 579 ;; leave store
614 (walk [↓ ↓ 580 (walk [↓ ↓ → ↓])
615 → ↓ ↓]) 581 (do-nothing 1))))
616 (walk [← ← ← 582
617 ↓ ↓ ↓ ↓ ↓ 583 (defn force-encounter [direction script]
618 ← ← ← ↑])))) 584 (delayed-improbability-search
585 600
586 #(search-string % "Wild")
587 (partial move direction) script))
588
589 (defn-memo fight-wild-pokemon
590 ([] (fight-wild-pokemon (leave-viridian-store)))
591 ([script]
592 (->> script
593 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
594 ← ← ← ← ← ← ← ←
595 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])
596 (force-encounter →))))
597
598 (defn-memo run-from-pokemon
599 ([] (run-from-pokemon (fight-wild-pokemon)))
600 ([script]
601 (->> script
602 (scroll-text)
603 (wait-until select-menu-entry)
604 (set-cursor 1)
605 (first-difference [] → AF)
606 (scroll-text)
607 (scroll-text))))
619 608
620 (defn-memo to-poke-center-computer 609 (defn-memo to-poke-center-computer
621 ([] (to-poke-center-computer 610 ([] (to-poke-center-computer
622 (viridian-store->viridian-poke-center))) 611 (run-from-pokemon)))
623 ([script] 612 ([script]
624 (->> script 613 (->> script
625 (walk [→ → 614 (walk-thru-grass [→ ↑])
615 (walk [↑ ← ← ←
616 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
617 ← ←
618 ↑ ↑ ↑ ↑
619 → → → → ↑])
620 (walk [→ →
626 ↑ ↑ ↑ 621 ↑ ↑ ↑
627 → → → → → → → → →]) 622 → → → → → → → → →]))))
628 (do-nothing 1)))) 623
629
630 (defn-memo begin-deposits 624 (defn-memo begin-deposits
631 ([] (begin-deposits 625 ([] (begin-deposits
632 (to-poke-center-computer))) 626 (to-poke-center-computer)))
633 ([script] 627 ([script]
634 (->> script 628 (->> script
730 5 724 5
731 [0xFF 0x01]) 725 [0xFF 0x01])
732 726
733 [;; first part of item manipulation program 727 [;; first part of item manipulation program
734 0x00 728 0x00
735 0x21 ;; load target + 1 into HL 729 0x21 ;; load target into HL
736 730
737 0x95 ;; this is the target address + 1 731 0x94 ;; this is the target address
738 0xD5 732 0xD5
739 733
740 0x00 ;; relative jump back to first part 734 0x00 ;; relative jump back to first part
741 0x18 735 0x18
742 736